void () { ProjectRootManagerEx rootManager = (ProjectRootManagerEx)ProjectRootManager.getInstance(myProject); final VirtualFile root = rootManager.getContentRoots()[0]; final VirtualFile dir = root.findChild("aDir"); PsiTestUtil.addExcludedRoot(myModule, dir); ensureCachesAreUpToDate(); WriteCommandAction.writeCommandAction(getProject()).run(() -> { VirtualFile newFile = createChildData(dir, "New.java"); setFileText(newFile, "class A{ Exception e;} //todo"); }); PsiDocumentManager.getInstance(myProject).commitAllDocuments(); ensureCachesAreUpToDate(); PsiTestUtil.removeExcludedRoot(myModule, dir); PsiClass exceptionClass = myJavaFacade.findClass("java.lang.Exception", GlobalSearchScope.allScope(getProject())); assertNotNull(exceptionClass); checkUsages(exceptionClass, new String[]{"1.java", "2.java", "New.java"}); checkTodos(new String[]{"2.java", "New.java"}); }