mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
ReferenceSearch: fix non-physical LocalSearchScope case
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
package com.intellij.psi.search;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
@@ -148,9 +149,25 @@ public class LocalSearchScope extends SearchScope {
|
||||
if (scope2 instanceof LocalSearchScope) {
|
||||
return intersectWith((LocalSearchScope)scope2);
|
||||
}
|
||||
LocalSearchScope nonPhysicalScope = tryIntersectNonPhysicalWith((GlobalSearchScope)scope2);
|
||||
if (nonPhysicalScope != null) return nonPhysicalScope;
|
||||
return ((GlobalSearchScope)scope2).intersectWith(this);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private LocalSearchScope tryIntersectNonPhysicalWith(@NotNull GlobalSearchScope scope) {
|
||||
Project project = scope.getProject();
|
||||
for (PsiElement element : myScope) {
|
||||
PsiFile containingFile = element.getContainingFile();
|
||||
if (containingFile == null) continue;
|
||||
if (containingFile.getViewProvider().isPhysical()) return null;
|
||||
if (project != null && project != containingFile.getProject()) {
|
||||
return EMPTY;
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static PsiElement intersectScopeElements(PsiElement element1, PsiElement element2) {
|
||||
if (PsiTreeUtil.isContextAncestor(element1, element2, false)) return element2;
|
||||
|
||||
Reference in New Issue
Block a user