diff --git a/CHANGELOG.md b/CHANGELOG.md index 3f6b863db..44ef41076 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0). ### Fixed - Class cast exception when resolving observer name references outside a valid `event` tag in `events.xml`. +- JetBrains MCP Server is now an optional plugin dependency; Magento MCP tools are registered only when MCP support is available. ## 2026.2.2 diff --git a/gradle.properties b/gradle.properties index 2091d4b28..7de5e025b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,7 +5,7 @@ pluginVersion = 2026.3.0 pluginSinceBuild = 261.21525.38 pluginUntilBuild = 268.* platformType = PS -platformVersion = 261.22158.208 +platformVersion = 2026.1.4 platformPlugins = com.intellij.lang.jsgraphql:261.22158.185 platformBundledPlugins = com.intellij.modules.json,com.jetbrains.php,JavaScript,com.intellij.css,org.jetbrains.plugins.yaml,com.intellij.copyright,com.intellij.mcpServer gradleVersion = 9.3.1 diff --git a/src/main/java/com/magento/idea/magento2plugin/stubs/indexes/xml/LayoutBlockTemplateIndex.java b/src/main/java/com/magento/idea/magento2plugin/stubs/indexes/xml/LayoutBlockTemplateIndex.java index ed6a57b5e..512be69b9 100644 --- a/src/main/java/com/magento/idea/magento2plugin/stubs/indexes/xml/LayoutBlockTemplateIndex.java +++ b/src/main/java/com/magento/idea/magento2plugin/stubs/indexes/xml/LayoutBlockTemplateIndex.java @@ -57,6 +57,6 @@ public boolean dependsOnFileContent() { @Override public int getVersion() { - return 1; + return 2; } } diff --git a/src/main/java/com/magento/idea/magento2plugin/stubs/indexes/xml/LayoutBlockTemplateIndexParser.java b/src/main/java/com/magento/idea/magento2plugin/stubs/indexes/xml/LayoutBlockTemplateIndexParser.java index 2b186333e..e6dc139d7 100644 --- a/src/main/java/com/magento/idea/magento2plugin/stubs/indexes/xml/LayoutBlockTemplateIndexParser.java +++ b/src/main/java/com/magento/idea/magento2plugin/stubs/indexes/xml/LayoutBlockTemplateIndexParser.java @@ -21,6 +21,7 @@ public class LayoutBlockTemplateIndexParser { private static final String BLOCK_TAG = "block"; + private static final String REFERENCE_BLOCK_TAG = "referenceBlock"; private static final String ARGUMENT_TAG = "argument"; private static final String CLASS_ATTRIBUTE = "class"; private static final String TEMPLATE_ATTRIBUTE = "template"; @@ -61,7 +62,7 @@ private void collect( final @NotNull Map> blockTemplates, final @NotNull Map> templateBlocks ) { - if (BLOCK_TAG.equals(tag.getName())) { + if (isBlockTemplateDeclaration(tag)) { collectBlock(tag, blockTemplates, templateBlocks); } @@ -70,6 +71,10 @@ private void collect( } } + private boolean isBlockTemplateDeclaration(final @NotNull XmlTag tag) { + return BLOCK_TAG.equals(tag.getName()) || REFERENCE_BLOCK_TAG.equals(tag.getName()); + } + private void collectBlock( final @NotNull XmlTag blockTag, final @NotNull Map> blockTemplates, diff --git a/src/main/java/com/magento/idea/magento2plugin/stubs/indexes/xml/LayoutTemplateBlockIndex.java b/src/main/java/com/magento/idea/magento2plugin/stubs/indexes/xml/LayoutTemplateBlockIndex.java index c57c71916..9c1fab552 100644 --- a/src/main/java/com/magento/idea/magento2plugin/stubs/indexes/xml/LayoutTemplateBlockIndex.java +++ b/src/main/java/com/magento/idea/magento2plugin/stubs/indexes/xml/LayoutTemplateBlockIndex.java @@ -57,6 +57,6 @@ public boolean dependsOnFileContent() { @Override public int getVersion() { - return 1; + return 2; } } diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index 69f1596b9..5ad84c94c 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -11,13 +11,12 @@ com.intellij.platform.images com.intellij.modules.json com.intellij.copyright - com.intellij.mcpServer + com.intellij.mcpServer com.jetbrains.php - + + + + + diff --git a/src/main/resources/META-INF/withPhp.xml b/src/main/resources/META-INF/withPhp.xml index 0d68c9400..ca9672b11 100644 --- a/src/main/resources/META-INF/withPhp.xml +++ b/src/main/resources/META-INF/withPhp.xml @@ -5,6 +5,7 @@ */ --> + com.intellij.mcpServer com.intellij.lang.jsgraphql @@ -154,7 +155,6 @@ - diff --git a/src/main/resources/META-INF/withPhpMcp.xml b/src/main/resources/META-INF/withPhpMcp.xml new file mode 100644 index 000000000..ba8fa0b3a --- /dev/null +++ b/src/main/resources/META-INF/withPhpMcp.xml @@ -0,0 +1,11 @@ + + + + + + diff --git a/src/test/java/com/magento/idea/magento2plugin/linemarker/php/BlockTemplateLinemarkerRegistrarTest.java b/src/test/java/com/magento/idea/magento2plugin/linemarker/php/BlockTemplateLinemarkerRegistrarTest.java index f7f2d9fc0..8047e5657 100644 --- a/src/test/java/com/magento/idea/magento2plugin/linemarker/php/BlockTemplateLinemarkerRegistrarTest.java +++ b/src/test/java/com/magento/idea/magento2plugin/linemarker/php/BlockTemplateLinemarkerRegistrarTest.java @@ -24,6 +24,18 @@ public void testBlockClassShouldHaveTemplateLinemarker() { assertProviderHasLinemarker(phpClass, "Navigate to block template"); } + /** + * Layout referenceBlock classes should navigate to their declared regular templates. + */ + public void testReferenceBlockClassShouldHaveTemplateLinemarker() { + myFixture.configureFromTempProjectFile( + "app/code/Foo/Bar/Block/Category/ListProduct.php" + ); + final PhpClass phpClass = PsiTreeUtil.findChildOfType(myFixture.getFile(), PhpClass.class); + + assertProviderHasLinemarker(phpClass, "Navigate to block template"); + } + /** * Regular templates should navigate back to layout block classes that declare them. */ @@ -36,6 +48,18 @@ public void testTemplateShouldHaveBlockLinemarker() { assertProviderHasLinemarker(anchor, "Navigate to template block"); } + /** + * Regular templates should navigate back to layout referenceBlock classes that declare them. + */ + public void testReferenceBlockTemplateShouldHaveBlockLinemarker() { + myFixture.configureFromTempProjectFile( + "app/code/Foo/Bar/view/frontend/templates/category/list.phtml" + ); + final PsiElement anchor = PsiTreeUtil.getDeepestFirst(myFixture.getFile()); + + assertProviderHasLinemarker(anchor, "Navigate to template block"); + } + private void assertProviderHasLinemarker(final PsiElement element, final String tooltip) { final LineMarkerInfo lineMarker = new BlockTemplateLineMarkerProvider() .getLineMarkerInfo(element); diff --git a/src/test/testData/project/magento2/app/code/Foo/Bar/Block/Category/ListProduct.php b/src/test/testData/project/magento2/app/code/Foo/Bar/Block/Category/ListProduct.php new file mode 100644 index 000000000..cfe07b1ed --- /dev/null +++ b/src/test/testData/project/magento2/app/code/Foo/Bar/Block/Category/ListProduct.php @@ -0,0 +1,8 @@ + + diff --git a/src/test/testData/project/magento2/app/code/Foo/Bar/view/frontend/templates/category/list.phtml b/src/test/testData/project/magento2/app/code/Foo/Bar/view/frontend/templates/category/list.phtml new file mode 100644 index 000000000..3f4e5e518 --- /dev/null +++ b/src/test/testData/project/magento2/app/code/Foo/Bar/view/frontend/templates/category/list.phtml @@ -0,0 +1,4 @@ + +
Category list