public class PsiDirectoryImpl extends PsiElementBase implements PsiDirectory, Queryable
Iconable.IconFlags, Iconable.LastComputedIconQueryable.Contributor, Queryable.PrintInfo, Queryable.UtilFLAGS_LOCKED, ICON_PLACEHOLDEREMPTY_ARRAYARRAY_FACTORYICON_FLAG_IGNORE_MASK, ICON_FLAG_OPEN, ICON_FLAG_READ_STATUS, ICON_FLAG_VISIBILITYEMPTY_NAVIGATABLE_ELEMENT_ARRAYEMPTY_NAVIGATION_ITEM_ARRAY| Constructor and Description |
|---|
PsiDirectoryImpl(PsiManagerImpl manager,
VirtualFile file) |
| Modifier and Type | Method and Description |
|---|---|
void |
accept(PsiElementVisitor visitor)
Passes the element to the specified visitor.
|
PsiElement |
add(PsiElement element)
Adds a child to this PSI element.
|
PsiElement |
addAfter(PsiElement element,
PsiElement anchor)
Adds a child to this PSI element, after the specified anchor element.
|
PsiElement |
addBefore(PsiElement element,
PsiElement anchor)
Adds a child to this PSI element, before the specified anchor element.
|
boolean |
canNavigateToSource()
Indicates whether this instance supports navigation to source (that means some kind of editor).
|
void |
checkAdd(PsiElement element)
Checks if it is possible to add the specified element as a child to this element,
and throws an exception if the add 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 |
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.
|
void |
checkDelete()
Checks if it is possible to delete the specified element from the tree,
and throws an exception if the add is not possible.
|
void |
checkSetName(java.lang.String name)
Checks if it is possible to rename the element to the specified name,
and throws an exception if the rename is not possible.
|
PsiElement |
copy()
Creates a copy of the file containing the PSI element and returns the corresponding
element in the created copy.
|
PsiFile |
copyFileFrom(java.lang.String newName,
PsiFile originalFile) |
PsiFile |
createFile(java.lang.String name)
Creates a file with the specified name in the directory.
|
PsiDirectory |
createSubdirectory(java.lang.String name)
Creates a subdirectory with the specified name in the directory.
|
void |
delete()
Deletes this PSI element from the tree.
|
boolean |
equals(java.lang.Object o) |
<T extends java.lang.Throwable> |
executeWithUpdatingAddedFilesDisabled(ThrowableRunnable<T> runnable) |
PsiElement |
findElementAt(int offset)
Finds a leaf PSI element at the specified offset from the start of the text range of this node.
|
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.
|
PsiElement [] |
getChildren()
Returns the array of children for the PSI element.
|
PsiFile |
getContainingFile()
Returns the file containing the PSI element.
|
protected javax.swing.Icon |
getElementIcon(int flags) |
PsiFile [] |
getFiles()
Returns the list of files in the directory.
|
Language |
getLanguage()
Returns the language of the PSI element.
|
PsiManager |
getManager()
Returns the PSI manager for the project to which the PSI element belongs.
|
java.lang.String |
getName()
Returns the name of the element.
|
ASTNode |
getNode()
Returns the AST node corresponding to the element.
|
PsiDirectory |
getParent()
Returns the parent of the PSI element.
|
PsiDirectory |
getParentDirectory()
Returns the parent directory of the directory.
|
ItemPresentation |
getPresentation() |
int |
getStartOffsetInParent()
Returns the text offset of the PSI element relative to its parent.
|
PsiDirectory [] |
getSubdirectories()
Returns the list of subdirectories of this directory.
|
java.lang.String |
getText()
Returns the text of the PSI element.
|
int |
getTextLength()
Returns the length of text of the PSI element.
|
int |
getTextOffset()
Returns the offset in the file to which the caret should be placed
when performing the navigation to the element.
|
TextRange |
getTextRange()
Returns the text range in the document occupied by the PSI element.
|
VirtualFile |
getVirtualFile()
Returns the virtual file represented by the PSI directory.
|
int |
hashCode() |
boolean |
isDirectory() |
boolean |
isPhysical()
Checks if an actual source or class file corresponds to the element.
|
boolean |
isValid()
Checks if this PSI element is valid.
|
boolean |
isWritable()
Checks if the contents of the element can be modified (if it belongs to a
non-read-only source file.)
|
void |
navigate(boolean requestFocus)
Open editor and select/navigate to the object there if possible.
|
boolean |
processChildren(PsiElementProcessor<PsiFileSystemItem> processor) |
void |
putInfo(java.util.Map<java.lang.String,java.lang.String> info) |
PsiElement |
replace(PsiElement newElement)
Replaces this PSI element (along with all its children) with another element
(along with the children).
|
PsiElement |
setName(java.lang.String name)
Renames the element.
|
boolean |
textMatches(java.lang.CharSequence text)
Checks if the text of this PSI element is equal to the specified character sequence.
|
boolean |
textMatches(PsiElement element)
Checks if the text of this PSI element is equal to the text of the specified PSI element.
|
char [] |
textToCharArray()
Returns the text of the PSI element as a character array.
|
java.lang.String |
toString()
toString() should never be presented to the user.
|
acceptChildren, addRange, addRangeAfter, addRangeBefore, canNavigate, deleteChildRange, findChildByClass, findChildrenByClass, findNotNullChildByClass, findReferenceAt, getContext, getFirstChild, getLastChild, getNavigationElement, getNextSibling, getOriginalElement, getPrevSibling, getProject, getReference, getReferences, getResolveScope, getUseScope, isEquivalentTo, notNullChild, processDeclarations, textContainsbuildRowIcon, computeBaseIcon, createLayeredIcon, getAdjustedBaseIcon, getBaseIcon, getIcon, iconWithVisibilityIfNeeded, isNativeFileType, isVisibilitySupported, overlayIcons, registerIconLayer, transformFlagschangeUserMap, clearUserData, clone, copyCopyableDataTo, copyUserDataTo, getCopyableUserData, getUserData, getUserDataString, getUserMap, isUserDataEmpty, putCopyableUserData, putUserData, putUserDataIfAbsent, replace, setUserMapfinalize, getClass, notify, notifyAll, wait, wait, waitacceptChildren, addRange, addRangeAfter, addRangeBefore, deleteChildRange, findReferenceAt, getContext, getCopyableUserData, getFirstChild, getLastChild, getNavigationElement, getNextSibling, getOriginalElement, getOwnReferences, getPrevSibling, getProject, getReference, getReferences, getResolveScope, getTextRangeInParent, getUseScope, isEquivalentTo, processDeclarations, putCopyableUserData, textContainsgetUserData, putUserDatacanNavigatepublic PsiDirectoryImpl(PsiManagerImpl manager, VirtualFile file)
public VirtualFile getVirtualFile()
PsiDirectorygetVirtualFile in interface PsiDirectorygetVirtualFile in interface PsiFileSystemItempublic boolean isDirectory()
isDirectory in interface PsiFileSystemItempublic boolean isValid()
PsiElementPsiDocumentManager.commitDocument(com.intellij.openapi.editor.Document)).
(In this case an attempt to change PSI will result in an exception).
Any access to invalid elements results in PsiInvalidElementAccessException.
Once invalid, elements can't become valid again.
Elements become invalid in following cases:
PsiElement.delete())isValid in interface PsiElementisValid in class PsiElementBasePsiUtilCore.ensureValid(PsiElement)public Language getLanguage()
PsiElementgetLanguage in interface PsiElementpublic PsiManager getManager()
PsiElementgetManager in interface PsiElementgetManager in class PsiElementBasepublic java.lang.String getName()
PsiNamedElementgetName in interface NavigationItemgetName in interface PsiDirectorygetName in interface PsiFileSystemItemgetName in interface PsiNamedElementgetName in class PsiElementBasepublic PsiElement setName(java.lang.String name) throws IncorrectOperationException
PsiNamedElementsetName in interface PsiDirectorysetName in interface PsiNamedElementname - the new element name.this
or a different element if the rename caused the element to be replaced).IncorrectOperationException - if the modification is not supported or not possible for some reason.public void checkSetName(java.lang.String name)
throws IncorrectOperationException
PsiCheckedRenameElementcheckSetName in interface PsiCheckedRenameElementname - the new name to check the renaming possibility for.IncorrectOperationException - if the rename is not supported or not possible for some reason.public PsiDirectory getParentDirectory()
PsiDirectorygetParentDirectory in interface PsiDirectorypublic PsiDirectory [] getSubdirectories()
PsiDirectorygetSubdirectories in interface PsiDirectorypublic PsiFile [] getFiles()
PsiDirectorygetFiles in interface PsiDirectorypublic PsiDirectory findSubdirectory(java.lang.String name)
PsiDirectoryfindSubdirectory in interface PsiDirectoryname - the name of the subdirectory to find.public PsiFile findFile(java.lang.String name)
PsiDirectoryfindFile in interface PsiDirectoryname - the name of the file to find.public boolean processChildren(PsiElementProcessor<PsiFileSystemItem> processor)
processChildren in interface PsiFileSystemItempublic PsiElement [] getChildren()
PsiElementgetChildren in interface PsiElementpublic PsiDirectory getParent()
PsiElementgetParent in interface PsiDirectorygetParent in interface PsiElementgetParent in interface PsiFileSystemItempublic PsiFile getContainingFile()
PsiElementgetContainingFile in interface PsiElementgetContainingFile in class PsiElementBasepublic TextRange getTextRange()
PsiElementgetTextRange in interface PsiElementpublic int getStartOffsetInParent()
PsiElementgetStartOffsetInParent in interface PsiElementpublic int getTextLength()
PsiElementgetTextLength in interface PsiElementpublic PsiElement findElementAt(int offset)
PsiElementfindElementAt in interface PsiElementoffset - the relative offset for which the PSI element is requested.public int getTextOffset()
PsiElementPsiNamedElement, this should return the offset in the file of the
name identifier.)getTextOffset in interface PsiElementpublic java.lang.String getText()
PsiElementgetText in interface PsiElementPsiElement.textMatches(java.lang.CharSequence),
PsiElement.textContains(char)public char [] textToCharArray()
PsiElementtextToCharArray in interface PsiElementpublic boolean textMatches(java.lang.CharSequence text)
PsiElementtextMatches in interface PsiElementtextMatches in class PsiElementBasetext - the character sequence to compare with.public boolean textMatches(PsiElement element)
PsiElementtextMatches in interface PsiElementtextMatches in class PsiElementBaseelement - the element to compare the text with.public final boolean isWritable()
PsiElementisWritable in interface PsiElementisWritable in class PsiElementBasepublic boolean isPhysical()
PsiElementPsiDocumentManager.getDocument(PsiFile) returns null for non-physical elements.
Not to be confused with FileViewProvider.isPhysical().isPhysical in interface PsiElementisPhysical in class PsiElementBasepublic PsiElement copy()
PsiElementcopy in interface PsiElementcopy in class PsiElementBasepublic PsiDirectory createSubdirectory(java.lang.String name) throws IncorrectOperationException
PsiDirectorycreateSubdirectory in interface PsiDirectoryname - the name of the subdirectory to create.IncorrectOperationException - if the operation failed for some reason.public void checkCreateSubdirectory(java.lang.String name)
throws IncorrectOperationException
PsiDirectorycheckCreateSubdirectory in interface PsiDirectoryname - the name of the subdirectory to check creation possibility.IncorrectOperationException - if the creation is not possible.public PsiFile createFile(java.lang.String name) throws IncorrectOperationException
PsiDirectorycreateFile in interface PsiDirectoryname - the name of the file to create.IncorrectOperationException - if the operation failed for some reason.public PsiFile copyFileFrom(java.lang.String newName, PsiFile originalFile) throws IncorrectOperationException
copyFileFrom in interface PsiDirectoryIncorrectOperationExceptionpublic <T extends java.lang.Throwable> void executeWithUpdatingAddedFilesDisabled(ThrowableRunnable<T> runnable) throws T extends java.lang.Throwable
T extends java.lang.Throwablepublic void checkCreateFile(java.lang.String name)
throws IncorrectOperationException
PsiDirectorycheckCreateFile in interface PsiDirectoryname - the name of the file to check creation possibility.IncorrectOperationException - if the creation is not possible.public PsiElement add(PsiElement element) throws IncorrectOperationException
PsiElementadd in interface PsiElementadd in class PsiElementBaseelement - the child element to add.element or its copy).IncorrectOperationException - if the modification is not supported or not possible for some reason.public void checkAdd(PsiElement element) throws IncorrectOperationException
PsiElementcheckAdd in interface PsiElementcheckAdd in class PsiElementBaseelement - the child element to check the add possibility.IncorrectOperationException - if the modification is not supported or not possible for some reason.public PsiElement addBefore(PsiElement element, PsiElement anchor) throws IncorrectOperationException
PsiElementaddBefore in interface PsiElementaddBefore in class PsiElementBaseelement - the child element to add.anchor - the anchor before which the child element is inserted (must be a child of this PSI element)element or its copy).IncorrectOperationException - if the modification is not supported or not possible for some reason.public PsiElement addAfter(PsiElement element, PsiElement anchor) throws IncorrectOperationException
PsiElementaddAfter in interface PsiElementaddAfter in class PsiElementBaseelement - the child element to add.anchor - the anchor after which the child element is inserted (must be a child of this PSI element)element or its copy).IncorrectOperationException - if the modification is not supported or not possible for some reason.public void delete()
throws IncorrectOperationException
PsiElementdelete in interface PsiElementdelete in class PsiElementBaseIncorrectOperationException - if the modification is not supported
or not possible for some reason (for example, the file containing the element is read-only).public void checkDelete()
throws IncorrectOperationException
PsiElementcheckDelete in interface PsiElementcheckDelete in class PsiElementBaseIncorrectOperationException - if the modification is not supported or not possible for some reason.public PsiElement replace(PsiElement newElement) throws IncorrectOperationException
PsiElementreplace in interface PsiElementreplace in class PsiElementBasenewElement - the element to replace this element with.newElement or its copy)IncorrectOperationException - if the modification is not supported or not possible for some reason.public void accept(PsiElementVisitor visitor)
PsiElementaccept in interface PsiElementaccept in class PsiElementBasevisitor - the visitor to pass the element to.public java.lang.String toString()
PsiElementtoString in interface PsiElementtoString in class java.lang.Objectpublic ASTNode getNode()
PsiElementgetNode in interface PsiElementpublic boolean canNavigateToSource()
Navigatablefalse.
In such cases it is not recommended to do batch navigation for all navigatables
available via CommonDataKeys.NAVIGATABLE_ARRAY,
because it may lead to opening several modal dialogs.
Use OpenSourceUtil.navigate(com.intellij.pom.Navigatable...) to process such arrays correctly.canNavigateToSource in interface NavigatablecanNavigateToSource in class PsiElementBasefalse if navigation to source is not possible for any reason.public ItemPresentation getPresentation()
getPresentation in interface NavigationItemgetPresentation in class PsiElementBasepublic void navigate(boolean requestFocus)
Navigatablenavigate in interface Navigatablenavigate in class PsiElementBaserequestFocus - true if focus requesting is necessaryprotected javax.swing.Icon getElementIcon(int flags)
getElementIcon in class ElementBasepublic void putInfo(java.util.Map<java.lang.String,java.lang.String> info)
public boolean equals(java.lang.Object o)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Object