diff --git a/CHANGELOG.md b/CHANGELOG.md index 1e476da1d..36edcc350 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0). - "Copy Path/Reference" does not show the preview value [#2497](https://github.com/magento/magento2-phpstorm-plugin/pull/2497) - Must not start write action from within read action in the other thread [#2498](https://github.com/magento/magento2-phpstorm-plugin/pull/2498) - URN map generation during indexing [#2499](https://github.com/magento/magento2-phpstorm-plugin/pull/2499) +- Cannot invoke "com.intellij.psi.PsiDirectory.getName() [#2500](https://github.com/magento/magento2-phpstorm-plugin/pull/2500) ## 2025.0.0 diff --git a/src/main/java/com/magento/idea/magento2plugin/actions/generation/generator/OverrideTemplateInThemeGenerator.java b/src/main/java/com/magento/idea/magento2plugin/actions/generation/generator/OverrideTemplateInThemeGenerator.java index 6520bc601..82d41be6d 100644 --- a/src/main/java/com/magento/idea/magento2plugin/actions/generation/generator/OverrideTemplateInThemeGenerator.java +++ b/src/main/java/com/magento/idea/magento2plugin/actions/generation/generator/OverrideTemplateInThemeGenerator.java @@ -19,9 +19,9 @@ import com.magento.idea.magento2plugin.util.magento.GetComponentNameByDirectoryUtil; import com.magento.idea.magento2plugin.util.magento.GetMagentoModuleUtil; import java.util.List; +import java.util.Objects; public class OverrideTemplateInThemeGenerator extends OverrideInThemeGenerator { - /** * OverrideTemplateInThemeGenerator constructor. * @@ -41,10 +41,13 @@ public void execute(final PsiFile baseFile, final String themeName) { final GetMagentoModuleUtil.MagentoModuleData moduleData = GetMagentoModuleUtil.getByContext(baseFile.getContainingDirectory(), project); - List pathComponents; + List pathComponents; //NOPMD if (moduleData == null) { - if (baseFile.getVirtualFile().getExtension().equals(OverridableFileType.JS.getType())) { + if (Objects.equals( + baseFile.getVirtualFile().getExtension(), + OverridableFileType.JS.getType()) + ) { pathComponents = getLibPathComponets(baseFile); } else { return; @@ -75,12 +78,21 @@ public void execute(final PsiFile baseFile, final String themeName) { directory = getTargetDirectory(directory, pathComponents); if (directory.findFile(baseFile.getName()) != null) { - JBPopupFactory.getInstance() - .createMessage( - validatorBundle.message("validator.file.alreadyExists", baseFile.getName()) - ) - .showCenteredInCurrentWindow(project); - directory.findFile(baseFile.getName()).navigate(true); + final PsiDirectory finalDirectory1 = directory; + ApplicationManager.getApplication().invokeLater(() -> { + JBPopupFactory.getInstance() + .createMessage( + validatorBundle.message( + "validator.file.alreadyExists", + baseFile.getName() + ) + ).showCenteredInCurrentWindow(project); + ApplicationManager.getApplication().invokeLater(() -> { + Objects.requireNonNull( + finalDirectory1.findFile(baseFile.getName()) + ).navigate(true); + }); + }); return; }