void () { final PsiJavaFile file = (PsiJavaFile)myFixture.addFileToProject("Foo.java", "class Foo {}"); final PsiIdentifier nameIdentifier = file.getClasses()[0].getNameIdentifier(); final Project project = getProject(); final VirtualFile virtualFile = file.getVirtualFile(); assertTrue(findWordInDumbMode("Foo", virtualFile, false)); assertFalse(findWordInDumbMode("Bar", virtualFile, false)); DumbModeTestUtils.runInDumbModeSynchronously(project, () -> { assertTrue(findWordInDumbMode("Foo", virtualFile, true)); assertFalse(findWordInDumbMode("Bar", virtualFile, true)); WriteCommandAction.runWriteCommandAction(project, (Computable<PsiElement>)() -> nameIdentifier.replace( JavaPsiFacade.getElementFactory(project).createIdentifier("Bar"))); assertTrue(FileDocumentManager.getInstance().isDocumentUnsaved(PsiDocumentManager.getInstance(project).getDocument(file))); assertTrue(findWordInDumbMode("Bar", virtualFile, true)); assertFalse(findWordInDumbMode("Foo", virtualFile, true)); }); assertTrue(findWordInDumbMode("Bar", virtualFile, false)); assertFalse(findWordInDumbMode("Foo", virtualFile, false)); }