Skip to content

Commit 932b328

Browse files
author
Vitaliy Boyko
committed
Refactoring
1 parent 2523020 commit 932b328

File tree

5 files changed

+36
-8
lines changed

5 files changed

+36
-8
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.Nodes.ModuleGroup)
42+
.withIcon(MagentoIcons.MODULE)
4243
);
4344
}
4445
}

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

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
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.CommonXml;
14+
import com.magento.idea.magento2plugin.magento.files.ModuleAclXml;
15+
import com.magento.idea.magento2plugin.magento.files.ModuleXml;
1316

1417
import static com.intellij.patterns.PlatformPatterns.psiElement;
1518
import static com.intellij.patterns.StandardPatterns.string;
@@ -22,34 +25,35 @@ public XmlCompletionContributor() {
2225
/* PHP class member completion provider */
2326
extend(CompletionType.BASIC, psiElement(XmlTokenType.XML_DATA_CHARACTERS)
2427
.withParent(XmlPatterns.xmlText().withParent(XmlPatterns.xmlTag().withChild(
25-
XmlPatterns.xmlAttribute().withName("xsi:type").withValue(string().oneOf("init_parameter"))))
28+
XmlPatterns.xmlAttribute().withName(CommonXml.SCHEMA_VALIDATE_ATTRIBUTE)
29+
.withValue(string().oneOf(CommonXml.INIT_PARAMETER))))
2630
),
2731
new PhpClassMemberCompletionProvider()
2832
);
2933

3034
/* Module Completion provider */
3135
extend(CompletionType.BASIC, psiElement(XmlTokenType.XML_ATTRIBUTE_VALUE_TOKEN)
32-
.inside(XmlPatterns.xmlAttribute().withName("id"))
33-
.inFile(xmlFile().withName(string().endsWith("acl.xml"))),
36+
.inside(XmlPatterns.xmlAttribute().withName(ModuleAclXml.XML_ATTR_ID))
37+
.inFile(xmlFile().withName(string().endsWith(ModuleAclXml.FILE_NAME))),
3438
new ModuleNameCompletionProvider()
3539
);
3640

3741
extend(CompletionType.BASIC, psiElement(XmlTokenType.XML_ATTRIBUTE_VALUE_TOKEN)
38-
.inside(XmlPatterns.xmlAttribute().withName("name"))
39-
.inFile(xmlFile().withName(string().endsWith("module.xml"))),
42+
.inside(XmlPatterns.xmlAttribute().withName(ModuleXml.MODULE_ATTR_NAME))
43+
.inFile(xmlFile().withName(string().endsWith(ModuleXml.FILE_NAME))),
4044
new ModuleNameCompletionProvider()
4145
);
4246

4347
/* PHP Class completion provider */
4448
extend(CompletionType.BASIC, psiElement(XmlTokenType.XML_DATA_CHARACTERS)
4549
.withParent(XmlPatterns.xmlText().withParent(XmlPatterns.xmlTag().withChild(
46-
XmlPatterns.xmlAttribute().withName("xsi:type").withValue(string().oneOf("object"))))
50+
XmlPatterns.xmlAttribute().withName(CommonXml.SCHEMA_VALIDATE_ATTRIBUTE).withValue(string().oneOf(CommonXml.OBJECT))))
4751
),
4852
new PhpClassCompletionProvider()
4953
);
5054

5155
extend(CompletionType.BASIC, psiElement(XmlTokenType.XML_ATTRIBUTE_VALUE_TOKEN)
52-
.inside(XmlPatterns.xmlAttribute().withName("class")),
56+
.inside(XmlPatterns.xmlAttribute().withName(CommonXml.ATTR_CLASS)),
5357
new PhpClassCompletionProvider()
5458
);
5559

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+
}
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)