Table of Contents

Class SyntaxNodeWalk

Namespace
RDCore.SDK.Model.AST.Abstract
Assembly
RDCore.SDK.dll

Walks the syntax tree the way it is written, statements in the blocks of structured statements included.

public static class SyntaxNodeWalk
Inheritance
SyntaxNodeWalk
Inherited Members

Remarks

The Children of a node are the nodes it is made of, but not the statements of the blocks it guards: the body of an If, a loop, a With or a Case is a StatementBlock that the statement holds on its own, and so are the ElseIf and Else branches of an If and the Case branches of a Select Case. Walking Children alone therefore never gets inside any of them: a declaration, or a statement, written in one is not found. This is where the tree is walked for whoever needs to see all of it.

The bounds of a declared array (Dim a(1 To n)) are held the same way: an ArrayBoundsNode has no children, and keeps the expression of each bound in its Bounds. They are walked as what the clause is made of.

So is the variable a Next names (Next i): a For or For Each loop keeps it in its NextExpression or NextExpression, and it is walked after the statements of the loop's body, where it is written. It is a reference to the loop's control variable, which a rename rewrites and a search for references finds.

So is the array a ReDim resizes (ReDim a(1 To n)): a RedimDeclarationNode keeps it in its Target, and it is walked before the bounds, where it is written. It is a reference to the array, or the declaration of a local array it declares.

Methods

ChildNodes(SyntaxNode)

The nodes node is directly made of: its Children, the branches of a structured statement, the statements of its own blocks, the variable the Next of a loop names, the array a ReDim resizes, and the expressions of the bounds of a declared array.

public static IEnumerable<SyntaxNode> ChildNodes(this SyntaxNode node)

Parameters

node SyntaxNode

A node of the tree.

Returns

IEnumerable<SyntaxNode>

The nodes, in the order they are written.

Descendants(SyntaxNode)

Every node under node, depth first and in the order they are written, however deep in the blocks of structured statements; not the node itself.

public static IEnumerable<SyntaxNode> Descendants(this SyntaxNode node)

Parameters

node SyntaxNode

A node of the tree.

Returns

IEnumerable<SyntaxNode>

Remarks

The walk keeps its own stack of the nodes it is in: however deep the tree is, it uses no more of the caller's thread's stack than for a shallow one.

SiblingLists(SyntaxNode)

The lists of sibling nodes that node holds: its Children, and the statements of each block it holds, each a list of its own.

public static IEnumerable<IReadOnlyList<SyntaxNode>> SiblingLists(this SyntaxNode node)

Parameters

node SyntaxNode

A node of the tree.

Returns

IEnumerable<IReadOnlyList<SyntaxNode>>

Remarks

Whether one node follows another is a question about siblings: the statements of two blocks are not each other's, however they are written.