Skip to content

Commit 3f21273

Browse files
author
Vitaliy Boyko
committed
Adjusted tests and fixed bugs
1 parent 98eda93 commit 3f21273

File tree

15 files changed

+195
-21
lines changed

15 files changed

+195
-21
lines changed

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

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,16 @@ public XmlCompletionContributor() {
7676
new FilePathCompletionProvider()
7777
);
7878

79+
extend(CompletionType.BASIC, psiElement(XmlTokenType.XML_DATA_CHARACTERS)
80+
.withParent(XmlPatterns.xmlText().withParent(
81+
XmlPatterns.xmlTag().withName(UiComponentXml.XML_TAG_ITEM).withChild(
82+
XmlPatterns.xmlAttribute().withValue(string()
83+
.matches(UiComponentXml.XML_ATTRIBUTE_TEMPLATE))
84+
))
85+
),
86+
new FilePathCompletionProvider()
87+
);
88+
7989
extend(CompletionType.BASIC, psiElement(XmlTokenType.XML_ATTRIBUTE_VALUE_TOKEN)
8090
.inside(XmlPatterns.xmlAttribute().withName("type")),
8191
new VirtualTypeCompletionProvider()
@@ -198,21 +208,28 @@ public XmlCompletionContributor() {
198208

199209
extend(CompletionType.BASIC, psiElement(XmlTokenType.XML_ATTRIBUTE_VALUE_TOKEN)
200210
.inside(XmlPatterns.xmlAttributeValue().withParent(
201-
XmlPatterns.xmlAttribute().withName("component")
211+
XmlPatterns.xmlAttribute().withName(UiComponentXml.XML_ATTRIBUTE_COMPONENT)
202212
)),
203-
new RequireJsMappingCompletionProvider()
213+
new CompositeCompletionProvider(
214+
new RequireJsMappingCompletionProvider(),
215+
new FilePathCompletionProvider()
216+
)
204217
);
205218

206219
extend(CompletionType.BASIC, psiElement(XmlTokenType.XML_DATA_CHARACTERS)
207220
.withParent(XmlPatterns.xmlText().withParent(
208-
XmlPatterns.xmlTag().withName("item").withChild(
209-
XmlPatterns.xmlAttribute().withValue(string().matches("component"))
221+
XmlPatterns.xmlTag().withName(UiComponentXml.XML_TAG_ITEM).withChild(
222+
XmlPatterns.xmlAttribute().withValue(string()
223+
.matches(UiComponentXml.XML_ATTRIBUTE_COMPONENT))
210224
).withChild(
211-
XmlPatterns.xmlAttribute().withName("name")
225+
XmlPatterns.xmlAttribute().withName(UiComponentXml.XML_ATTRIBUTE_NAME)
212226
)
213227
)
214228
),
215-
new RequireJsMappingCompletionProvider()
229+
new CompositeCompletionProvider(
230+
new RequireJsMappingCompletionProvider(),
231+
new FilePathCompletionProvider()
232+
)
216233
);
217234

218235
// mftf action group completion contributor
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 UiComponentXml {
8+
public static String XML_ATTRIBUTE_TEMPLATE = "template";
9+
public static String XML_ATTRIBUTE_COMPONENT = "component";
10+
public static String XML_TAG_ITEM = "item";
11+
public static String XML_ATTRIBUTE_NAME = "name";
12+
}

src/com/magento/idea/magento2plugin/reference/xml/XmlReferenceContributor.java

Lines changed: 29 additions & 14 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.magento.files.MftfActionGroup;
1212
import com.magento.idea.magento2plugin.magento.files.MftfTest;
13+
import com.magento.idea.magento2plugin.magento.files.UiComponentXml;
1314
import com.magento.idea.magento2plugin.reference.provider.*;
1415
import com.magento.idea.magento2plugin.reference.provider.mftf.*;
1516
import com.magento.idea.magento2plugin.util.RegExUtil;
@@ -226,24 +227,38 @@ public void registerReferenceProviders(@NotNull PsiReferenceRegistrar registrar)
226227

227228
// <someXmlTag component="requireJsMappingKey" />
228229
registrar.registerReferenceProvider(
229-
XmlPatterns.xmlAttributeValue().withParent(
230-
XmlPatterns.xmlAttribute().withName("component")
231-
),
232-
new RequireJsPreferenceReferenceProvider()
230+
XmlPatterns.xmlAttributeValue().withParent(
231+
XmlPatterns.xmlAttribute().withName(UiComponentXml.XML_ATTRIBUTE_COMPONENT)
232+
),
233+
new RequireJsPreferenceReferenceProvider()
233234
);
234235

235236
// <item name="component">requireJsMappingKey</item>
236237
registrar.registerReferenceProvider(
237-
XmlPatterns.psiElement(XmlTokenType.XML_DATA_CHARACTERS).withParent(
238-
XmlPatterns.xmlText().withParent(
239-
XmlPatterns.xmlTag().withName("item").withChild(
240-
XmlPatterns.xmlAttribute().withValue(string().matches("component"))
241-
).withChild(
242-
XmlPatterns.xmlAttribute().withName("name")
243-
)
244-
)
245-
),
246-
new RequireJsPreferenceReferenceProvider()
238+
XmlPatterns.psiElement(XmlTokenType.XML_DATA_CHARACTERS).withParent(
239+
XmlPatterns.xmlText().withParent(
240+
XmlPatterns.xmlTag().withName(UiComponentXml.XML_TAG_ITEM).withChild(
241+
XmlPatterns.xmlAttribute().withValue(string().matches(UiComponentXml.XML_ATTRIBUTE_COMPONENT))
242+
).withChild(
243+
XmlPatterns.xmlAttribute().withName(UiComponentXml.XML_ATTRIBUTE_NAME)
244+
)
245+
)
246+
),
247+
new RequireJsPreferenceReferenceProvider()
248+
);
249+
250+
// <item name="template">reference</item>
251+
registrar.registerReferenceProvider(
252+
XmlPatterns.psiElement(XmlTokenType.XML_DATA_CHARACTERS).withParent(
253+
XmlPatterns.xmlText().withParent(
254+
XmlPatterns.xmlTag().withName(UiComponentXml.XML_TAG_ITEM).withChild(
255+
XmlPatterns.xmlAttribute().withValue(string().matches(UiComponentXml.XML_ATTRIBUTE_TEMPLATE))
256+
).withChild(
257+
XmlPatterns.xmlAttribute().withName(UiComponentXml.XML_ATTRIBUTE_NAME)
258+
)
259+
)
260+
),
261+
new FilePathReferenceProvider()
247262
);
248263

249264
registerReferenceForDifferentNesting(registrar);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
4+
<fieldset name="general" >
5+
<field name="test_field" component="Foo_Bar/js/fi<caret>">
6+
</field>
7+
</fieldset>
8+
</form>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
4+
<dataSource name="test_source">
5+
<argument name="data" xsi:type="array">
6+
<item name="js_config" xsi:type="array">
7+
<item name="component" xsi:type="string">Foo_Bar/js/fi<caret></item>
8+
</item>
9+
</argument>
10+
</dataSource>
11+
</form>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
4+
<dataSource name="test_source">
5+
<argument name="data" xsi:type="array">
6+
<item name="js_config" xsi:type="array">
7+
<item name="component" xsi:type="string">testF<caret></item>
8+
</item>
9+
</argument>
10+
</dataSource>
11+
</form>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
4+
<fieldset name="general" >
5+
<field name="test_field" template="Foo_Bar/temp<caret>">
6+
</field>
7+
</fieldset>
8+
</form>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
4+
<dataSource name="test_source">
5+
<argument name="data" xsi:type="array">
6+
<item name="js_config" xsi:type="array">
7+
<item name="template" xsi:type="string">Foo_Bar/temp<caret></item>
8+
</item>
9+
</argument>
10+
</dataSource>
11+
</form>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<h1>test</h1>

0 commit comments

Comments
 (0)