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