GenericErrorNode

class GenericErrorNode(error: Exception? = null, message: String? = null) : Node, ErrorNode

Generic implementation of ErrorNode.

Constructors

Link copied to clipboard
constructor(error: Exception? = null, message: String? = null)

Functions

Link copied to clipboard
fun Node.addSeveralAfter(newNodes: List<Node>)

Inserts the newNodes after this node if it is in a MutableList. For this to work, Node.assignParents must have been called.

fun Node.addSeveralAfter(targetNode: Node, newNodes: List<Node>)

Looks for targetNode in the lists of nodes in this node. When found, newNodes are inserted after it. When not found, an IllegalStateException is thrown.

Link copied to clipboard
fun Node.addSeveralBefore(newNodes: List<Node>)

Inserts the newNodes before this node if it is in a MutableList. For this to work, Node.assignParents must have been called.

fun Node.addSeveralBefore(targetNode: Node, newNodes: List<Node>)

Looks for targetNode in the lists of nodes in this node. When found, newNodes are inserted before it. When not found, an IllegalStateException is thrown.

Link copied to clipboard

Sets or corrects the parent of all AST nodes. Kolasu does not see set/add/delete operations on the AST nodes, so this function should be called manually after modifying the AST.

Link copied to clipboard
fun <T> Node.collectByType(klass: Class<T>, walker: (Node) -> Sequence<Node> = Node::walk): List<T>

T is not forced to be a subtype of Node to support using interfaces.

Link copied to clipboard
fun Node.computeIds(walker: (Node) -> Sequence<Node> = Node::walk, idProvider: IdProvider = SequentialIdProvider()): IdentityHashMap<Node, String>
Link copied to clipboard
fun Node.computeIdsForReferencedNodes(walker: (Node) -> Sequence<Node> = Node::walk, idProvider: IdProvider = OnlyReferencedIdProvider(this)): IdentityHashMap<Node, String>
Link copied to clipboard

Return the property containing this Node, if any. Null should be returned for root nodes.

Link copied to clipboard
fun contains(range: Range?): Boolean

Tests whether the given range is contained in the interval represented by this object.

Link copied to clipboard
fun Node.debugPrint(indent: String = "", configuration: DebugPrintConfiguration = DebugPrintConfiguration()): String
Link copied to clipboard
fun detach(keepRange: Boolean = true, keepSourceText: Boolean = false)
Link copied to clipboard
Link copied to clipboard
fun Node.find(predicate: (Node) -> Boolean, walker: (Node) -> Sequence<Node> = Node::walk): Node?
Link copied to clipboard
fun <T> Node.findAncestorOfType(klass: Class<T>): T?

Note that type T is not strictly forced to be a Node. This is intended to support interfaces like Statement or Expression. However, being an ancestor the returned value is guaranteed to be a Node, as only Node instances can be part of the hierarchy.

Link copied to clipboard
fun Node.findByRange(range: Range, selfContained: Boolean = false): Node?
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun Node.hasValidParents(parent: Node? = this.parent): Boolean
Link copied to clipboard

Return the index of this Node within the containing property. The return value is null for root nodes. The index is always 0 for Nodes in singular containment properties.

Link copied to clipboard
Link copied to clipboard
fun Node.isBefore(other: Node): Boolean
Link copied to clipboard
fun Node.mapChildren(operation: (Node) -> Node): Node
Link copied to clipboard
fun overlaps(range: Range?): Boolean

Tests whether the given range overlaps the interval represented by this object.

Link copied to clipboard
fun Node.processConsideringDirectParent(operation: (Node, Node?) -> Unit, parent: Node? = null)

Recursively execute operation on this node, and all nodes below this node. Every node is informed about its parent node. (But not about the parent's parent!)

Link copied to clipboard
fun Node.processNodes(operation: (Node) -> Unit, walker: (Node) -> Sequence<Node> = Node::walk)

Recursively execute operation on this node, and all nodes below this node.

Link copied to clipboard
fun <T> Node.processNodesOfType(klass: Class<T>, operation: (T) -> Unit, walker: (Node) -> Sequence<Node> = Node::walk)

Recursively execute operation on this node, and all nodes below this node that extend klass.

Link copied to clipboard
fun Node.processProperties(propertiesToIgnore: Set<String> = emptySet(), propertyOperation: (PropertyDescription) -> Unit)

Executes an operation on the properties of a node.

Link copied to clipboard
fun registerObserver(observer: Observer<*>)
Link copied to clipboard

Removes this node from the parent if it is in a MutableList. For this to work, Node.assignParents must have been called.

fun Node.removeFromList(targetNode: Node)

Looks for targetNode in the lists of nodes in this node. When found, it is removed. When not found, an IllegalStateException is thrown.

Link copied to clipboard
fun Node.replaceWith(other: Node)

Replace this node with other (by modifying the children of the parent node.) For this to work, Node.assignParents must have been called.

Link copied to clipboard

Replaces this node with any amount of other nodes if it is in a MutableList.

fun Node.replaceWithSeveral(oldNode: Node, newNodes: List<Node>)

Looks for oldNode in the lists of nodes in this node. When found, it is removed, and in its place the newNodes are inserted. When not found, an IllegalStateException is thrown.

Link copied to clipboard
fun Node.searchByRange(range: Range, selfContained: Boolean = false): Sequence<Node>
Link copied to clipboard
fun <T> Node.searchByType(klass: Class<T>, walker: (Node) -> Sequence<Node> = Node::walk): Sequence<T>
Link copied to clipboard
override fun toString(): String

This must be final because otherwise data classes extending this will automatically generate their own implementation. If Link properties are present it could lead to stack overflows in case of circular graphs.

Link copied to clipboard
fun Node.transformChildren(operation: (Node) -> Node)
Link copied to clipboard
fun Node.transformTree(operation: (Node) -> Node, inPlace: Boolean = false, mutationsCache: IdentityHashMap<Node, Node> = IdentityHashMap<Node, Node>()): Node
Link copied to clipboard
fun unregisterObserver(observer: Observer<in Node>)
Link copied to clipboard

Traverse the entire tree, deep first, starting from this Node.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun Node.walkDescendants(walker: (Node) -> Sequence<Node> = Node::walk): Sequence<Node>
fun <N : Any> Node.walkDescendants(type: KClass<N>, walker: (Node) -> Sequence<Node> = Node::walk): Sequence<N>
Link copied to clipboard

Performs a post-order (or leaves-first) node traversal starting with a given node.

Link copied to clipboard

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open override val message: String
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open val nodeType: String
Link copied to clipboard
Link copied to clipboard

The node from which this AST Node has been generated, if any.

Link copied to clipboard
var parent: Node?

The parent node, if any.

Link copied to clipboard
Link copied to clipboard

The properties of this AST nodes, including attributes, children, and references.

Link copied to clipboard
open override var range: Range?

The range of this node in the source text. If a range has been provided when creating this node, it is returned. Otherwise, the value of this property is the range of the origin, if any.

Link copied to clipboard
open override val source: Source?
Link copied to clipboard
open override val sourceText: String?

The source text for this node

Link copied to clipboard