void () { VirtualFile vFile = myFixture.getTempDirFixture().createFile("foo.py"); final Project project = myFixture.getProject(); PsiFileImpl fooPyFile = (PsiFileImpl)PsiManager.getInstance(project).findFile(vFile); assertNotNull(fooPyFile); final Document fooDocument = fooPyFile.getViewProvider().getDocument(); assertNotNull(fooDocument); final Collection<PyClass> classes = PyClassNameIndex.find("Foo123", project, GlobalSearchScope.allScope(project)); assertEquals(0, classes.size()); WriteCommandAction.writeCommandAction(project, fooPyFile).run(() -> fooDocument.setText("class Foo123: pass")); final PsiDocumentManager documentManager = PsiDocumentManager.getInstance(project); documentManager.commitDocument(fooDocument); documentManager.performForCommittedDocument(fooDocument, () -> { fooPyFile.setTreeElementPointer(null); //classes = PyClassNameIndex.find("Foo", project, GlobalSearchScope.allScope(project)); //fooPyFile.unloadContent(); DumbModeTestUtils.runInDumbModeSynchronously(project, () -> { assertEquals(1, ((PyFile)fooPyFile).getTopLevelClasses().size()); assertFalse(fooPyFile.isContentsLoaded()); }); final Collection<PyClass> committedClasses = PyClassNameIndex.find("Foo123", project, GlobalSearchScope.allScope(project)); assertEquals(1, committedClasses.size()); }); }