Skip to content

Commit 63e7c51

Browse files
author
Vitaliy
authored
Merge branch '1.0.1-develop' into dialog-center-position
2 parents 567cb15 + 7b8eaf0 commit 63e7c51

File tree

14 files changed

+222
-6
lines changed

14 files changed

+222
-6
lines changed

build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ plugins {
88
}
99

1010
group 'com.magento.idea'
11-
version '0.0.9'
11+
version '1.0.1'
1212

1313
apply plugin: 'org.jetbrains.intellij'
1414
apply plugin: 'java'
@@ -47,7 +47,7 @@ publishPlugin {
4747
token = System.getenv("MAGENTO_PHPSTORM_intellijPublishToken")
4848
if (Boolean.valueOf(System.getenv("MAGENTO_PHPSTORM_isAlpha"))) {
4949
channels 'alpha'
50-
//version = version + "-alpha-" + getDate()
50+
version = version + "-alpha-" + getDate()
5151
}
5252
}
5353

resources/META-INF/plugin.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<idea-plugin>
88
<id>com.magento.idea.magento2plugin</id>
99
<name>Magento PhpStorm</name>
10-
<version>0.0.9</version>
10+
<version>1.0.1</version>
1111
<vendor url="https://github.com/magento/magento2-phpstorm-plugin">Magento Inc.</vendor>
1212

1313
<description><![CDATA[

src/com/magento/idea/magento2plugin/completion/provider/mftf/ActionGroupCompletionProvider.java

+33
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,13 @@
99
import com.intellij.codeInsight.completion.CompletionResultSet;
1010
import com.intellij.codeInsight.lookup.LookupElementBuilder;
1111
import com.intellij.psi.PsiElement;
12+
import com.intellij.psi.util.PsiTreeUtil;
13+
import com.intellij.psi.xml.XmlAttribute;
14+
import com.intellij.psi.xml.XmlAttributeValue;
15+
import com.intellij.psi.xml.XmlTag;
1216
import com.intellij.util.ProcessingContext;
1317
import com.intellij.util.indexing.FileBasedIndex;
18+
import com.magento.idea.magento2plugin.magento.files.MftfActionGroup;
1419
import com.magento.idea.magento2plugin.stubs.indexes.mftf.ActionGroupIndex;
1520
import org.jetbrains.annotations.NotNull;
1621

@@ -31,9 +36,37 @@ protected void addCompletions(@NotNull CompletionParameters parameters,
3136

3237
Collection<String> selectorNames
3338
= FileBasedIndex.getInstance().getAllKeys(ActionGroupIndex.KEY, position.getProject());
39+
String currentActionGroup = getCurrentActionGroupName((XmlAttributeValue) parameters.getPosition().getParent());
3440

3541
for (String selectorName: selectorNames) {
42+
if (selectorName.equals(currentActionGroup)) {
43+
continue;
44+
}
45+
3646
result.addElement(LookupElementBuilder.create(selectorName));
3747
}
3848
}
49+
50+
private String getCurrentActionGroupName(XmlAttributeValue xmlAttributeValue) {
51+
PsiElement xmlAttribute = xmlAttributeValue.getParent();
52+
XmlTag xmlTag = PsiTreeUtil.getParentOfType(xmlAttribute, XmlTag.class);
53+
54+
if (xmlTag == null) {
55+
return null;
56+
}
57+
58+
XmlAttribute nameAttribute = xmlTag.getAttribute(MftfActionGroup.NAME_ATTRIBUTE);
59+
60+
if (nameAttribute == null) {
61+
return null;
62+
}
63+
64+
String value = nameAttribute.getValue();
65+
66+
if (value == null || value.isEmpty()) {
67+
return null;
68+
}
69+
70+
return value;
71+
}
3972
}

src/com/magento/idea/magento2plugin/linemarker/php/WebApiLineMarkerProvider.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import com.intellij.codeInsight.daemon.LineMarkerProvider;
99
import com.intellij.codeInsight.navigation.NavigationGutterIconBuilder;
1010
import com.intellij.psi.PsiElement;
11+
import com.intellij.psi.util.PsiTreeUtil;
1112
import com.intellij.psi.xml.XmlTag;
1213
import com.jetbrains.php.lang.psi.elements.Method;
1314
import com.jetbrains.php.lang.psi.elements.PhpClass;
@@ -62,7 +63,7 @@ public void collectSlowLineMarkers(@NotNull List<PsiElement> psiElements, @NotNu
6263
.create(MagentoIcons.WEB_API)
6364
.setTargets(results)
6465
.setTooltipText(tooltipText.toString());
65-
collection.add(builder.createLineMarkerInfo(psiElement));
66+
collection.add(builder.createLineMarkerInfo(PsiTreeUtil.getDeepestFirst(psiElement)));
6667
}
6768
}
6869

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

+1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@ public class MftfActionGroup {
1313
public static String USER_INPUT_TAG = "userInput";
1414
public static String ROOT_TAG = "actionGroup";
1515
public static String URL_ATTRIBUTE = "url";
16+
public static String NAME_ATTRIBUTE = "name";
1617
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
namespace Foo\Bar\Block\Test;
4+
5+
use Magento\Framework\View\Element\Template;
6+
7+
class ViewBlock extends Template
8+
{
9+
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
10+
<actionGroup name="MyActionGroup" extends="MyActionGr<caret>">
11+
</actionGroup>
12+
</actionGroups>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Catalog\Model;
8+
9+
class ClassNotConfiguredInWebApiXml
10+
{
11+
public function create()
12+
{
13+
}
14+
15+
public function update()
16+
{
17+
}
18+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Catalog\Service;
8+
9+
class TestService
10+
{
11+
public function create()
12+
{
13+
}
14+
15+
public function update()
16+
{
17+
}
18+
}
19+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<routes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Webapi:etc/webapi.xsd">
9+
<route url="/V1/blog/post" method="PUT">
10+
<service class="Magento\Catalog\Service\TestService" method="create"/>
11+
<resources>
12+
<resource ref="Magento_Catalog::test"/>
13+
</resources>
14+
</route>
15+
<route url="/V1/blog/update" method="POST">
16+
<service class="Magento\Catalog\Service\TestService" method="update"/>
17+
<resources>
18+
<resource ref="Magento_Catalog::test"/>
19+
</resources>
20+
</route>
21+
</routes>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
package com.magento.idea.magento2plugin.actions.generation.generator;
6+
7+
import com.intellij.openapi.project.Project;
8+
import com.intellij.psi.PsiFile;
9+
import com.magento.idea.magento2plugin.actions.generation.data.BlockFileData;
10+
11+
public class ModuleBlockClassGeneratorTest extends BaseGeneratorTestCase {
12+
13+
/**
14+
* Test Block generator
15+
*/
16+
public void testGenerateFile() {
17+
Project project = myFixture.getProject();
18+
19+
BlockFileData blockData = new BlockFileData(
20+
"Block/Test",
21+
"ViewBlock",
22+
"Foo_Bar",
23+
"Foo\\Bar\\Block\\Test"
24+
);
25+
ModuleBlockClassGenerator moduleBlockClassGenerator = new ModuleBlockClassGenerator(blockData, project);
26+
PsiFile blockFile = moduleBlockClassGenerator.generate("test");
27+
28+
String filePath = this.getFixturePath("ViewBlock.php");
29+
PsiFile expectedFile = myFixture.configureByFile(filePath);
30+
31+
assertGeneratedFileIsCorrect(expectedFile, "src/app/code/Foo/Bar/Block/Test", blockFile);
32+
}
33+
}

tests/com/magento/idea/magento2plugin/completion/xml/MftfNameCompletionRegistrarTest.java

+7
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,11 @@ public void testExtendsSameNameMustBeEmpty() {
3131

3232
assertCompletionNotShowing(filePath);
3333
}
34+
35+
public void testExtendsSameNameMustBeEmptyForActionGroup() {
36+
String filePath = this.getFixturePath("TestActionGroup.xml");
37+
myFixture.copyFileToProject(filePath);
38+
39+
assertCompletionNotShowing(filePath);
40+
}
3441
}

tests/com/magento/idea/magento2plugin/inspections/php/GraphQlResolverInspectionTest.java

-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
*/
55
package com.magento.idea.magento2plugin.inspections.php;
66

7-
import com.magento.idea.magento2plugin.bundles.InspectionBundle;
8-
97
public class GraphQlResolverInspectionTest extends InspectionPhpFixtureTestCase {
108

119
private final String errorMessage = inspectionBundle.message(
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/*
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
package com.magento.idea.magento2plugin.linemarker.php;
6+
7+
import com.intellij.openapi.application.impl.ApplicationInfoImpl;
8+
import com.magento.idea.magento2plugin.MagentoIcons;
9+
10+
public class WebApiLinemarkerRegistrarTest extends LinemarkerPhpFixtureTestCase {
11+
12+
private static final String expectedClassLineMarkerTooltip =
13+
"Navigate to Web API configuration:<pre> PUT /V1/blog/post\n" +
14+
" POST /V1/blog/update\n" +
15+
"</pre>";
16+
17+
private static final String expectedMethodCreateLineMarkerTooltip =
18+
"Navigate to Web API configuration:<pre> POST /V1/blog/update\n" +
19+
"</pre>";
20+
21+
private static final String expectedMethodUpdateLineMarkerTooltip =
22+
"Navigate to Web API configuration:<pre> PUT /V1/blog/post\n" +
23+
"</pre>";
24+
25+
/**
26+
* Class configured as WEB API service in web_api.xml should have WEB API line markers
27+
*/
28+
public void testWebApiServiceShouldHaveLinemarker() {
29+
String filePath = this.getFixturePath("TestService.php");
30+
31+
//work around for issue caused by com.magento.idea.magento2plugin.linemarker.xml.LineMarkerXmlTagDecorator
32+
//in com.intellij.psi.impl.smartPointers.SmartPsiElementPointerImpl.createElementInfo
33+
boolean isInStressTestCurrent = ApplicationInfoImpl.isInStressTest();
34+
ApplicationInfoImpl.setInStressTest(true);
35+
36+
myFixture.configureByFile(filePath);
37+
38+
//assert class line marker
39+
assertHasLinemarkerWithTooltipAndIcon(expectedClassLineMarkerTooltip, MagentoIcons.WEB_API.toString());
40+
41+
//assert methods line markers
42+
assertHasLinemarkerWithTooltipAndIcon(expectedMethodCreateLineMarkerTooltip, MagentoIcons.WEB_API.toString());
43+
assertHasLinemarkerWithTooltipAndIcon(expectedMethodUpdateLineMarkerTooltip, MagentoIcons.WEB_API.toString());
44+
45+
//restore default value
46+
ApplicationInfoImpl.setInStressTest(isInStressTestCurrent);
47+
}
48+
49+
/**
50+
* Regular class should not have WEB API line markers
51+
*/
52+
public void testRegularPhpClassShouldNotHaveLinemarker() {
53+
String filePath = this.getFixturePath("ClassNotConfiguredInWebApiXml.php");
54+
myFixture.configureByFile(filePath);
55+
56+
//assert class line marker
57+
assertHasNoLinemarkerWithTooltipAndIcon(expectedClassLineMarkerTooltip, MagentoIcons.WEB_API.toString());
58+
59+
//assert methods line markers
60+
assertHasNoLinemarkerWithTooltipAndIcon(expectedMethodCreateLineMarkerTooltip, MagentoIcons.WEB_API.toString());
61+
assertHasNoLinemarkerWithTooltipAndIcon(expectedMethodUpdateLineMarkerTooltip, MagentoIcons.WEB_API.toString());
62+
}
63+
}

0 commit comments

Comments
 (0)