mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
use stubs when resolving in dumb mode
This commit is contained in:
@@ -55,22 +55,11 @@ public class StubTreeLoaderImpl extends StubTreeLoader {
|
||||
try {
|
||||
final FileContent fc = new FileContentImpl(vFile, vFile.contentsToByteArray());
|
||||
fc.putUserData(IndexingDataKeys.PROJECT, project);
|
||||
if (psiFile != null) {
|
||||
fc.putUserData(IndexingDataKeys.PSI_FILE, psiFile);
|
||||
if (!vFile.getFileType().isBinary()) {
|
||||
fc.putUserData(IndexingDataKeys.FILE_TEXT_CONTENT_KEY, psiFile.getViewProvider().getContents());
|
||||
}
|
||||
psiFile.putUserData(PsiFileImpl.BUILDING_STUB, true);
|
||||
}
|
||||
Stub element;
|
||||
try {
|
||||
element = StubTreeBuilder.buildStubTree(fc);
|
||||
}
|
||||
finally {
|
||||
if (psiFile != null) {
|
||||
psiFile.putUserData(PsiFileImpl.BUILDING_STUB, null);
|
||||
}
|
||||
if (psiFile != null && !vFile.getFileType().isBinary()) {
|
||||
fc.putUserData(IndexingDataKeys.FILE_TEXT_CONTENT_KEY, psiFile.getViewProvider().getContents());
|
||||
// but don't reuse psiFile itself to avoid loading its contents. If we load AST, the stub will be thrown out anyway.
|
||||
}
|
||||
Stub element = StubTreeBuilder.buildStubTree(fc);
|
||||
if (element instanceof PsiFileStub) {
|
||||
StubTree tree = new StubTree((PsiFileStub)element);
|
||||
tree.setDebugInfo("created from file content");
|
||||
|
||||
@@ -66,6 +66,7 @@ class GroovyStubsTest extends LightCodeInsightFixtureTestCase {
|
||||
DumbServiceImpl.getInstance(project).setDumb(true);
|
||||
try {
|
||||
assertOneElement(((GroovyFile) fooFile).classes);
|
||||
assertFalse(fooFile.isContentsLoaded());
|
||||
}
|
||||
finally {
|
||||
DumbServiceImpl.getInstance(project).setDumb(false);
|
||||
|
||||
@@ -396,6 +396,7 @@ public class PyStubsTest extends PyTestCase {
|
||||
DumbServiceImpl.getInstance(project).setDumb(true);
|
||||
try {
|
||||
assertEquals(1, ((PyFile) fooPyFile).getTopLevelClasses().size());
|
||||
assertFalse(fooPyFile.isContentsLoaded());
|
||||
}
|
||||
finally {
|
||||
DumbServiceImpl.getInstance(project).setDumb(false);
|
||||
|
||||
Reference in New Issue
Block a user