com.intellij.psi
Interface PsiDirectory

All Superinterfaces:
Iconable, Navigatable, NavigationItem, PsiElement, PsiFileSystemItem, PsiNamedElement, UserDataHolder

public interface PsiDirectory
extends PsiElement, PsiFileSystemItem, NavigationItem

Represents a file system directory and allows to access its contents.


Field Summary
static PsiDirectory[] EMPTY_ARRAY
          The empty array of PSI directories which can be reused to avoid unnecessary allocations.
 
Method Summary
 void checkCreateClass(java.lang.String name)
          Checks if it's possible to create a class with the specified name in the directory, and throws an exception if the creation is not possible.
 void checkCreateFile(java.lang.String name)
          Checks if it's possible to create a file with the specified name in the directory, and throws an exception if the creation is not possible.
 void checkCreateInterface(java.lang.String name)
          Checks if it's possible to create an interface with the specified name in the directory, and throws an exception if the creation is not possible.
 void checkCreateSubdirectory(java.lang.String name)
          Checks if it's possible to create a subdirectory with the specified name in the directory, and throws an exception if the creation is not possible.
 PsiClass createAnnotationType(java.lang.String name)
          Creates an annotation class with the specified name in the directory.
 PsiClass createClass(java.lang.String name)
          Creates a class with the specified name in the directory.
 PsiClass createEnum(java.lang.String name)
          Creates an enumeration class with the specified name in the directory.
 PsiFile createFile(java.lang.String name)
          Creates a file with the specified name in the directory.
 PsiClass createInterface(java.lang.String name)
          Creates an interface class with the specified name in the directory.
 PsiDirectory createSubdirectory(java.lang.String name)
          Creates a subdirectory with the specified name in the directory.
 PsiFile findFile(java.lang.String name)
          Finds a file with the specified name in this directory.
 PsiDirectory findSubdirectory(java.lang.String name)
          Finds the subdirectory of this directory with the specified name.
 PsiClass[] getClasses()
          Returns the list of Java classes contained in the directory.
 PsiFile[] getFiles()
          Returns the list of files in the directory.
 java.lang.String getName()
          Returns the name of the element.
 PsiPackage getPackage()
          Returns the package corresponding to the directory.
 PsiDirectory getParentDirectory()
          Returns the parent directory of the directory.
 PsiDirectory[] getSubdirectories()
          Returns the list of subdirectories of this directory.
 VirtualFile getVirtualFile()
          Returns the virtual file represented by the PSI directory.
 boolean isSourceRoot()
          Checks if the directory is a source root for the project to which it belongs.
 PsiElement setName(java.lang.String name)
          Renames the element.
 
Methods inherited from interface com.intellij.psi.PsiFileSystemItem
checkSetName
 
Methods inherited from interface com.intellij.navigation.NavigationItem
getFileStatus, getPresentation
 
Methods inherited from interface com.intellij.pom.Navigatable
canNavigate, canNavigateToSource, navigate
 

Field Detail

EMPTY_ARRAY

static final PsiDirectory[] EMPTY_ARRAY
The empty array of PSI directories which can be reused to avoid unnecessary allocations.

Method Detail

getVirtualFile

@NotNull
VirtualFile getVirtualFile()
Returns the virtual file represented by the PSI directory.

Returns:
the virtual file instance.

getName

java.lang.String getName()
Description copied from interface: PsiNamedElement
Returns the name of the element.

Specified by:
getName in interface NavigationItem
Specified by:
getName in interface PsiNamedElement
Returns:
the element name.

setName

@NotNull
PsiElement setName(java.lang.String name)
                   throws IncorrectOperationException
Description copied from interface: PsiNamedElement
Renames the element.

Specified by:
setName in interface PsiNamedElement
Parameters:
name - the new element name.
Returns:
the element corresponding to this element after the rename (either this or a different element if the rename caused the element to be replaced).
Throws:
IncorrectOperationException - if the modification is not supported or not possible for some reason.

getPackage

@Nullable
PsiPackage getPackage()
Returns the package corresponding to the directory.

Returns:
the package instance, or null if the directory does not correspond to any package.

getParentDirectory

@Nullable
PsiDirectory getParentDirectory()
Returns the parent directory of the directory.

Returns:
the parent directory, or null if the directory has no parent.

getSubdirectories

@NotNull
PsiDirectory[] getSubdirectories()
Returns the list of subdirectories of this directory.

Returns:
the array of subdirectories.

getFiles

@NotNull
PsiFile[] getFiles()
Returns the list of files in the directory.

Returns:
the array of files.

getClasses

@NotNull
PsiClass[] getClasses()
Returns the list of Java classes contained in the directory.

Returns:
the array of classes.

findSubdirectory

@Nullable
PsiDirectory findSubdirectory(java.lang.String name)
Finds the subdirectory of this directory with the specified name.

Parameters:
name - the name of the subdirectory to find.
Returns:
the subdirectory instance, or null if no subdirectory with such a name is found.

findFile

@Nullable
PsiFile findFile(java.lang.String name)
Finds a file with the specified name in this directory.

Parameters:
name - the name of the file to find.
Returns:
the file instance, or null if no file with such a name is found.

createClass

@NotNull
PsiClass createClass(java.lang.String name)
                     throws IncorrectOperationException
Creates a class with the specified name in the directory.

Parameters:
name - the name of the class to create (not including the file extension).
Returns:
the created class instance.
Throws:
IncorrectOperationException - if the operation failed for some reason.

checkCreateClass

void checkCreateClass(java.lang.String name)
                      throws IncorrectOperationException
Checks if it's possible to create a class with the specified name in the directory, and throws an exception if the creation is not possible. Does not actually modify anything.

Parameters:
name - the name of the class to check creation possibility (not including the file extension).
Throws:
IncorrectOperationException - if the creation is not possible.

createInterface

@NotNull
PsiClass createInterface(java.lang.String name)
                         throws IncorrectOperationException
Creates an interface class with the specified name in the directory.

Parameters:
name - the name of the interface to create (not including the file extension).
Returns:
the created interface instance.
Throws:
IncorrectOperationException - if the operation failed for some reason.

checkCreateInterface

void checkCreateInterface(java.lang.String name)
                          throws IncorrectOperationException
Checks if it's possible to create an interface with the specified name in the directory, and throws an exception if the creation is not possible. Does not actually modify anything.

Parameters:
name - the name of the interface to check creation possibility (not including the file extension).
Throws:
IncorrectOperationException - if the creation is not possible.

createEnum

@NotNull
PsiClass createEnum(java.lang.String name)
                    throws IncorrectOperationException
Creates an enumeration class with the specified name in the directory.

Parameters:
name - the name of the enumeration class to create (not including the file extension).
Returns:
the created class instance.
Throws:
IncorrectOperationException - if the operation failed for some reason.

createAnnotationType

@NotNull
PsiClass createAnnotationType(java.lang.String name)
                              throws IncorrectOperationException
Creates an annotation class with the specified name in the directory.

Parameters:
name - the name of the annotation class to create (not including the file extension).
Returns:
the created class instance.
Throws:
IncorrectOperationException - if the operation failed for some reason.

createSubdirectory

@NotNull
PsiDirectory createSubdirectory(java.lang.String name)
                                throws IncorrectOperationException
Creates a subdirectory with the specified name in the directory.

Parameters:
name - the name of the subdirectory to create.
Returns:
the created directory instance.
Throws:
IncorrectOperationException - if the operation failed for some reason.

checkCreateSubdirectory

void checkCreateSubdirectory(java.lang.String name)
                             throws IncorrectOperationException
Checks if it's possible to create a subdirectory with the specified name in the directory, and throws an exception if the creation is not possible. Does not actually modify anything.

Parameters:
name - the name of the subdirectory to check creation possibility.
Throws:
IncorrectOperationException - if the creation is not possible.

createFile

@NotNull
PsiFile createFile(java.lang.String name)
                   throws IncorrectOperationException
Creates a file with the specified name in the directory.

Parameters:
name - the name of the file to create.
Returns:
the created file instance.
Throws:
IncorrectOperationException - if the operation failed for some reason.

checkCreateFile

void checkCreateFile(java.lang.String name)
                     throws IncorrectOperationException
Checks if it's possible to create a file with the specified name in the directory, and throws an exception if the creation is not possible. Does not actually modify anything.

Parameters:
name - the name of the file to check creation possibility.
Throws:
IncorrectOperationException - if the creation is not possible.

isSourceRoot

boolean isSourceRoot()
Checks if the directory is a source root for the project to which it belongs.

Returns:
true if the directory is a source root, false otherwise