public class ProjectFileIndexImpl extends java.lang.Object implements ProjectFileIndex
ProjectFileIndex.SERVICE| Constructor and Description |
|---|
ProjectFileIndexImpl(Project project) |
ProjectFileIndexImpl(Project project,
DirectoryIndex index,
FileTypeRegistry fileTypeManager)
Deprecated.
Do not pass DirectoryIndex explicitly.
|
| Modifier and Type | Method and Description |
|---|---|
VirtualFile |
getClassRootForFile(VirtualFile file)
Returns a classpath entry to which the specified file or directory belongs.
|
static VirtualFile |
getClassRootForFile(VirtualFile file,
DirectoryInfo info) |
static VirtualFile |
getContentRootForFile(DirectoryInfo info,
VirtualFile file,
boolean honorExclusion) |
VirtualFile |
getContentRootForFile(VirtualFile file)
Returns the module content root to which the specified file or directory belongs or null if the file does not belong to content of any module.
|
VirtualFile |
getContentRootForFile(VirtualFile file,
boolean honorExclusion)
Returns the module content root to which the specified file or directory belongs or null if the file does not belong to content of any module.
|
DirectoryInfo |
getInfoForFileOrDirectory(VirtualFile file) |
Module |
getModuleForFile(VirtualFile file)
Returns module to which content the specified file belongs or null if the file does not belong to content of any module.
|
Module |
getModuleForFile(VirtualFile file,
boolean honorExclusion)
Returns module to which content the specified file belongs or null if the file does not belong to content of any module.
|
java.util.List<OrderEntry> |
getOrderEntriesForFile(VirtualFile file)
Returns the order entries which contain the specified file (either in CLASSES or SOURCES).
|
java.lang.String |
getPackageNameByDirectory(VirtualFile dir)
Returns the name of the package corresponding to the specified directory.
|
SourceFolder |
getSourceFolder(VirtualFile fileOrDir) |
VirtualFile |
getSourceRootForFile(VirtualFile file)
Returns the module source root or library source root to which the specified file or directory belongs.
|
static VirtualFile |
getSourceRootForFile(VirtualFile file,
DirectoryInfo info) |
boolean |
isContentSourceFile(VirtualFile file) |
boolean |
isExcluded(VirtualFile file)
Checks if the specified file or directory is located under project roots but the file itself or one of its parent directories is
either excluded from the project or ignored by
FileTypeRegistry.isFileIgnored(VirtualFile)). |
static boolean |
isFileInContent(VirtualFile fileOrDir,
DirectoryInfo info) |
boolean |
isIgnored(VirtualFile file) |
boolean |
isInContent(VirtualFile fileOrDir)
Returns
true if fileOrDir is a file or directory under a content root of this project or module and not excluded or
ignored. |
protected boolean |
isInContent(VirtualFile file,
DirectoryInfo info) |
boolean |
isInLibrary(VirtualFile fileOrDir) |
boolean |
isInLibraryClasses(VirtualFile fileOrDir)
Returns true if
fileOrDir belongs to classes of some library which is included into dependencies of some module. |
boolean |
isInLibrarySource(VirtualFile fileOrDir)
Returns true if
fileOrDir is a file or directory from sources of some library which is included into dependencies
of some module. |
boolean |
isInSource(VirtualFile fileOrDir)
Returns true if
fileOrDir is a file or directory from production/test sources of some module or sources of some library which is included into dependencies
of some module. |
boolean |
isInSourceContent(VirtualFile fileOrDir)
Returns
true if fileOrDir is a file or directory located under a sources, tests or resources root and not excluded or ignored. |
boolean |
isInTestSourceContent(VirtualFile fileOrDir)
Returns true if
fileOrDir is a file or directory located under a test sources or resources root and not excluded or ignored. |
boolean |
isLibraryClassFile(VirtualFile file)
Returns true if
file is a file which belongs to the classes (not sources) of some library which is included into dependencies
of some module. |
protected boolean |
isScopeDisposed() |
boolean |
isUnderIgnored(VirtualFile file)
Checks if the specified file or directory is located under project roots but the file itself or one of its parent directories is ignored
by
FileTypeRegistry.isFileIgnored(VirtualFile)). |
boolean |
isUnderSourceRootOfType(VirtualFile fileOrDir,
java.util.Set<? extends JpsModuleSourceRootType<?>> rootTypes)
Returns
true if fileOrDir is a file or directory located under a source root of type from rootTypes set and not excluded or ignored |
boolean |
iterateContent(ContentIterator processor)
Processes all files and directories under content roots skipping excluded and ignored files and directories.
|
boolean |
iterateContent(ContentIterator processor,
VirtualFileFilter filter)
Same as
FileIndex.iterateContent(ContentIterator) but allows to pass filter to
provide filtering in condition for directories. |
boolean |
iterateContentUnderDirectory(VirtualFile dir,
ContentIterator processor)
Processes all files and directories in the content under directory
dir (including the directory itself) skipping excluded
and ignored files and directories. |
boolean |
iterateContentUnderDirectory(VirtualFile dir,
ContentIterator processor,
VirtualFileFilter customFilter)
Same as
FileIndex.iterateContentUnderDirectory(VirtualFile, ContentIterator) but allows to pass additional customFilter to
the iterator, in case you need to skip some file system branches using your own logic. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetInstanceisContentSourceFile, iterateContent, iterateContentUnderDirectory, iterateContentUnderDirectorypublic ProjectFileIndexImpl(Project project)
@Deprecated public ProjectFileIndexImpl(Project project, DirectoryIndex index, FileTypeRegistry fileTypeManager)
public boolean iterateContent(ContentIterator processor, VirtualFileFilter filter)
FileIndexFileIndex.iterateContent(ContentIterator) but allows to pass filter to
provide filtering in condition for directories.
If filter returns false on a directory, the directory won't be processed, but iteration will go on.
null filter means that all directories should be processed.
iterateContent in interface FileIndexContentIterator.processFile(VirtualFile) returned false)public boolean isExcluded(VirtualFile file)
ProjectFileIndexFileTypeRegistry.isFileIgnored(VirtualFile)).isExcluded in interface ProjectFileIndexfile is excluded or ignored, false otherwise.public boolean isUnderIgnored(VirtualFile file)
ProjectFileIndexFileTypeRegistry.isFileIgnored(VirtualFile)).isUnderIgnored in interface ProjectFileIndexfile is ignored, false otherwise.public Module getModuleForFile(VirtualFile file)
ProjectFileIndexgetModuleForFile in interface ProjectFileIndexpublic Module getModuleForFile(VirtualFile file, boolean honorExclusion)
ProjectFileIndexgetModuleForFile in interface ProjectFileIndexhonorExclusion - if false the containing module will be returned even if the file is located under a folder marked as excludedpublic java.util.List<OrderEntry> getOrderEntriesForFile(VirtualFile file)
ProjectFileIndexgetOrderEntriesForFile in interface ProjectFileIndexpublic VirtualFile getClassRootForFile(VirtualFile file)
ProjectFileIndexgetClassRootForFile in interface ProjectFileIndexpublic static VirtualFile getClassRootForFile(VirtualFile file, DirectoryInfo info)
public VirtualFile getSourceRootForFile(VirtualFile file)
ProjectFileIndexgetSourceRootForFile in interface ProjectFileIndexpublic static VirtualFile getSourceRootForFile(VirtualFile file, DirectoryInfo info)
public VirtualFile getContentRootForFile(VirtualFile file)
ProjectFileIndexgetContentRootForFile in interface ProjectFileIndexpublic VirtualFile getContentRootForFile(VirtualFile file, boolean honorExclusion)
ProjectFileIndexgetContentRootForFile in interface ProjectFileIndexhonorExclusion - if false the containing content root will be returned even if the file is located under a folder marked as excludedpublic static VirtualFile getContentRootForFile(DirectoryInfo info, VirtualFile file, boolean honorExclusion)
public java.lang.String getPackageNameByDirectory(VirtualFile dir)
ProjectFileIndexgetPackageNameByDirectory in interface ProjectFileIndexpublic boolean isLibraryClassFile(VirtualFile file)
ProjectFileIndexfile is a file which belongs to the classes (not sources) of some library which is included into dependencies
of some module.isLibraryClassFile in interface ProjectFileIndexpublic boolean isInSource(VirtualFile fileOrDir)
ProjectFileIndexfileOrDir is a file or directory from production/test sources of some module or sources of some library which is included into dependencies
of some module.isInSource in interface ProjectFileIndexpublic boolean isInLibraryClasses(VirtualFile fileOrDir)
ProjectFileIndexfileOrDir belongs to classes of some library which is included into dependencies of some module.isInLibraryClasses in interface ProjectFileIndexpublic boolean isInLibrarySource(VirtualFile fileOrDir)
ProjectFileIndexfileOrDir is a file or directory from sources of some library which is included into dependencies
of some module.isInLibrarySource in interface ProjectFileIndexpublic boolean isInLibrary(VirtualFile fileOrDir)
isInLibrary in interface ProjectFileIndexpublic boolean isIgnored(VirtualFile file)
isIgnored in interface ProjectFileIndexpublic boolean isInContent(VirtualFile fileOrDir)
FileIndextrue if fileOrDir is a file or directory under a content root of this project or module and not excluded or
ignored.isInContent in interface FileIndexpublic static boolean isFileInContent(VirtualFile fileOrDir, DirectoryInfo info)
public boolean isInSourceContent(VirtualFile fileOrDir)
FileIndextrue if fileOrDir is a file or directory located under a sources, tests or resources root and not excluded or ignored.isInSourceContent in interface FileIndexpublic boolean isInTestSourceContent(VirtualFile fileOrDir)
FileIndexfileOrDir is a file or directory located under a test sources or resources root and not excluded or ignored.
Use this method when you really need to check whether the file is under test roots according to project configuration.
If you want to determine whether file should be considered as test (e.g. for implementing SearchScope)
you'd better use TestSourcesFilter.isTestSources(VirtualFile, Project) instead
which includes FileIndex.isInTestSourceContent(VirtualFile) invocation.
isInTestSourceContent in interface FileIndexTestSourcesFilter.isTestSources(VirtualFile, Project)public boolean isUnderSourceRootOfType(VirtualFile fileOrDir, java.util.Set<? extends JpsModuleSourceRootType<?>> rootTypes)
FileIndextrue if fileOrDir is a file or directory located under a source root of type from rootTypes set and not excluded or ignoredisUnderSourceRootOfType in interface FileIndexpublic SourceFolder getSourceFolder(VirtualFile fileOrDir)
getSourceFolder in interface ProjectFileIndexprotected boolean isScopeDisposed()
public boolean iterateContent(ContentIterator processor)
FileIndexiterateContent in interface FileIndexContentIterator.processFile(VirtualFile) returned false)public boolean iterateContentUnderDirectory(VirtualFile dir, ContentIterator processor, VirtualFileFilter customFilter)
FileIndexFileIndex.iterateContentUnderDirectory(VirtualFile, ContentIterator) but allows to pass additional customFilter to
the iterator, in case you need to skip some file system branches using your own logic. If customFilter returns false on
a directory, it won't be processed, but iteration will go on.
null filter means that all directories should be processed.
iterateContentUnderDirectory in interface FileIndexpublic boolean iterateContentUnderDirectory(VirtualFile dir, ContentIterator processor)
FileIndexdir (including the directory itself) skipping excluded
and ignored files and directories. Does nothing if dir is not in the content.iterateContentUnderDirectory in interface FileIndexContentIterator.processFile(VirtualFile) returned false)public DirectoryInfo getInfoForFileOrDirectory(VirtualFile file)
public boolean isContentSourceFile(VirtualFile file)
isContentSourceFile in interface FileIndexprotected boolean isInContent(VirtualFile file, DirectoryInfo info)