public abstract class PsiPackageBase extends PsiElementBase implements PsiDirectoryContainer, Queryable
Iconable.IconFlags, Iconable.LastComputedIcon
Queryable.Contributor, Queryable.PrintInfo, Queryable.Util
FLAGS_LOCKED, ICON_PLACEHOLDER
EMPTY_ARRAY
ARRAY_FACTORY
ICON_FLAG_IGNORE_MASK, ICON_FLAG_OPEN, ICON_FLAG_READ_STATUS, ICON_FLAG_VISIBILITY
EMPTY_NAVIGATABLE_ELEMENT_ARRAY
EMPTY_NAVIGATION_ITEM_ARRAY
Constructor and Description |
---|
PsiPackageBase(PsiManager manager,
java.lang.String qualifiedName) |
Modifier and Type | Method and Description |
---|---|
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 |
canNavigate()
Indicates whether this instance supports navigation of any kind.
|
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 |
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) |
PsiElement |
copy()
Creates a copy of the file containing the PSI element and returns the corresponding
element in the created copy.
|
void |
delete()
Deletes this PSI element from the tree.
|
boolean |
equals(java.lang.Object o) |
PsiElement |
findElementAt(int offset)
Finds a leaf PSI element at the specified offset from the start of the text range of this node.
|
protected abstract PsiPackageBase |
findPackage(java.lang.String qName) |
protected java.util.Collection<PsiDirectory> |
getAllDirectories() |
protected abstract java.util.Collection<PsiDirectory> |
getAllDirectories(boolean includeLibrarySources) |
PsiElement [] |
getChildren()
Returns the array of children for the PSI element.
|
PsiFile |
getContainingFile()
Returns the file containing the PSI element.
|
PsiDirectory [] |
getDirectories()
Returns the array of all directories (under all source roots in the project)
corresponding to the package.
|
PsiDirectory [] |
getDirectories(GlobalSearchScope scope)
Returns the array of directories corresponding to the package in the specified search scope.
|
RowIcon |
getElementIcon(int elementFlags) |
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.
|
PsiElement |
getParent()
Returns the parent of the PSI element.
|
PsiPackageBase |
getParentPackage() |
java.lang.String |
getQualifiedName() |
int |
getStartOffsetInParent()
Returns the text offset of the PSI element relative to its parent.
|
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.
|
int |
hashCode() |
boolean |
isPhysical()
Checks if an actual source or class file corresponds to the element.
|
boolean |
isWritable()
Checks if the contents of the element can be modified (if it belongs to a
non-read-only source file.)
|
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.
|
accept, acceptChildren, addRange, addRangeAfter, addRangeBefore, deleteChildRange, findChildByClass, findChildrenByClass, findNotNullChildByClass, findReferenceAt, getContext, getFirstChild, getLastChild, getNavigationElement, getNextSibling, getOriginalElement, getPresentation, getPrevSibling, getProject, getReference, getReferences, getResolveScope, getUseScope, isEquivalentTo, isValid, navigate, notNullChild, processDeclarations, textContains
buildRowIcon, computeBaseIcon, createLayeredIcon, getAdjustedBaseIcon, getBaseIcon, getIcon, iconWithVisibilityIfNeeded, isNativeFileType, isVisibilitySupported, overlayIcons, registerIconLayer, transformFlags
changeUserMap, clearUserData, clone, copyCopyableDataTo, copyUserDataTo, getCopyableUserData, getUserData, getUserDataString, getUserMap, isUserDataEmpty, putCopyableUserData, putUserData, putUserDataIfAbsent, replace, setUserMap
finalize, getClass, notify, notifyAll, wait, wait, wait
accept, acceptChildren, addRange, addRangeAfter, addRangeBefore, deleteChildRange, findReferenceAt, getContext, getCopyableUserData, getFirstChild, getLanguage, getLastChild, getNavigationElement, getNextSibling, getOriginalElement, getOwnReferences, getPrevSibling, getProject, getReference, getReferences, getResolveScope, getTextRangeInParent, getUseScope, isEquivalentTo, isValid, processDeclarations, putCopyableUserData, textContains
getUserData, putUserData
public PsiPackageBase(PsiManager manager, java.lang.String qualifiedName)
protected java.util.Collection<PsiDirectory> getAllDirectories()
protected abstract java.util.Collection<PsiDirectory> getAllDirectories(boolean includeLibrarySources)
protected abstract PsiPackageBase findPackage(java.lang.String qName)
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String getQualifiedName()
public PsiDirectory [] getDirectories()
PsiDirectoryContainer
getDirectories
in interface PsiDirectoryContainer
public PsiDirectory [] getDirectories(GlobalSearchScope scope)
PsiDirectoryContainer
getDirectories
in interface PsiDirectoryContainer
scope
- the scope in which directories are searched.public RowIcon getElementIcon(int elementFlags)
getElementIcon
in class ElementBase
public java.lang.String getName()
PsiNamedElement
getName
in interface NavigationItem
getName
in interface PsiNamedElement
getName
in class PsiElementBase
public PsiElement setName(java.lang.String name) throws IncorrectOperationException
PsiNamedElement
setName
in interface PsiNamedElement
name
- 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
IncorrectOperationException
public PsiPackageBase getParentPackage()
public PsiManager getManager()
PsiElement
getManager
in interface PsiElement
getManager
in class PsiElementBase
public PsiElement [] getChildren()
PsiElement
getChildren
in interface PsiElement
public PsiElement getParent()
PsiElement
getParent
in interface PsiElement
public PsiFile getContainingFile()
PsiElement
getContainingFile
in interface PsiElement
getContainingFile
in class PsiElementBase
public TextRange getTextRange()
PsiElement
getTextRange
in interface PsiElement
public int getStartOffsetInParent()
PsiElement
getStartOffsetInParent
in interface PsiElement
public int getTextLength()
PsiElement
getTextLength
in interface PsiElement
public PsiElement findElementAt(int offset)
PsiElement
findElementAt
in interface PsiElement
offset
- the relative offset for which the PSI element is requested.public int getTextOffset()
PsiElement
PsiNamedElement
, this should return the offset in the file of the
name identifier.)getTextOffset
in interface PsiElement
public java.lang.String getText()
PsiElement
getText
in interface PsiElement
PsiElement.textMatches(java.lang.CharSequence)
,
PsiElement.textContains(char)
public char [] textToCharArray()
PsiElement
textToCharArray
in interface PsiElement
public boolean textMatches(java.lang.CharSequence text)
PsiElement
textMatches
in interface PsiElement
textMatches
in class PsiElementBase
text
- the character sequence to compare with.public boolean textMatches(PsiElement element)
PsiElement
textMatches
in interface PsiElement
textMatches
in class PsiElementBase
element
- the element to compare the text with.public PsiElement copy()
PsiElement
copy
in interface PsiElement
copy
in class PsiElementBase
public PsiElement add(PsiElement element) throws IncorrectOperationException
PsiElement
add
in interface PsiElement
add
in class PsiElementBase
element
- the child element to add.element
or its copy).IncorrectOperationException
- if the modification is not supported or not possible for some reason.public PsiElement addBefore(PsiElement element, PsiElement anchor) throws IncorrectOperationException
PsiElement
addBefore
in interface PsiElement
addBefore
in class PsiElementBase
element
- 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
PsiElement
addAfter
in interface PsiElement
addAfter
in class PsiElementBase
element
- 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 checkAdd(PsiElement element) throws IncorrectOperationException
PsiElement
checkAdd
in interface PsiElement
checkAdd
in class PsiElementBase
element
- the child element to check the add possibility.IncorrectOperationException
- if the modification is not supported or not possible for some reason.public void delete() throws IncorrectOperationException
PsiElement
delete
in interface PsiElement
delete
in class PsiElementBase
IncorrectOperationException
- 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
PsiElement
checkDelete
in interface PsiElement
checkDelete
in class PsiElementBase
IncorrectOperationException
- if the modification is not supported or not possible for some reason.public PsiElement replace(PsiElement newElement) throws IncorrectOperationException
PsiElement
replace
in interface PsiElement
replace
in class PsiElementBase
newElement
- 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 boolean isWritable()
PsiElement
isWritable
in interface PsiElement
isWritable
in class PsiElementBase
public java.lang.String toString()
PsiElement
toString
in interface PsiElement
toString
in class java.lang.Object
public boolean canNavigate()
Navigatable
Navigatable.canNavigateToSource()
returns true
.
We assume that this method should return true
in such case,
so implement this method respectively.canNavigate
in interface Navigatable
canNavigate
in class PsiElementBase
false
if navigation is not possible for any reason.public boolean canNavigateToSource()
Navigatable
false
.
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 Navigatable
canNavigateToSource
in class PsiElementBase
false
if navigation to source is not possible for any reason.public boolean isPhysical()
PsiElement
PsiDocumentManager.getDocument(PsiFile)
returns null for non-physical elements.
Not to be confused with FileViewProvider.isPhysical()
.isPhysical
in interface PsiElement
isPhysical
in class PsiElementBase
public ASTNode getNode()
PsiElement
getNode
in interface PsiElement