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, wait
getInstance
isContentSourceFile, iterateContent, iterateContentUnderDirectory, iterateContentUnderDirectory
public ProjectFileIndexImpl(Project project)
@Deprecated public ProjectFileIndexImpl(Project project, DirectoryIndex index, FileTypeRegistry fileTypeManager)
public boolean iterateContent(ContentIterator processor, VirtualFileFilter filter)
FileIndex
FileIndex.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 FileIndex
ContentIterator.processFile(VirtualFile)
returned false)public boolean isExcluded(VirtualFile file)
ProjectFileIndex
FileTypeRegistry.isFileIgnored(VirtualFile)
).isExcluded
in interface ProjectFileIndex
file
is excluded or ignored, false otherwise.public boolean isUnderIgnored(VirtualFile file)
ProjectFileIndex
FileTypeRegistry.isFileIgnored(VirtualFile)
).isUnderIgnored
in interface ProjectFileIndex
file
is ignored, false otherwise.public Module getModuleForFile(VirtualFile file)
ProjectFileIndex
getModuleForFile
in interface ProjectFileIndex
public Module getModuleForFile(VirtualFile file, boolean honorExclusion)
ProjectFileIndex
getModuleForFile
in interface ProjectFileIndex
honorExclusion
- 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)
ProjectFileIndex
getOrderEntriesForFile
in interface ProjectFileIndex
public VirtualFile getClassRootForFile(VirtualFile file)
ProjectFileIndex
getClassRootForFile
in interface ProjectFileIndex
public static VirtualFile getClassRootForFile(VirtualFile file, DirectoryInfo info)
public VirtualFile getSourceRootForFile(VirtualFile file)
ProjectFileIndex
getSourceRootForFile
in interface ProjectFileIndex
public static VirtualFile getSourceRootForFile(VirtualFile file, DirectoryInfo info)
public VirtualFile getContentRootForFile(VirtualFile file)
ProjectFileIndex
getContentRootForFile
in interface ProjectFileIndex
public VirtualFile getContentRootForFile(VirtualFile file, boolean honorExclusion)
ProjectFileIndex
getContentRootForFile
in interface ProjectFileIndex
honorExclusion
- 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)
ProjectFileIndex
getPackageNameByDirectory
in interface ProjectFileIndex
public boolean isLibraryClassFile(VirtualFile file)
ProjectFileIndex
file
is a file which belongs to the classes (not sources) of some library which is included into dependencies
of some module.isLibraryClassFile
in interface ProjectFileIndex
public boolean isInSource(VirtualFile fileOrDir)
ProjectFileIndex
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.isInSource
in interface ProjectFileIndex
public boolean isInLibraryClasses(VirtualFile fileOrDir)
ProjectFileIndex
fileOrDir
belongs to classes of some library which is included into dependencies of some module.isInLibraryClasses
in interface ProjectFileIndex
public boolean isInLibrarySource(VirtualFile fileOrDir)
ProjectFileIndex
fileOrDir
is a file or directory from sources of some library which is included into dependencies
of some module.isInLibrarySource
in interface ProjectFileIndex
public boolean isInLibrary(VirtualFile fileOrDir)
isInLibrary
in interface ProjectFileIndex
public boolean isIgnored(VirtualFile file)
isIgnored
in interface ProjectFileIndex
public boolean isInContent(VirtualFile fileOrDir)
FileIndex
true
if fileOrDir
is a file or directory under a content root of this project or module and not excluded or
ignored.isInContent
in interface FileIndex
public static boolean isFileInContent(VirtualFile fileOrDir, DirectoryInfo info)
public boolean isInSourceContent(VirtualFile fileOrDir)
FileIndex
true
if fileOrDir
is a file or directory located under a sources, tests or resources root and not excluded or ignored.isInSourceContent
in interface FileIndex
public boolean isInTestSourceContent(VirtualFile fileOrDir)
FileIndex
fileOrDir
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 FileIndex
TestSourcesFilter.isTestSources(VirtualFile, Project)
public boolean isUnderSourceRootOfType(VirtualFile fileOrDir, java.util.Set<? extends JpsModuleSourceRootType<?>> rootTypes)
FileIndex
true
if fileOrDir
is a file or directory located under a source root of type from rootTypes
set and not excluded or ignoredisUnderSourceRootOfType
in interface FileIndex
public SourceFolder getSourceFolder(VirtualFile fileOrDir)
getSourceFolder
in interface ProjectFileIndex
protected boolean isScopeDisposed()
public boolean iterateContent(ContentIterator processor)
FileIndex
iterateContent
in interface FileIndex
ContentIterator.processFile(VirtualFile)
returned false)public boolean iterateContentUnderDirectory(VirtualFile dir, ContentIterator processor, VirtualFileFilter customFilter)
FileIndex
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. 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 FileIndex
public boolean iterateContentUnderDirectory(VirtualFile dir, ContentIterator processor)
FileIndex
dir
(including the directory itself) skipping excluded
and ignored files and directories. Does nothing if dir
is not in the content.iterateContentUnderDirectory
in interface FileIndex
ContentIterator.processFile(VirtualFile)
returned false)public DirectoryInfo getInfoForFileOrDirectory(VirtualFile file)
public boolean isContentSourceFile(VirtualFile file)
isContentSourceFile
in interface FileIndex
protected boolean isInContent(VirtualFile file, DirectoryInfo info)