com.intellij.openapi.roots
Interface ProjectFileIndex

All Superinterfaces:
FileIndex

public interface ProjectFileIndex
extends FileIndex

Provides information about files contained in a project.

See Also:
ProjectRootManager.getFileIndex()

Method Summary
 VirtualFile getClassRootForFile(VirtualFile file)
          Returns a classpath entry to which the specified file or directory belongs.
 VirtualFile getContentRootForFile(VirtualFile file)
          Returns the module content root to which the specified file or directory belongs.
 Module getModuleForFile(VirtualFile file)
          Returns module to which the specified file belongs.
 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.
 VirtualFile getSourceRootForFile(VirtualFile file)
          Returns the module source root or library source root to which the specified file or directory belongs.
 boolean isIgnored(VirtualFile file)
          Checks if the specified file or directory is ignored (either excluded by exclude roots or ignored by FileTypeManager.isFileIgnored(String)).
 boolean isInLibraryClasses(VirtualFile fileOrDir)
          Returns true if fileOrDir is a file or directory from library classes.
 boolean isInLibrarySource(VirtualFile fileOrDir)
          Returns true if fileOrDir is a file or directory from library source.
 boolean isInSource(VirtualFile fileOrDir)
          Returns true if fileOrDir is a file or directory from the content source or library sources.
 boolean isJavaSourceFile(VirtualFile file)
          Returns true if file is a Java source file which is treated as source (that is either project source or library source)
 boolean isLibraryClassFile(VirtualFile file)
          Returns true if file is a compiled class file which belongs to some library.
 
Methods inherited from interface com.intellij.openapi.roots.FileIndex
getDirectoriesByPackageName, isContentJavaSourceFile, isInContent, isInSourceContent, isInTestSourceContent, iterateContent, iterateContentUnderDirectory
 

Method Detail

getModuleForFile

@Nullable
Module getModuleForFile(VirtualFile file)
Returns module to which the specified file belongs.

Returns:
the module instance or null if the file does not belong to content of any module.

getOrderEntriesForFile

@NotNull
OrderEntry[] getOrderEntriesForFile(VirtualFile file)
Returns the order entries which contain the specified file (either in CLASSES or SOURCES).

Returns:
the array of order entries containing the file.

getClassRootForFile

@Nullable
VirtualFile getClassRootForFile(VirtualFile file)
Returns a classpath entry to which the specified file or directory belongs.

Parameters:
file - the file or directory for which the information is requested.
Returns:
the file for the classpath entry, or null if the file is not a compiled class file or directory belonging to a library.

getSourceRootForFile

@Nullable
VirtualFile getSourceRootForFile(VirtualFile file)
Returns the module source root or library source root to which the specified file or directory belongs.

Parameters:
file - the file or directory for which the information is requested.
Returns:
the file for the source root, or null if the file is not located under any of the source roots for the module.

getContentRootForFile

@Nullable
VirtualFile getContentRootForFile(VirtualFile file)
Returns the module content root to which the specified file or directory belongs.

Parameters:
file - the file or directory for which the information is requested.
Returns:
the file for the content root, or null if the file does not belong to this project.

getPackageNameByDirectory

@Nullable
java.lang.String getPackageNameByDirectory(VirtualFile dir)
Returns the name of the package corresponding to the specified directory.

Parameters:
dir - the directory for which the package name is requested.
Returns:
the package name, or null if the directory does not correspond to any package.

isJavaSourceFile

boolean isJavaSourceFile(VirtualFile file)
Returns true if file is a Java source file which is treated as source (that is either project source or library source)

Parameters:
file - the file to check.
Returns:
true if the file is a Java source file belonging to project or library sources, false otherwise.

isLibraryClassFile

boolean isLibraryClassFile(VirtualFile file)
Returns true if file is a compiled class file which belongs to some library.

Parameters:
file - the file to check.
Returns:
true if the file belongs to library classes, false otherwise.

isInSource

boolean isInSource(VirtualFile fileOrDir)
Returns true if fileOrDir is a file or directory from the content source or library sources.

Parameters:
fileOrDir - the file or directory to check.
Returns:
true if the file or directory belongs to project or library sources, false otherwise.

isInLibraryClasses

boolean isInLibraryClasses(VirtualFile fileOrDir)
Returns true if fileOrDir is a file or directory from library classes.

Parameters:
fileOrDir - the file or directory to check.
Returns:
true if the file belongs to library classes, false otherwise.

isInLibrarySource

boolean isInLibrarySource(VirtualFile fileOrDir)
Returns true if fileOrDir is a file or directory from library source.

Parameters:
fileOrDir - the file or directory to check.
Returns:
true if the file belongs to library sources, false otherwise.

isIgnored

boolean isIgnored(VirtualFile file)
Checks if the specified file or directory is ignored (either excluded by exclude roots or ignored by FileTypeManager.isFileIgnored(String)).

Parameters:
file - the file to check.
Returns:
true if file is ignored, false otherwise.