Skip to content

Commit 5f62adb

Browse files
Merge branch '5.4.0-develop' into fix-bug-ConfigurasiManager
2 parents 6c78ed6 + 4250faa commit 5f62adb

File tree

5 files changed

+74
-39
lines changed

5 files changed

+74
-39
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0).
88

99
### Fixed
1010

11-
- Fixed compatibility with PhpStorm/IntelliJ 2025.* [#2495](https://github.com/magento/magento2-phpstorm-plugin/pull/2495)
11+
- Compatibility with PhpStorm/IntelliJ 2025.* [#2495](https://github.com/magento/magento2-phpstorm-plugin/pull/2495)
12+
- "Copy Path/Reference" does not show the preview value [#2497](https://github.com/magento/magento2-phpstorm-plugin/pull/2497)
13+
- Must not start write action from within read action in the other thread [#2498](https://github.com/magento/magento2-phpstorm-plugin/pull/2498)
14+
- URN map generation during indexing [#2499](https://github.com/magento/magento2-phpstorm-plugin/pull/2499)
1215

1316
## 2025.0.0
1417

src/main/java/com/magento/idea/magento2plugin/actions/CopyMagentoPath.java

Lines changed: 44 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
package com.magento.idea.magento2plugin.actions;
77

88
import com.intellij.ide.actions.CopyPathProvider;
9-
import com.intellij.openapi.actionSystem.AnActionEvent;
10-
import com.intellij.openapi.actionSystem.PlatformDataKeys;
119
import com.intellij.openapi.editor.Editor;
1210
import com.intellij.openapi.project.Project;
1311
import com.intellij.openapi.vfs.VirtualFile;
@@ -27,8 +25,7 @@ public class CopyMagentoPath extends CopyPathProvider {
2725
public static final String PHTML_EXTENSION = "phtml";
2826
public static final String JS_EXTENSION = "js";
2927
public static final String CSS_EXTENSION = "css";
30-
private final List<String> acceptedTypes
31-
= Arrays.asList(PHTML_EXTENSION, JS_EXTENSION, CSS_EXTENSION);
28+
public static final String HTML_EXTENSION = "html";
3229
private static final List<String> SUPPORTED_IMAGE_EXTENSIONS
3330
= new ArrayList<>(Arrays.asList(ImageIO.getReaderFormatNames()));
3431
public static final String SEPARATOR = "::";
@@ -57,20 +54,6 @@ public CopyMagentoPath() {
5754
SUPPORTED_IMAGE_EXTENSIONS.add("svg");
5855
}
5956

60-
@Override
61-
public void update(@NotNull final AnActionEvent event) {
62-
final VirtualFile virtualFile = event.getData(PlatformDataKeys.VIRTUAL_FILE);
63-
if (isNotValidFile(virtualFile)) {
64-
event.getPresentation().setVisible(false);
65-
}
66-
}
67-
68-
private boolean isNotValidFile(final VirtualFile virtualFile) {
69-
return virtualFile != null && virtualFile.isDirectory()
70-
|| virtualFile != null && !acceptedTypes.contains(virtualFile.getExtension())
71-
&& !SUPPORTED_IMAGE_EXTENSIONS.contains(virtualFile.getExtension());
72-
}
73-
7457
@Override
7558
public @Nullable String getPathToElement(
7659
final @NotNull Project project,
@@ -94,30 +77,61 @@ private boolean isNotValidFile(final VirtualFile virtualFile) {
9477
final StringBuilder fullPath = new StringBuilder(virtualFile.getPath());
9578

9679
index = -1;
97-
String[] paths;
80+
final String[] paths;
9881

9982
if (PHTML_EXTENSION.equals(virtualFile.getExtension())) {
10083
paths = templatePaths;
101-
} else if (JS_EXTENSION.equals(virtualFile.getExtension())
102-
|| CSS_EXTENSION.equals(virtualFile.getExtension())
103-
|| SUPPORTED_IMAGE_EXTENSIONS.contains(virtualFile.getExtension())) {
84+
} else if (isMagentoFile(virtualFile)) {
10485
paths = webPaths;
10586
} else {
106-
return fullPath.toString();
87+
return "";
10788
}
10889

10990
try {
110-
final int endIndex = getIndexOf(paths, fullPath, paths[++index]);
111-
final int offset = paths[index].length();
112-
113-
fullPath.replace(0, endIndex + offset, "");
114-
115-
return moduleName + SEPARATOR + fullPath;
91+
return getResultPath(virtualFile, paths, fullPath, moduleName);
11692
} catch (ArrayIndexOutOfBoundsException exception) {
117-
return fullPath.toString();
93+
return "";
11894
}
11995
}
12096

97+
/**
98+
* Determines if the provided file is supported by Magento Path.
99+
*
100+
* @param virtualFile the virtual file to be checked
101+
* @return bool
102+
*/
103+
private static boolean isMagentoFile(@NotNull final VirtualFile virtualFile) {
104+
return JS_EXTENSION.equals(virtualFile.getExtension())
105+
|| CSS_EXTENSION.equals(virtualFile.getExtension())
106+
|| HTML_EXTENSION.equals(virtualFile.getExtension())
107+
|| SUPPORTED_IMAGE_EXTENSIONS.contains(virtualFile.getExtension());
108+
}
109+
110+
/**
111+
* Constructs a result.
112+
*
113+
* @param virtualFile the virtual file being processed
114+
* @param paths an array of potential path segments to be checked
115+
* @param fullPath the full path of the virtual file as a mutable string builder
116+
* @param moduleName the name of the module associated with the file
117+
* @return the constructed result path
118+
*/
119+
private @NotNull String getResultPath(
120+
@NotNull final VirtualFile virtualFile,
121+
final String[] paths,
122+
final StringBuilder fullPath,
123+
final String moduleName
124+
) {
125+
final int endIndex = getIndexOf(paths, fullPath, paths[++index]);
126+
final int offset = paths[index].length();
127+
128+
fullPath.replace(0, endIndex + offset, "");
129+
130+
return PHTML_EXTENSION.equals(virtualFile.getExtension())
131+
? moduleName + SEPARATOR + fullPath
132+
: moduleName + "/" + fullPath.substring(0, fullPath.lastIndexOf("."));
133+
}
134+
121135
/**
122136
* Get index where web|template path starts in the fullPath.
123137
*

src/main/java/com/magento/idea/magento2plugin/inspections/php/fix/PhpModuleNameQuickFix.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import com.intellij.codeInspection.LocalQuickFix;
99
import com.intellij.codeInspection.ProblemDescriptor;
10+
import com.intellij.openapi.application.ApplicationManager;
1011
import com.intellij.openapi.command.WriteCommandAction;
1112
import com.intellij.openapi.project.Project;
1213
import com.jetbrains.php.lang.psi.elements.StringLiteralExpression;
@@ -38,7 +39,9 @@ public void applyFix(
3839
) {
3940
final StringLiteralExpression expression =
4041
(StringLiteralExpression) descriptor.getPsiElement();
41-
applyFix(expression);
42+
if (ApplicationManager.getApplication().isDispatchThread()) {
43+
applyFix(expression);
44+
}
4245
}
4346

4447
private void applyFix(final StringLiteralExpression expression) {

src/main/java/com/magento/idea/magento2plugin/project/RegenerateUrnMapListener.java

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import com.intellij.notification.NotificationGroupManager;
1111
import com.intellij.notification.NotificationType;
1212
import com.intellij.openapi.application.ApplicationManager;
13+
import com.intellij.openapi.project.DumbService;
1314
import com.intellij.openapi.project.Project;
1415
import com.intellij.openapi.vfs.VirtualFile;
1516
import com.intellij.psi.PsiDirectory;
@@ -46,17 +47,31 @@ public RegenerateUrnMapListener(final @NotNull Project project) {
4647
* @param event MouseEvent
4748
*/
4849
@Override
50+
@SuppressWarnings("PMD.UseNotifyAllInsteadOfNotify")
4951
public void mouseClicked(final MouseEvent event) {
50-
final ExternalResourceManager manager =
51-
ExternalResourceManager.getInstance();
52-
final PsiManager psiManager = PsiManager.getInstance(project);
53-
final MagentoComponentManager componentManager =
54-
MagentoComponentManager.getInstance(project);
52+
if (DumbService.getInstance(project).isDumb()) {
53+
NotificationGroupManager.getInstance()
54+
.getNotificationGroup("Magento Notifications")
55+
.createNotification(
56+
"URN map generation unavailable",
57+
"Indexing is in progress."
58+
+ " Please wait for it to complete"
59+
+ " before running URN mapping generation.",
60+
NotificationType.WARNING
61+
)
62+
.notify(project);
63+
return;
64+
}
5565

5666
ApplicationManager.getApplication().runWriteAction(
5767
new Runnable() {
5868
@Override
5969
public void run() {
70+
final PsiManager psiManager = PsiManager.getInstance(project);
71+
final MagentoComponentManager componentManager =
72+
MagentoComponentManager.getInstance(project);
73+
final ExternalResourceManager manager =
74+
ExternalResourceManager.getInstance();
6075
final Collection<VirtualFile> xsdFiles
6176
= FilenameIndex.getAllFilesByExt(project, "xsd");
6277
final Collection<MagentoComponent> components

src/main/resources/META-INF/plugin.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,8 @@
151151

152152
<action id="CopyMagentoPath"
153153
class="com.magento.idea.magento2plugin.actions.CopyMagentoPath"
154-
text="Magento Path"
155-
description="Copies Magento's path of file depending on file type">
154+
text="Magento Asset"
155+
description="Copies Magento-formatted file asset path depending on file type">
156156
<add-to-group group-id="CopyFileReference" anchor="last"/>
157157
</action>
158158
<group id="UctReindexMenu">

0 commit comments

Comments
 (0)