void () { ApplicationManager.getApplication().runWriteAction(() -> { PsiClass psiClass = myJavaFacade.findClass("p.A"); assertEquals("p.A", psiClass.getQualifiedName()); PsiFile psiFile = myPsiManager.findFile(myPackDir.findChild("A.java")); psiFile.getChildren(); assertEquals(psiFile, psiClass.getContainingFile()); VirtualFile file = psiFile.getVirtualFile(); assertEquals(myModule, ModuleUtilCore.findModuleForFile(file, myProject)); Module anotherModule = createModule("another"); PsiTestUtil.addSourceRoot(anotherModule, mySrcDir1); assertNotNull(ModuleUtilCore.findModuleForFile(file, myProject)); }); }