Skip to content

Commit 4bb9876

Browse files
author
Vitaliy
authored
Merge branch '1.0.0-develop' into magento-version-util
2 parents ec747ac + 2ec77d5 commit 4bb9876

File tree

6 files changed

+80
-14
lines changed

6 files changed

+80
-14
lines changed

src/com/magento/idea/magento2plugin/completion/provider/ModuleNameCompletionProvider.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import com.intellij.psi.PsiElement;
1313
import com.intellij.util.ProcessingContext;
1414
import com.intellij.util.indexing.FileBasedIndex;
15+
import com.magento.idea.magento2plugin.MagentoIcons;
1516
import com.magento.idea.magento2plugin.stubs.indexes.ModuleNameIndex;
1617
import org.jetbrains.annotations.NotNull;
1718

@@ -38,7 +39,7 @@ protected void addCompletions(@NotNull CompletionParameters parameters,
3839
result.addElement(
3940
LookupElementBuilder
4041
.create(moduleName)
41-
.withIcon(AllIcons.Modules.ModulesNode)
42+
.withIcon(MagentoIcons.MODULE)
4243
);
4344
}
4445
}

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

Lines changed: 54 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import com.intellij.psi.xml.XmlTokenType;
1111
import com.magento.idea.magento2plugin.completion.provider.*;
1212
import com.magento.idea.magento2plugin.completion.provider.mftf.*;
13+
import com.magento.idea.magento2plugin.magento.files.*;
1314

1415
import static com.intellij.patterns.PlatformPatterns.psiElement;
1516
import static com.intellij.patterns.StandardPatterns.string;
@@ -18,22 +19,62 @@
1819
public class XmlCompletionContributor extends CompletionContributor {
1920

2021
public XmlCompletionContributor() {
21-
extend(CompletionType.BASIC, psiElement(XmlTokenType.XML_ATTRIBUTE_VALUE_TOKEN),
22-
new CompositeCompletionProvider(
23-
new PhpClassCompletionProvider(),
24-
new PhpClassMemberCompletionProvider(),
25-
new ModuleNameCompletionProvider(),
26-
new FilePathCompletionProvider()
27-
)
22+
23+
/* PHP class member completion provider */
24+
extend(CompletionType.BASIC, psiElement(XmlTokenType.XML_DATA_CHARACTERS)
25+
.withParent(XmlPatterns.xmlText().withParent(XmlPatterns.xmlTag().withChild(
26+
XmlPatterns.xmlAttribute().withName(CommonXml.SCHEMA_VALIDATE_ATTRIBUTE)
27+
.withValue(string().oneOf(CommonXml.INIT_PARAMETER))))
28+
),
29+
new PhpClassMemberCompletionProvider()
30+
);
31+
32+
/* Module Completion provider */
33+
extend(CompletionType.BASIC, psiElement(XmlTokenType.XML_ATTRIBUTE_VALUE_TOKEN)
34+
.inside(XmlPatterns.xmlAttribute().withName(ModuleAclXml.XML_ATTR_ID))
35+
.inFile(xmlFile().withName(string().endsWith(ModuleAclXml.FILE_NAME))),
36+
new ModuleNameCompletionProvider()
2837
);
2938

30-
extend(CompletionType.BASIC, psiElement(XmlTokenType.XML_DATA_CHARACTERS),
31-
new CompositeCompletionProvider(
32-
new PhpClassCompletionProvider(),
33-
new PhpClassMemberCompletionProvider(),
34-
new ModuleNameCompletionProvider(),
39+
extend(CompletionType.BASIC, psiElement(XmlTokenType.XML_ATTRIBUTE_VALUE_TOKEN)
40+
.inside(XmlPatterns.xmlAttribute().withName(ModuleXml.MODULE_ATTR_NAME))
41+
.inFile(xmlFile().withName(string().endsWith(ModuleXml.FILE_NAME))),
42+
new ModuleNameCompletionProvider()
43+
);
44+
45+
/* PHP Class completion provider */
46+
47+
// <randomTag xsi:type="completion">
48+
extend(CompletionType.BASIC, psiElement(XmlTokenType.XML_DATA_CHARACTERS)
49+
.withParent(XmlPatterns.xmlText().withParent(XmlPatterns.xmlTag().withChild(
50+
XmlPatterns.xmlAttribute().withName(CommonXml.SCHEMA_VALIDATE_ATTRIBUTE).withValue(string().oneOf(CommonXml.OBJECT))))
51+
),
52+
new PhpClassCompletionProvider()
53+
);
54+
55+
// <randomTag class="completion">
56+
extend(CompletionType.BASIC, psiElement(XmlTokenType.XML_ATTRIBUTE_VALUE_TOKEN)
57+
.inside(XmlPatterns.xmlAttribute().withName(CommonXml.ATTR_CLASS)),
58+
new PhpClassCompletionProvider()
59+
);
60+
61+
// <preference for="completion">
62+
extend(CompletionType.BASIC, psiElement(XmlTokenType.XML_ATTRIBUTE_VALUE_TOKEN)
63+
.inside(XmlPatterns.xmlAttribute().withName(ModuleDiXml.PREFERENCE_ATTR_FOR)),
64+
new PhpClassCompletionProvider()
65+
);
66+
67+
// <type name="completion">
68+
extend(CompletionType.BASIC, psiElement(XmlTokenType.XML_ATTRIBUTE_VALUE_TOKEN)
69+
.inside(XmlPatterns.xmlAttribute().withName(ModuleDiXml.PLUGIN_TYPE_ATTR_NAME)
70+
.withParent(XmlPatterns.xmlTag().withName(ModuleDiXml.PLUGIN_TYPE_TAG))),
71+
new PhpClassCompletionProvider()
72+
);
73+
74+
/* File Path Completion provider */
75+
extend(CompletionType.BASIC, psiElement(XmlTokenType.XML_ATTRIBUTE_VALUE_TOKEN)
76+
.inside(XmlPatterns.xmlAttribute().withName(LayoutXml.XML_ATTRIBUTE_TEMPLATE)),
3577
new FilePathCompletionProvider()
36-
)
3778
);
3879

3980
extend(CompletionType.BASIC, psiElement(XmlTokenType.XML_ATTRIBUTE_VALUE_TOKEN)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
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 CommonXml {
8+
public static String SCHEMA_VALIDATE_ATTRIBUTE = "xsi:type";
9+
public static String INIT_PARAMETER = "init_parameter";
10+
public static String OBJECT = "object";
11+
public static String ATTR_CLASS = "class";
12+
}

src/com/magento/idea/magento2plugin/magento/files/LayoutXml.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ public class LayoutXml {
1010
public static String CacheableAttributeFalseValue = "false";
1111
public static String BlockAttributeTagName = "block";
1212
public static String ReferenceBlockAttributeTagName = "referenceBlock";
13+
public static String XML_ATTRIBUTE_TEMPLATE = "template";
1314
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
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 ModuleAclXml {
8+
public static String XML_ATTR_ID = "id";
9+
public static String FILE_NAME = "acl.xml";
10+
}

src/com/magento/idea/magento2plugin/magento/files/ModuleXml.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
public class ModuleXml implements ModuleFileInterface {
1111
public static String FILE_NAME = "module.xml";
12+
public static String MODULE_ATTR_NAME = "name";
1213
public static String TEMPLATE = "Magento Module Xml";
1314
private static ModuleXml INSTANCE = null;
1415

0 commit comments

Comments
 (0)