resource roots: show 'out of source' icon for java files under resource roots

This commit is contained in:
nik
2013-09-12 09:13:53 +04:00
parent 5c9daf7339
commit 64055b1760
2 changed files with 8 additions and 5 deletions
@@ -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);
}
}