Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,6 @@ public boolean dependsOnFileContent() {

@Override
public int getVersion() {
return 1;
return 2;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -61,7 +62,7 @@ private void collect(
final @NotNull Map<String, Set<String>> blockTemplates,
final @NotNull Map<String, Set<String>> templateBlocks
) {
if (BLOCK_TAG.equals(tag.getName())) {
if (isBlockTemplateDeclaration(tag)) {
collectBlock(tag, blockTemplates, templateBlocks);
}

Expand All @@ -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<String, Set<String>> blockTemplates,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,6 @@ public boolean dependsOnFileContent() {

@Override
public int getVersion() {
return 1;
return 2;
}
}
3 changes: 1 addition & 2 deletions src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,12 @@
<depends>com.intellij.platform.images</depends>
<depends>com.intellij.modules.json</depends>
<depends>com.intellij.copyright</depends>
<depends>com.intellij.mcpServer</depends>
<depends optional="true" config-file="withMcp.xml">com.intellij.mcpServer</depends>
<depends optional="true" config-file="withPhp.xml">com.jetbrains.php</depends>

<extensions defaultExtensionNs="com.intellij">
<projectService serviceImplementation="com.magento.idea.magento2plugin.project.Settings"/>
<projectService serviceImplementation="com.magento.idea.magento2plugin.project.startup.DeferredProjectOpenActions"/>
<mcpServer.mcpToolset implementation="com.magento.idea.magento2plugin.mcp.MagentoMcpProjectToolset"/>

<projectConfigurable
groupId="tools"
Expand Down
11 changes: 11 additions & 0 deletions src/main/resources/META-INF/withMcp.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<idea-plugin>
<extensions defaultExtensionNs="com.intellij">
<mcpServer.mcpToolset implementation="com.magento.idea.magento2plugin.mcp.MagentoMcpProjectToolset"/>
</extensions>
</idea-plugin>
2 changes: 1 addition & 1 deletion src/main/resources/META-INF/withPhp.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/
-->
<idea-plugin>
<depends optional="true" config-file="withPhpMcp.xml">com.intellij.mcpServer</depends>
<depends optional="true" config-file="withJsGraphQl.xml">com.intellij.lang.jsgraphql</depends>
<actions>
<!-- In editor generators -->
Expand Down Expand Up @@ -154,7 +155,6 @@
<projectTemplatesFactory implementation="com.magento.idea.magento2plugin.generation.php.MagentoTemplatesFactory"/>

<projectService serviceImplementation="com.magento.idea.magento2uct.settings.UctSettingsService"/>
<mcpServer.mcpToolset implementation="com.magento.idea.magento2plugin.mcp.MagentoMcpToolset"/>

<completion.contributor language="XML" implementationClass="com.magento.idea.magento2plugin.completion.xml.XmlCompletionContributor" id="xml"/>
<completion.contributor language="PHP" implementationClass="com.magento.idea.magento2plugin.completion.php.PhpCompletionContributor" id="php"/>
Expand Down
11 changes: 11 additions & 0 deletions src/main/resources/META-INF/withPhpMcp.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<idea-plugin>
<extensions defaultExtensionNs="com.intellij">
<mcpServer.mcpToolset implementation="com.magento.idea.magento2plugin.mcp.MagentoMcpToolset"/>
</extensions>
</idea-plugin>
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php
namespace Foo\Bar\Block\Category;

use Magento\Framework\View\Element\Template;

class ListProduct extends Template
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<block class="Foo\Bar\Block\Widget\TestMethod" name="foo.bar.template.block" template="Foo_Bar::widget/customer_creations.phtml"/>
<referenceBlock name="category.products.list" class="Foo\Bar\Block\Category\ListProduct" template="Foo_Bar::category/list.phtml"/>
</body>
</page>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php
/** @var \Foo\Bar\Block\Category\ListProduct $block */
?>
<div>Category list</div>
Loading