use stubs when resolving in dumb mode

This commit is contained in:
peter
2014-04-01 12:16:58 +02:00
parent 90163c5982
commit 18b1ccdea3
3 changed files with 6 additions and 15 deletions
@@ -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);