public abstract class LeafElement extends TreeElement
Iconable.IconFlags, Iconable.LastComputedIconEMPTY_ARRAYFLAGS_LOCKED, ICON_PLACEHOLDERICON_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, toStringbuildRowIcon, computeBaseIcon, createLayeredIcon, getAdjustedBaseIcon, getBaseIcon, getElementIcon, getIcon, iconWithVisibilityIfNeeded, isNativeFileType, isVisibilitySupported, overlayIcons, registerIconLayer, transformFlagschangeUserMap, clearUserData, copyCopyableDataTo, copyUserDataTo, getCopyableUserData, getUserData, getUserDataString, getUserMap, isUserDataEmpty, putCopyableUserData, putUserData, putUserDataIfAbsent, replace, setUserMapfinalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetCopyableUserData, putCopyableUserDatagetUserData, putUserDataprotected LeafElement(IElementType type, java.lang.CharSequence text)
public LeafElement clone()
ASTNodeclone in interface ASTNodeclone in class TreeElementpublic int getTextLength()
ASTNodepublic java.lang.CharSequence getChars()
ASTNodePsiElement.textMatches(java.lang.CharSequence),
ASTNode.textContains(char)public java.lang.String getText()
ASTNodepublic char charAt(int position)
public int copyTo(char [] buffer,
int start)
public char [] textToCharArray()
textToCharArray in class TreeElementpublic boolean textContains(char c)
ASTNodec - the character to search for.protected int textMatches(java.lang.CharSequence buffer,
int start)
textMatches in class TreeElementpublic LeafElement rawReplaceWithText(java.lang.String newText)
public LeafElement replaceWithText(java.lang.String newText)
public LeafElement findLeafElementAt(int offset)
ASTNodefindLeafElementAt in interface ASTNodefindLeafElementAt in class TreeElementoffset - the relative offset for which the child node is requested.public boolean textMatches(java.lang.CharSequence buf,
int start,
int end)
textMatches in class TreeElementpublic void acceptTree(TreeElementVisitor visitor)
acceptTree in class TreeElementpublic ASTNode findChildByType(IElementType type)
ASTNodetype - the type of the node to return.public ASTNode findChildByType(IElementType type, ASTNode anchor)
ASTNodetype - the type of the node to return.anchor - to start search frompublic ASTNode findChildByType(TokenSet typesSet)
ASTNodetypesSet - the token set used to filter the returned children.public ASTNode findChildByType(TokenSet typesSet, ASTNode anchor)
ASTNodetypesSet - the token set used to filter the returned children.anchor - to start search frompublic int hc()
hc in class TreeElementpublic TreeElement getFirstChildNode()
ASTNodegetFirstChildNode in interface ASTNodegetFirstChildNode in class TreeElementpublic TreeElement getLastChildNode()
ASTNodegetLastChildNode in interface ASTNodegetLastChildNode in class TreeElementpublic int getCachedLength()
getCachedLength in class TreeElementpublic ASTNode [] getChildren(TokenSet filter)
ASTNodefilter - the token set used to filter the returned children, or null if
all children should be returned.public void addChild(ASTNode child, ASTNode anchorBefore)
ASTNodechild - 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)
ASTNodeleafType - 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)
ASTNodechild - the child node to add.public void removeChild(ASTNode child)
ASTNodechild - the child node to remove.public void replaceChild(ASTNode oldChild, ASTNode newChild)
ASTNodeoldChild - the child node to replace.newChild - the node to replace with.public void replaceAllChildrenToChildrenOf(ASTNode anotherParent)
ASTNodeanotherParent - the parent node whose children are used for replacement.public void removeRange(ASTNode first, ASTNode firstWhichStayInTree)
ASTNodefirstNodeToRemove,
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)
ASTNodefirstChild, 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()
ASTNodepublic <T extends PsiElement> T getPsi(java.lang.Class<T> clazz)
ASTNodeclazz - expected psi class