public abstract class LeafElement extends TreeElement
Iconable.IconFlags, Iconable.LastComputedIcon
EMPTY_ARRAY
FLAGS_LOCKED, ICON_PLACEHOLDER
ICON_FLAG_IGNORE_MASK, ICON_FLAG_OPEN, ICON_FLAG_READ_STATUS, ICON_FLAG_VISIBILITY
Modifier | Constructor and Description |
---|---|
protected |
LeafElement(IElementType type,
java.lang.CharSequence text) |
Modifier and Type | Method and Description |
---|---|
void |
acceptTree(TreeElementVisitor visitor) |
void |
addChild(ASTNode child)
Adds the specified child node as the last child of this node.
|
void |
addChild(ASTNode child,
ASTNode anchorBefore)
Adds the specified child node at the specified position in the child list.
|
void |
addChildren(ASTNode firstChild,
ASTNode lastChild,
ASTNode anchorBefore)
Adds a range of nodes belonging to the same parent to the list of children of this node,
starting with
firstChild , up to and not including firstChildToNotAdd . |
void |
addLeaf(IElementType leafType,
java.lang.CharSequence leafText,
ASTNode anchorBefore)
Add leaf element with specified type and text in the child list.
|
char |
charAt(int position) |
LeafElement |
clone()
Creates and returns a deep copy of the AST tree part starting at this node.
|
int |
copyTo(char [] buffer,
int start) |
ASTNode |
findChildByType(IElementType type)
Returns the first child of the specified node which has the specified type.
|
ASTNode |
findChildByType(IElementType type,
ASTNode anchor)
Returns the first child after anchor of the specified node which has the specified type.
|
ASTNode |
findChildByType(TokenSet typesSet)
Returns the first child of the specified node which has type from specified set.
|
ASTNode |
findChildByType(TokenSet typesSet,
ASTNode anchor)
Returns the first child after anchor of the specified node which has type from specified set.
|
LeafElement |
findLeafElementAt(int offset)
Finds a leaf child node at the specified offset from the start of the text range of this node.
|
int |
getCachedLength() |
java.lang.CharSequence |
getChars()
Returns same text getText() returns but might be more effective eliminating toString() transformation from internal CharSequence representation
|
ASTNode [] |
getChildren(TokenSet filter)
Returns the list of children of the specified node, optionally filtered by the
specified token type filter.
|
TreeElement |
getFirstChildNode()
Returns the first child of this node in the tree.
|
TreeElement |
getLastChildNode()
Returns the last child of this node in the tree.
|
PsiElement |
getPsi()
Returns the PSI element for this node.
|
<T extends PsiElement> |
getPsi(java.lang.Class<T> clazz)
Checks and returns the PSI element for this node.
|
java.lang.String |
getText()
Returns the text of this node.
|
int |
getTextLength()
Returns the length of the node text.
|
int |
hc() |
LeafElement |
rawReplaceWithText(java.lang.String newText) |
void |
removeChild(ASTNode child)
Removes the specified node from the list of children of this node.
|
void |
removeRange(ASTNode first,
ASTNode firstWhichStayInTree)
Removes a range of nodes from the list of children, starting with
firstNodeToRemove ,
up to and not including firstNodeToKeep . |
void |
replaceAllChildrenToChildrenOf(ASTNode anotherParent)
Replaces all child nodes with the children of the specified node.
|
void |
replaceChild(ASTNode oldChild,
ASTNode newChild)
Replaces the specified child node with another node.
|
LeafElement |
replaceWithText(java.lang.String newText) |
boolean |
textContains(char c)
Checks if the specified character is present in the text of this node.
|
protected int |
textMatches(java.lang.CharSequence buffer,
int start) |
boolean |
textMatches(java.lang.CharSequence buf,
int start,
int end) |
char [] |
textToCharArray() |
clearCaches, copyElement, equals, getElementType, getManager, getStartOffset, getStartOffsetInParent, getTextOffset, getTextRange, getTreeNext, getTreeParent, getTreePrev, invalidate, onInvalidated, rawInsertAfterMe, rawInsertBeforeMe, rawRemove, rawRemoveUpTo, rawRemoveUpToLast, rawReplaceWithList, textMatches, textMatches, toString
buildRowIcon, computeBaseIcon, createLayeredIcon, getAdjustedBaseIcon, getBaseIcon, getElementIcon, getIcon, iconWithVisibilityIfNeeded, isNativeFileType, isVisibilitySupported, overlayIcons, registerIconLayer, transformFlags
changeUserMap, clearUserData, copyCopyableDataTo, copyUserDataTo, getCopyableUserData, getUserData, getUserDataString, getUserMap, isUserDataEmpty, putCopyableUserData, putUserData, putUserDataIfAbsent, replace, setUserMap
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getCopyableUserData, putCopyableUserData
getUserData, putUserData
protected LeafElement(IElementType type, java.lang.CharSequence text)
public LeafElement clone()
ASTNode
clone
in interface ASTNode
clone
in class TreeElement
public int getTextLength()
ASTNode
public java.lang.CharSequence getChars()
ASTNode
PsiElement.textMatches(java.lang.CharSequence)
,
ASTNode.textContains(char)
public java.lang.String getText()
ASTNode
public char charAt(int position)
public int copyTo(char [] buffer, int start)
public char [] textToCharArray()
textToCharArray
in class TreeElement
public boolean textContains(char c)
ASTNode
c
- the character to search for.protected int textMatches(java.lang.CharSequence buffer, int start)
textMatches
in class TreeElement
public LeafElement rawReplaceWithText(java.lang.String newText)
public LeafElement replaceWithText(java.lang.String newText)
public LeafElement findLeafElementAt(int offset)
ASTNode
findLeafElementAt
in interface ASTNode
findLeafElementAt
in class TreeElement
offset
- the relative offset for which the child node is requested.public boolean textMatches(java.lang.CharSequence buf, int start, int end)
textMatches
in class TreeElement
public void acceptTree(TreeElementVisitor visitor)
acceptTree
in class TreeElement
public ASTNode findChildByType(IElementType type)
ASTNode
type
- the type of the node to return.public ASTNode findChildByType(IElementType type, ASTNode anchor)
ASTNode
type
- the type of the node to return.anchor
- to start search frompublic ASTNode findChildByType(TokenSet typesSet)
ASTNode
typesSet
- the token set used to filter the returned children.public ASTNode findChildByType(TokenSet typesSet, ASTNode anchor)
ASTNode
typesSet
- the token set used to filter the returned children.anchor
- to start search frompublic int hc()
hc
in class TreeElement
public TreeElement getFirstChildNode()
ASTNode
getFirstChildNode
in interface ASTNode
getFirstChildNode
in class TreeElement
public TreeElement getLastChildNode()
ASTNode
getLastChildNode
in interface ASTNode
getLastChildNode
in class TreeElement
public int getCachedLength()
getCachedLength
in class TreeElement
public ASTNode [] getChildren(TokenSet filter)
ASTNode
filter
- the token set used to filter the returned children, or null if
all children should be returned.public void addChild(ASTNode child, ASTNode anchorBefore)
ASTNode
child
- the child node to add.anchorBefore
- the node before which the child node is inserted (null
to add a child as a last node).public void addLeaf(IElementType leafType, java.lang.CharSequence leafText, ASTNode anchorBefore)
ASTNode
leafType
- type of leaf element to add.leafText
- text of added leaf.anchorBefore
- the node before which the child node is inserted.public void addChild(ASTNode child)
ASTNode
child
- the child node to add.public void removeChild(ASTNode child)
ASTNode
child
- the child node to remove.public void replaceChild(ASTNode oldChild, ASTNode newChild)
ASTNode
oldChild
- the child node to replace.newChild
- the node to replace with.public void replaceAllChildrenToChildrenOf(ASTNode anotherParent)
ASTNode
anotherParent
- the parent node whose children are used for replacement.public void removeRange(ASTNode first, ASTNode firstWhichStayInTree)
ASTNode
firstNodeToRemove
,
up to and not including firstNodeToKeep
.first
- the first child node to remove from the tree.firstWhichStayInTree
- the first child node to keep in the tree.public void addChildren(ASTNode firstChild, ASTNode lastChild, ASTNode anchorBefore)
ASTNode
firstChild
, up to and not including firstChildToNotAdd
.firstChild
- the first node to add.lastChild
- the first child node following firstChild which will not be added to the tree.anchorBefore
- the node before which the child nodes are inserted.public PsiElement getPsi()
ASTNode
public <T extends PsiElement> T getPsi(java.lang.Class<T> clazz)
ASTNode
clazz
- expected psi class