Package-level declarations

Types

Link copied to clipboard
Link copied to clipboard
data class CompositeOrigin(val elements: List<Origin>, val range: Range?, val sourceText: String?) : Origin, Serializable
Link copied to clipboard
data class DebugPrintConfiguration(var skipEmptyCollections: Boolean = false, var skipNull: Boolean = false, var forceShowRange: Boolean = false, val hide: MutableList<String> = mutableListOf(), var indentBlock: String = " ")

Influence what and how we print the debug information.

Link copied to clipboard
annotation class Derived

Use this to mark all relations which are secondary, i.e., they are calculated from other relations, so that they will not be considered branches of the AST.

Link copied to clipboard
interface Destination
Link copied to clipboard

This should be used for definitions of classes, interfaces, structures

Link copied to clipboard
interface ErrorNode

An AST node that marks the presence of an error, for example a syntactic or semantic error in the original tree.

Link copied to clipboard
interface Expression
Link copied to clipboard
class FileSource(val file: File) : Source
Link copied to clipboard
class GenericErrorNode(error: Exception? = null, message: String? = null) : Node, ErrorNode

Generic implementation of ErrorNode.

Link copied to clipboard
Link copied to clipboard

Use this to mark properties that are internal, i.e., they are used for bookkeeping and are not part of the model, so that they will not be considered branches of the AST.

Link copied to clipboard
annotation class Link

Use this to mark all the properties that return a Node or a list of Nodes which are not contained by the Node having the properties. In other words: they are just references. This will prevent them from being considered branches of the AST.

Link copied to clipboard
Link copied to clipboard
interface Named : PossiblyNamed

An entity which has a name.

Link copied to clipboard

The Abstract Syntax Tree will be constituted by instances of Node.

Link copied to clipboard
annotation class NodeType

Use this to mark something that does not inherit from Node as a node, so it will be included in the AST.

Link copied to clipboard
interface Origin
Link copied to clipboard

PlaceholderElements can be used to represent elements in code matchers templates and code templates. They represent variable elements in ASTs.

Link copied to clipboard
data class Point(val line: Int, val column: Int) : Comparable<Point> , Serializable

A location in a source code file. The line should be in 1..n, the column in 0..n.

Link copied to clipboard
interface PossiblyNamed

An entity that can have a name

Link copied to clipboard
data class PropertyDescription(val name: String, val provideNodes: Boolean, val multiplicity: Multiplicity, val value: Any?, val propertyType: PropertyType)
Link copied to clipboard
Link copied to clipboard
data class PropertyTypeDescription(val name: String, val provideNodes: Boolean, val multiple: Boolean, val valueType: KType)
Link copied to clipboard
data class Range(val start: Point, val end: Point, var source: Source? = null) : Comparable<Range> , Serializable

An area in a source file, from start to end. The start point is the point right before the starting character. The end point is the point right after the last character. An empty range will have coinciding points.

Link copied to clipboard
class ReferenceByName<N : PossiblyNamed>(val name: String, initialReferred: N? = null) : Serializable

A reference associated by using a name. It can be used only to refer to Nodes and not to other values.

Link copied to clipboard
class SimpleOrigin(val range: Range?, val sourceText: String?) : Origin, Serializable
Link copied to clipboard
abstract class Source : Serializable
Link copied to clipboard
class SourceSet(val name: String, val root: Path)
Link copied to clipboard
class SourceSetElement(val sourceSet: SourceSet, val relativePath: Path) : Source
Link copied to clipboard
interface Statement
Link copied to clipboard
class StringSource(val code: String? = null) : Source
Link copied to clipboard
data class SyntheticSource(val description: String) : Source

This source is intended to be used for nodes that are "calculated". For example, nodes representing types that are derived by examining the code but cannot be associated to any specific point in the code.

Link copied to clipboard
Link copied to clipboard
class URLSource(val url: URL) : Source

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.

fun <T> MutableList<T>.addSeveralAfter(index: Int, additions: List<T>)

Replaces the element at index with additions.

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.

fun <T> MutableList<T>.addSeveralBefore(index: Int, additions: List<T>)

Replaces the element at index with additions.

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

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

Link copied to clipboard
fun Node.debugPrint(indent: String = "", configuration: DebugPrintConfiguration = DebugPrintConfiguration()): String
fun <N : Node> ParsingResult<N>.debugPrint(indent: String = "", configuration: DebugPrintConfiguration = DebugPrintConfiguration()): String
fun Any?.debugPrint(indent: String = "", configuration: DebugPrintConfiguration = DebugPrintConfiguration()): String
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
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
Link copied to clipboard
fun Node.isBefore(other: Node): Boolean
Link copied to clipboard
Link copied to clipboard
fun lineRange(lineNumber: Int, lineCode: String, source: Source? = null): Range
Link copied to clipboard
fun Node.mapChildren(operation: (Node) -> Node): Node
Link copied to clipboard
inline fun <T : Node> Node.nextSibling(): Node?
Link copied to clipboard
inline fun <T : Node> Node.previousSibling(): Node?
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.

fun <T : Any> Class<T>.processProperties(propertiesToIgnore: Set<String> = emptySet(), propertyTypeOperation: (PropertyTypeDescription) -> Unit)
fun <T : Any> KClass<T>.processProperties(propertiesToIgnore: Set<String> = emptySet(), propertyTypeOperation: (PropertyTypeDescription) -> Unit)

Executes an operation on the properties definitions of a node class.

Link copied to clipboard
fun range(startLine: Int, startCol: Int, endLine: Int, endCol: Int): Range

Utility function to create a Range

Link copied to clipboard
fun <T : Node> T.relevantMemberProperties(withRange: Boolean = false, withNodeType: Boolean = false): List<KProperty1<T, *>>
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.

fun <T> MutableList<T>.replaceWithSeveral(index: Int, replacements: List<T>)

Replaces the element at index with replacements.

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

Try to resolve the reference by assigining @parampossibleValue. The assignment is not performed if

fun <N : PossiblyNamed> ReferenceByName<N>.tryToResolve(candidates: Iterable<N>, caseInsensitive: Boolean = false): Boolean

Try to resolve the reference by finding a named element with a matching name. The name match is performed in a case sensitive or insensitive way depending on the value of @paramcaseInsensitive.

Link copied to clipboard
fun <N : Node> N.withOrigin(origin: Origin?): N
Link copied to clipboard
fun <T : Node> T.withParent(parent: Node?): T
Link copied to clipboard
fun <N : Node> N.withRange(range: Range?): N

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val START_COLUMN: Int = 0
Link copied to clipboard
val START_LINE: Int = 1
Link copied to clipboard
Link copied to clipboard