com.intellij.openapi.roots
Interface FileIndex

All Known Subinterfaces:
ModuleFileIndex, ProjectFileIndex

public interface FileIndex

Provides information about files contained in a project or module.

See Also:
ProjectRootManager.getFileIndex(), ModuleRootManager.getFileIndex()

Method Summary
 VirtualFile[] getDirectoriesByPackageName(java.lang.String packageName, boolean includeLibrarySources)
          Returns all directories in content sources and libraries (and optionally library sources) corresponding to the given package name.
 boolean isContentJavaSourceFile(VirtualFile file)
          Returns true if file is a java source file which belongs to sources of the content.
 boolean isInContent(VirtualFile fileOrDir)
          Returns true if fileOrDir is a file or directory under a content root of this project or module.
 boolean isInSourceContent(VirtualFile fileOrDir)
          Returns true if fileOrDir is a file or directory from the content source.
 boolean isInTestSourceContent(VirtualFile fileOrDir)
          Returns true if fileOrDir is a file or directory from the test content source
 boolean iterateContent(ContentIterator iterator)
          Iterates all files and directories in the content.
 boolean iterateContentUnderDirectory(VirtualFile dir, ContentIterator iterator)
          Iterates all files and directories in the content under directory dir (including the directory itself).
 

Method Detail

iterateContent

boolean iterateContent(ContentIterator iterator)
Iterates all files and directories in the content.

Parameters:
iterator - the iterator receiving the files.
Returns:
false if files processing was stopped (ContentIterator.processFile(VirtualFile) returned false)

iterateContentUnderDirectory

boolean iterateContentUnderDirectory(VirtualFile dir,
                                     ContentIterator iterator)
Iterates all files and directories in the content under directory dir (including the directory itself). Does not iterate anything if dir is not in the content.

Parameters:
dir - the directory the contents of which is iterated.
iterator - the iterator receiving the files.
Returns:
false if files processing was stopped (ContentIterator.processFile(VirtualFile) returned false)

isInContent

boolean isInContent(VirtualFile fileOrDir)
Returns true if fileOrDir is a file or directory under a content root of this project or module.

Parameters:
fileOrDir - the file or directory to check.
Returns:
true if the file or directory belongs to a content root, false otherwise.

isContentJavaSourceFile

boolean isContentJavaSourceFile(VirtualFile file)
Returns true if file is a java source file which belongs to sources of the content. Note that sometimes a java file can belong to the content and be a source file but not belong to sources of the content. This happens if sources of some library are located under the content (so they belong to the project content but not as sources).

Parameters:
file - the file to check.
Returns:
true if the file is a Java source file in the content sources, false otherwise.

isInSourceContent

boolean isInSourceContent(VirtualFile fileOrDir)
Returns true if fileOrDir is a file or directory from the content source. (Returns true for both source and test source).

Parameters:
fileOrDir - the file or directory to check.
Returns:
true if the file or directory belongs to a source or test source root, false otherwise.

isInTestSourceContent

boolean isInTestSourceContent(VirtualFile fileOrDir)
Returns true if fileOrDir is a file or directory from the test content source

Parameters:
fileOrDir - the file or directory to check.
Returns:
true if the file or directory belongs to a test source root, false otherwise.

getDirectoriesByPackageName

VirtualFile[] getDirectoriesByPackageName(java.lang.String packageName,
                                          boolean includeLibrarySources)
Returns all directories in content sources and libraries (and optionally library sources) corresponding to the given package name.

Parameters:
packageName - the name of the package for which directories are requested.
includeLibrarySources - if true, directories under library sources are included in the returned list.
Returns:
the list of directories.