void () { final VirtualFile root = ModuleRootManager.getInstance(myModule).getContentRoots()[0]; ensureCachesAreUpToDate(); WriteCommandAction.writeCommandAction(getProject()).run(() -> { VirtualFile newFile = createChildData(root, "New.java"); setFileText(newFile, "class A{ Exception e;} //todo"); }); PsiDocumentManager.getInstance(myProject).commitAllDocuments(); ensureCachesAreUpToDate(); VirtualFile[] sourceRoots = ModuleRootManager.getInstance(myModule).getSourceRoots(); LOG.assertTrue(sourceRoots.length == 1); PsiTestUtil.removeSourceRoot(myModule, sourceRoots[0]); PsiClass exceptionClass = myJavaFacade.findClass("java.lang.Exception", GlobalSearchScope.allScope(getProject())); assertNotNull(exceptionClass); // currently it actually finds usages by FQN due to Java PSI enabled for out-of-source java files // so the following check is disabled //checkUsages(exceptionClass, new String[]{}); checkTodos(new String[]{"2.java", "New.java"}); }