From ccaeba93b5b08c424f1a18a88e8abbf76cdd7a06 Mon Sep 17 00:00:00 2001 From: Daniel Espendiller Date: Mon, 9 Jun 2025 11:50:39 +0200 Subject: [PATCH] Fix read thread access of bundle files lookup rendering --- .../util/dict/SymfonyBundle.java | 20 ++++++++++------- .../dict/SymfonyBundleFileLookupElement.java | 22 +++++++++---------- 2 files changed, 23 insertions(+), 19 deletions(-) diff --git a/src/main/java/fr/adrienbrault/idea/symfony2plugin/util/dict/SymfonyBundle.java b/src/main/java/fr/adrienbrault/idea/symfony2plugin/util/dict/SymfonyBundle.java index dfcdaa97b..452343e34 100644 --- a/src/main/java/fr/adrienbrault/idea/symfony2plugin/util/dict/SymfonyBundle.java +++ b/src/main/java/fr/adrienbrault/idea/symfony2plugin/util/dict/SymfonyBundle.java @@ -16,6 +16,12 @@ public class SymfonyBundle { @NotNull final private PhpClass phpClass; + @NotNull + final private String phpClassName; + + @NotNull + private final String phpClassNameNamespaceName; + @NotNull public PhpClass getPhpClass() { return this.phpClass; @@ -28,11 +34,14 @@ public String getNamespaceName() { @NotNull public String getName() { - return this.phpClass.getName(); + return this.phpClassName; } public SymfonyBundle(@NotNull PhpClass phpClass) { this.phpClass = phpClass; + + this.phpClassName = this.phpClass.getName(); + this.phpClassNameNamespaceName = this.phpClass.getNamespaceName(); } @Nullable @@ -41,12 +50,7 @@ public PsiDirectory getDirectory() { return null; } - PsiDirectory bundleDirectory = this.phpClass.getContainingFile().getContainingDirectory(); - if(null == bundleDirectory) { - return null; - } - - return bundleDirectory; + return this.phpClass.getContainingFile().getContainingDirectory(); } @Nullable @@ -78,7 +82,7 @@ public String getRelativePath(@NotNull VirtualFile file) { } public boolean isInBundle(@NotNull PhpClass phpClass) { - return phpClass.getNamespaceName().startsWith(this.phpClass.getNamespaceName()); + return phpClass.getNamespaceName().startsWith(this.phpClassNameNamespaceName); } public boolean isInBundle(@NotNull PsiFile psiFile) { diff --git a/src/main/java/fr/adrienbrault/idea/symfony2plugin/util/dict/SymfonyBundleFileLookupElement.java b/src/main/java/fr/adrienbrault/idea/symfony2plugin/util/dict/SymfonyBundleFileLookupElement.java index 46c014e33..ae28ca94d 100644 --- a/src/main/java/fr/adrienbrault/idea/symfony2plugin/util/dict/SymfonyBundleFileLookupElement.java +++ b/src/main/java/fr/adrienbrault/idea/symfony2plugin/util/dict/SymfonyBundleFileLookupElement.java @@ -6,17 +6,21 @@ import com.intellij.codeInsight.lookup.LookupElementPresentation; import com.intellij.util.IconUtil; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * @author Daniel Espendiller */ public class SymfonyBundleFileLookupElement extends LookupElement { - + private final @NotNull String bundleName; private final BundleFile bundleFile; private InsertHandler insertHandler = null; + private final @Nullable String shortcutName; public SymfonyBundleFileLookupElement(BundleFile bundleFile) { this.bundleFile = bundleFile; + this.shortcutName = bundleFile.getShortcutPath(); + this.bundleName = bundleFile.getSymfonyBundle().getName(); } public SymfonyBundleFileLookupElement(BundleFile bundleFile, InsertHandler insertHandler) { @@ -27,23 +31,21 @@ public SymfonyBundleFileLookupElement(BundleFile bundleFile, InsertHandler