boolean (@NotNull Project project, @NotNull VirtualFile file) { FileTypeManager fileTypeManager = FileTypeManager.getInstance(); if (file.isDirectory() || !FileTypeRegistry.getInstance().isFileOfType(file, StdFileTypes.JAVA) || fileTypeManager.isFileIgnored(file)) { return false; } ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex(); return fileIndex.isUnderSourceRootOfType(file, JavaModuleSourceRootTypes.SOURCES) || fileIndex.isInLibrarySource(file); }