ReferenceSearch: fix non-physical LocalSearchScope case

This commit is contained in:
Gregory.Shrago
2013-08-08 23:39:26 +04:00
parent 18c94184d7
commit 8ae15b747c
@@ -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;