boolean (PsiFile file) { if (file == null || !file.isValid() || !(file instanceof PsiJavaFile)) return false; VirtualFile virtualFile = PsiUtilCore.getVirtualFile(file); if (virtualFile == null) return false; Module module = ModuleUtilCore.findModuleForFile(virtualFile, file.getProject()); if (module == null) return false; ModuleRootManager rootManager = ModuleRootManager.getInstance(module); ModuleFileIndex fileIndex = rootManager.getFileIndex(); if (!fileIndex.isInSourceContent(virtualFile)) return false; return getTestRoots(rootManager).findFirst().isPresent(); }