mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
EA-109160 - assert: StubProcessingHelperBase.handleNonPsiStubs
accept that some view providers may be different than during indexing and use JavaSourceFilterScope to access Java stubs to avoid querying those view providers at all
This commit is contained in:
@@ -71,6 +71,7 @@ import com.intellij.util.indexing.*
|
||||
import com.intellij.util.indexing.impl.MapIndexStorage
|
||||
import com.intellij.util.indexing.impl.MapReduceIndex
|
||||
import com.intellij.util.io.*
|
||||
import com.siyeh.ig.JavaOverridingMethodUtil
|
||||
import groovy.transform.CompileStatic
|
||||
import org.jetbrains.annotations.NotNull
|
||||
|
||||
@@ -797,4 +798,15 @@ class IndexTest extends JavaCodeInsightFixtureTestCase {
|
||||
assert files?.length == 1
|
||||
}).assertTiming()
|
||||
}
|
||||
|
||||
void "test class file in src content isn't returned from index"() {
|
||||
def runnable = JavaPsiFacade.getInstance(project).findClass(Runnable.name, GlobalSearchScope.allScope(project))
|
||||
def thread = JavaPsiFacade.getInstance(project).findClass(Thread.name, GlobalSearchScope.allScope(project))
|
||||
def srcRoot = myFixture.tempDirFixture.getFile("")
|
||||
WriteCommandAction.runWriteCommandAction(project) { VfsUtil.copy(this, thread.containingFile.virtualFile, srcRoot) }
|
||||
|
||||
def projectScope = GlobalSearchScope.projectScope(project)
|
||||
assert !JavaOverridingMethodUtil.getOverridingMethodsIfCheapEnough(runnable.methods[0], projectScope, { true }).findFirst().present
|
||||
assert StubIndex.instance.getElements(JavaStubIndexKeys.METHODS, 'run', project, projectScope, PsiMethod).empty
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.intellij.psi.stubs;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiBinaryFile;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.PsiManager;
|
||||
@@ -107,6 +108,13 @@ public abstract class StubProcessingHelperBase {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (psiFile instanceof PsiBinaryFile) {
|
||||
// a file can be indexed as containing stubs,
|
||||
// but then in a specific project FileViewProviderFactory can decide not to create stub-aware PSI
|
||||
// because the file isn't in expected location
|
||||
return true;
|
||||
}
|
||||
|
||||
ObjectStubTree objectStubTree = StubTreeLoader.getInstance().readFromVFile(psiFile.getProject(), file);
|
||||
if (objectStubTree == null) {
|
||||
LOG.error("Stub index points to a file without indexed stubs: " + psiFile.getFileType());
|
||||
|
||||
+2
-1
@@ -19,6 +19,7 @@ import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.java.stubs.index.JavaStubIndexKeys;
|
||||
import com.intellij.psi.impl.search.JavaSourceFilterScope;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.search.GlobalSearchScopeUtil;
|
||||
import com.intellij.psi.search.SearchScope;
|
||||
@@ -60,7 +61,7 @@ public class JavaOverridingMethodUtil {
|
||||
if (!StubIndex.getInstance().processElements(JavaStubIndexKeys.METHODS,
|
||||
name,
|
||||
project,
|
||||
effectiveSearchScope,
|
||||
new JavaSourceFilterScope(effectiveSearchScope),
|
||||
PsiMethod.class,
|
||||
m -> {
|
||||
ProgressManager.checkCanceled();
|
||||
|
||||
Reference in New Issue
Block a user