- All Known Subinterfaces:
ChooseStatementNode,CompoundInitializerNode,CompoundStatementNode,DeclarationListNode,DesignationNode
A node in which all children have type
T.-
Nested Class Summary
Nested classes/interfaces inherited from interface dev.civl.abc.ast.node.IF.ASTNode
ASTNode.NodeKind -
Method Summary
Modifier and TypeMethodDescriptionintaddSequenceChild(T child) Appends the given node to the child list of this sequence node.copy()Returns a deep copy of this AST node.getSequenceChild(int i) Returns the child at position i, indexed from 0.voidinsertChildren(int index, List<T> list) Inserts a sequence of nodes into the child sequence of this node.removeChild(int index) Removes the child at givenindexfrom this node.setSequenceChild(int i, T child) Sets the child at index i to the given node.shiftRemoveChild(int index) Removes the child at the index from the list completely, shifting all children in front of it back by one.Methods inherited from interface dev.civl.abc.ast.node.IF.ASTNode
addAllTransformAnnotations, addTransformAnnotation, child, childIndex, children, diff, equiv, getAttribute, getOwner, getScope, getSource, id, keepOnly, nextDFS, nodeKind, numChildren, parent, prettyPrint, prettyRepresentation, prettyRepresentation, print, remove, removeTransformAnnotation, setAttribute, setChild, setId, setOwner, setScope, toString, transformAnnotationsMethods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
Method Details
-
addSequenceChild
Appends the given node to the child list of this sequence node. In the pre-state, the given node must have no parent. In the post-state, the given node will have its parent set to this node.- Parameters:
child- a node of typeTwhich does not currently have a parent- Returns:
- the index of the child after it is added, which equals the number of children of this node in the prestate (i.e., before the method executes)
-
getSequenceChild
Returns the child at position i, indexed from 0. This may benull.- Parameters:
i- an integer in the range [0,n), where n is the number of children of this sequence node- Returns:
- the child at index i, which may be
null
-
setSequenceChild
Sets the child at index i to the given node. The index i may be any nonnegative integer. If the index refers to a point beyond the current extent of the child list,nullchildren are added until the list is long enough. Otherwise the old child at index i will be replaced by the new. If the old child was notnull, it will become free, i.e., its parent field will be set tonull.- Parameters:
i- a nonnegative integerchild- a node of typeTwhich does not currently have a parent- Returns:
- the old node in position i (could be
null)
-
copy
SequenceNode<T> copy()Description copied from interface:ASTNodeReturns a deep copy of this AST node. The node and all of its descendants will be cloned. The cloning does not copy analysis or attribute information. -
removeChild
Description copied from interface:ASTNodeRemoves the child at given
indexfrom this node.The index must be in the range [0,n-1], where n is the value returned by
ASTNode.numChildren()in the pre-state (i.e., before this method is invoked). If there is no child at the given index (i.e., child isnull), this is a no-op.If the removed child is non-
null, its parent is set tonull.- Specified by:
removeChildin interfaceASTNode- Parameters:
index- nonnegative integer in the range [0,n-1], where n is the number of children before executing this method- Returns:
- the child that was removed (may be
null)
-
insertChildren
Inserts a sequence of nodes into the child sequence of this node. Any children after the given index will be shifted up in index.- Parameters:
index- an integer in [0,numChildren]list- a non-null list of free nodes of type T, any of which may be null
-
shiftRemoveChild
Removes the child at the index from the list completely, shifting all children in front of it back by one. Returns the child that was pulled from the list.- Parameters:
index- an integer in [0,numChildren)- Returns:
- The child that was removed from the list.
-