Skip to content

Commit

Permalink
Avoid invalidated objects when searching for Java references (asciido…
Browse files Browse the repository at this point in the history
  • Loading branch information
ahus1 committed Mar 24, 2024
1 parent d4544ea commit 95247c3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ This document provides a high-level view of the changes introduced by release.
- Calculate tree view eagerly in the background to unblock EDT (#1579)
- Prevent decoder exception when filename contains a percentage sind in IntelliJ 2024.1 EAP (#1580)
- Avoid NPE when searching for Java references (#1582)
- Avoid invalidated objects when searching for Java references (#1583)

=== 0.41.10

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.intellij.psi.PsiClass;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiInvalidElementAccessException;
import com.intellij.psi.PsiPackage;
import com.intellij.psi.PsiReference;
import com.intellij.psi.impl.cache.CacheManager;
Expand Down Expand Up @@ -104,13 +105,16 @@ private void search(@NotNull Processor<? super PsiReference> consumer, PsiElemen
if (text != null) {
LowLevelSearchUtil.processTexts(text, 0, text.length(), searcher, index -> {
myDumbService.runReadActionInSmartMode(() -> {
PsiReference referenceAt = psiFile.findReferenceAt(index);
if (referenceAt instanceof PsiMultiReference) {
for (PsiReference reference : ((PsiMultiReference) referenceAt).getReferences()) {
checkReference(consumer, element, reference);
try {
PsiReference referenceAt = psiFile.findReferenceAt(index);
if (referenceAt instanceof PsiMultiReference) {
for (PsiReference reference : ((PsiMultiReference) referenceAt).getReferences()) {
checkReference(consumer, element, reference);
}
}
checkReference(consumer, element, referenceAt);
} catch (PsiInvalidElementAccessException ignored) {
}
checkReference(consumer, element, referenceAt);
});
return true;
});
Expand Down

0 comments on commit 95247c3

Please sign in to comment.