mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
resource roots: show 'out of source' icon for java files under resource roots
This commit is contained in:
+2
-1
@@ -30,6 +30,7 @@ import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.*;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jps.model.java.JavaModuleSourceRootTypes;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
@@ -90,7 +91,7 @@ public class ClassesTreeStructureProvider implements SelectableTreeStructureProv
|
||||
|
||||
private boolean fileInRoots(VirtualFile file) {
|
||||
final ProjectFileIndex index = ProjectRootManager.getInstance(myProject).getFileIndex();
|
||||
return file != null && (index.isInSourceContent(file) || index.isInLibraryClasses(file) || index.isInLibrarySource(file));
|
||||
return file != null && (index.isUnderSourceRootOfType(file, JavaModuleSourceRootTypes.SOURCES) || index.isInLibraryClasses(file) || index.isInLibrarySource(file));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.fileTypes.StdFileTypes;
|
||||
import com.intellij.openapi.fileTypes.FileTypeManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jps.model.java.JavaModuleSourceRootTypes;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
@@ -30,9 +31,10 @@ public class FileIndexUtil {
|
||||
|
||||
public static boolean isJavaSourceFile(@NotNull Project project, @NotNull VirtualFile file) {
|
||||
FileTypeManager fileTypeManager = FileTypeManager.getInstance();
|
||||
if (file.isDirectory()) return false;
|
||||
if (file.getFileType() != StdFileTypes.JAVA) return false;
|
||||
if (fileTypeManager.isFileIgnored(file)) return false;
|
||||
return ProjectRootManager.getInstance(project).getFileIndex().isInSource(file);
|
||||
if (file.isDirectory() || file.getFileType() != StdFileTypes.JAVA || fileTypeManager.isFileIgnored(file)) {
|
||||
return false;
|
||||
}
|
||||
ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex();
|
||||
return fileIndex.isUnderSourceRootOfType(file, JavaModuleSourceRootTypes.SOURCES) || fileIndex.isInLibrarySource(file);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user