Skip to content

Commit 1506f60

Browse files
author
bohar
committed
[XmlCompletion] #91 - Added php class completion for source_model tag in system.xml and source_model parameter tag attribute in widget.xml
1 parent 0c3ff4f commit 1506f60

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-0
lines changed

src/com/magento/idea/magento2plugin/completion/xml/XmlCompletionContributor.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,23 @@ public XmlCompletionContributor() {
103103
new PhpConstructorArgumentCompletionProvider()
104104
);
105105

106+
// <source_model>php class completion</source_model> in system.xml files.
107+
extend(CompletionType.BASIC, psiElement(XmlTokenType.XML_DATA_CHARACTERS)
108+
.inside(XmlPatterns.xmlTag().withName(ModuleSystemXml.SOURCE_MODEL_ELEMENT_NAME)
109+
.withParent(XmlPatterns.xmlTag().withName(ModuleSystemXml.FIELD_ELEMENT_NAME))
110+
).inFile(xmlFile().withName(string().endsWith(ModuleSystemXml.FILE_NAME))),
111+
new PhpClassCompletionProvider()
112+
);
113+
114+
// <parameter source_model="completion">...</parameter> in widget.xml files.
115+
extend(CompletionType.BASIC, psiElement(XmlTokenType.XML_ATTRIBUTE_VALUE_TOKEN)
116+
.inside(XmlPatterns.xmlAttribute().withName(ModuleWidgetXml.ATTRIBUTE_SOURCE_MODEL_NAME)
117+
.withParent(XmlPatterns.xmlTag().withName(ModuleWidgetXml.TAG_PARAMETER_NAME).
118+
withParent(XmlPatterns.xmlTag().withName(ModuleWidgetXml.TAG_PARAMETERS_NAME)))
119+
).inFile(xmlFile().withName(string().endsWith(ModuleWidgetXml.FILE_NAME))),
120+
new PhpClassCompletionProvider()
121+
);
122+
106123
// <service method="methodName"/>
107124
extend(CompletionType.BASIC, psiElement(XmlTokenType.XML_ATTRIBUTE_VALUE_TOKEN)
108125
.inside(XmlPatterns.xmlAttribute().withName("method")
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/*
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
package com.magento.idea.magento2plugin.magento.files;
6+
7+
public class ModuleSystemXml {
8+
public static final String FILE_NAME = "system.xml";
9+
public static final String FIELD_ELEMENT_NAME = "field";
10+
public static final String SOURCE_MODEL_ELEMENT_NAME = "source_model";
11+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/*
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
package com.magento.idea.magento2plugin.magento.files;
6+
7+
public class ModuleWidgetXml {
8+
public static final String FILE_NAME = "widget.xml";
9+
public static final String TAG_WIDGET_NAME = "widget";
10+
public static final String TAG_PARAMETERS_NAME = "parameters";
11+
public static final String TAG_PARAMETER_NAME = "parameter";
12+
public static final String ATTRIBUTE_SOURCE_MODEL_NAME = "source_model";
13+
}

0 commit comments

Comments
 (0)