Skip to content

Commit 7dd0901

Browse files
committed
1658: Fix null handling in file navigation and enhance readability.
Improved null safety by ensuring proper checks around file navigation logic. Refactored UI interaction and popup messaging to adhere to threading best practices, enhancing code clarity and preventing race conditions. Updated changelog to reflect the fixed issue.
1 parent 5b91b53 commit 7dd0901

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0).
1212
- "Copy Path/Reference" does not show the preview value [#2497](https://github.com/magento/magento2-phpstorm-plugin/pull/2497)
1313
- Must not start write action from within read action in the other thread [#2498](https://github.com/magento/magento2-phpstorm-plugin/pull/2498)
1414
- URN map generation during indexing [#2499](https://github.com/magento/magento2-phpstorm-plugin/pull/2499)
15+
- Cannot invoke "com.intellij.psi.PsiDirectory.getName() [#2500](https://github.com/magento/magento2-phpstorm-plugin/pull/2500)
1516

1617
## 2025.0.0
1718

src/main/java/com/magento/idea/magento2plugin/actions/generation/generator/OverrideTemplateInThemeGenerator.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,19 @@ public void execute(final PsiFile baseFile, final String themeName) {
7676
directory = getTargetDirectory(directory, pathComponents);
7777

7878
if (directory.findFile(baseFile.getName()) != null) {
79-
PsiDirectory finalDirectory1 = directory;
79+
final PsiDirectory finalDirectory1 = directory;
8080
ApplicationManager.getApplication().invokeLater(() -> {
8181
JBPopupFactory.getInstance()
82-
.createMessage(validatorBundle.message("validator.file.alreadyExists", baseFile.getName()))
83-
.showCenteredInCurrentWindow(project);
82+
.createMessage(
83+
validatorBundle.message(
84+
"validator.file.alreadyExists",
85+
baseFile.getName()
86+
)
87+
).showCenteredInCurrentWindow(project);
8488
ApplicationManager.getApplication().invokeLater(() -> {
85-
Objects.requireNonNull(finalDirectory1.findFile(baseFile.getName())).navigate(true);
89+
Objects.requireNonNull(
90+
finalDirectory1.findFile(baseFile.getName())
91+
).navigate(true);
8692
});
8793
});
8894
return;

0 commit comments

Comments
 (0)