public class CompositeElement extends TreeElement
Iconable.IconFlags, Iconable.LastComputedIcon
Modifier and Type | Field and Description |
---|---|
static CompositeElement[] |
EMPTY_ARRAY |
FLAGS_LOCKED, ICON_PLACEHOLDER
ICON_FLAG_IGNORE_MASK, ICON_FLAG_OPEN, ICON_FLAG_READ_STATUS, ICON_FLAG_VISIBILITY
Constructor and Description |
---|
CompositeElement(IElementType type) |
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 . |
TreeElement |
addInternal(TreeElement first,
ASTNode last,
ASTNode anchor,
java.lang.Boolean before) |
void |
addLeaf(IElementType leafType,
java.lang.CharSequence leafText,
ASTNode anchorBefore)
Add leaf element with specified type and text in the child list.
|
void |
clearCaches() |
CompositeElement |
clone()
Creates and returns a deep copy of the AST tree part starting at this node.
|
int |
countChildren(TokenSet filter) |
protected PsiElement |
createPsiNoLock() |
void |
deleteChildInternal(ASTNode child) |
ASTNode |
findChildByRole(int role) |
PsiElement |
findChildByRoleAsPsiElement(int role) |
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 types)
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.
|
PsiElement |
findPsiChildByType(IElementType type) |
PsiElement |
findPsiChildByType(TokenSet types) |
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.
|
<T extends PsiElement> |
getChildrenAsPsiElements(IElementType type,
ArrayFactory<? extends T> constructor) |
<T extends PsiElement> |
getChildrenAsPsiElements(TokenSet filter,
ArrayFactory<? extends T> constructor) |
int |
getChildRole(ASTNode child) |
protected int |
getChildRole(ASTNode child,
int roleCandidate) |
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() |
void |
rawAddChildren(TreeElement first) |
void |
rawAddChildrenWithoutNotifications(TreeElement first) |
TreeElement |
rawFirstChild() |
TreeElement |
rawLastChild() |
void |
rawRemoveAllChildren() |
void |
removeAllChildren() |
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.
|
void |
replaceChildInternal(ASTNode child,
TreeElement newElement) |
void |
setPsi(PsiElement psi) |
void |
subtreeChanged() |
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) |
char [] |
textToCharArray() |
copyElement, equals, getElementType, getManager, getStartOffset, getStartOffsetInParent, getTextOffset, getTextRange, getTreeNext, getTreeParent, getTreePrev, invalidate, onInvalidated, rawInsertAfterMe, rawInsertBeforeMe, rawRemove, rawRemoveUpTo, rawRemoveUpToLast, rawReplaceWithList, textMatches, 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
public static final CompositeElement[] EMPTY_ARRAY
public CompositeElement(IElementType type)
public CompositeElement clone()
ASTNode
clone
in interface ASTNode
clone
in class TreeElement
public void subtreeChanged()
public void clearCaches()
clearCaches
in class TreeElement
public void acceptTree(TreeElementVisitor visitor)
acceptTree
in class TreeElement
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 PsiElement findPsiChildByType(IElementType type)
public PsiElement findPsiChildByType(TokenSet types)
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 types)
ASTNode
types
- 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 java.lang.String getText()
ASTNode
public java.lang.CharSequence getChars()
ASTNode
PsiElement.textMatches(java.lang.CharSequence)
,
ASTNode.textContains(char)
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 final PsiElement findChildByRoleAsPsiElement(int role)
public ASTNode findChildByRole(int role)
public int getChildRole(ASTNode child)
protected final int getChildRole(ASTNode child, int roleCandidate)
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 <T extends PsiElement> T [] getChildrenAsPsiElements(TokenSet filter, ArrayFactory<? extends T> constructor)
public <T extends PsiElement> T [] getChildrenAsPsiElements(IElementType type, ArrayFactory<? extends T> constructor)
public int countChildren(TokenSet filter)
public TreeElement addInternal(TreeElement first, ASTNode last, ASTNode anchor, java.lang.Boolean before)
public void deleteChildInternal(ASTNode child)
public void replaceChildInternal(ASTNode child, TreeElement newElement)
public int getTextLength()
ASTNode
public int hc()
hc
in class TreeElement
public int getCachedLength()
getCachedLength
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 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 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 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 removeAllChildren()
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 final PsiElement getPsi()
ASTNode
public <T extends PsiElement> T getPsi(java.lang.Class<T> clazz)
ASTNode
clazz
- expected psi classprotected PsiElement createPsiNoLock()
public void setPsi(PsiElement psi)
public final void rawAddChildren(TreeElement first)
public void rawAddChildrenWithoutNotifications(TreeElement first)
public void rawRemoveAllChildren()
public TreeElement rawFirstChild()
public TreeElement rawLastChild()