In This Article

IAstNode Interface

Provides the base requirements for an AST (abstract syntax tree) node.

public interface IAstNode

Properties

Children

Gets the list containing the child AST nodes of this AST node.

IList<IAstNode> Children { get; }

Property Value

IList<IAstNode>:

The list containing the child AST nodes of this AST node.

EndOffset

Gets or sets the end offset of this AST node, if known.

int? EndOffset { get; set; }

Property Value

Nullable<Int32>:

The end offset of this AST node, if known.

HasChildren

Gets whether the AST node contains any child AST nodes.

bool HasChildren { get; }

Property Value

Boolean:

true if the AST node contains any child AST nodes; otherwise, false.

Id

Gets an integer value that identifies the type of AST node, if known.

int Id { get; }

Property Value

Int32:

An integer value that identifies the type of AST node, if known.

Length

Gets the character length of this AST node, if known.

int Length { get; }

Property Value

Int32:

The character length of this AST node, if known.

Parent

Gets or sets the parent IAstNode of this AST node, if known.

IAstNode Parent { get; set; }

Property Value

IAstNode:

The parent IAstNode of this AST node, if known.

StartOffset

Gets or sets the start offset of this AST node, if known.

int? StartOffset { get; set; }

Property Value

Nullable<Int32>:

The start offset of this AST node, if known.

Value

Gets or sets the string-based value for the AST node.

string Value { get; set; }

Property Value

String:

The string-based value for the AST node.

Methods

Contains(Int32)

Returns whether the AST node contains the specified offset.

bool Contains(int offset)
Parameter Type Description
offset Int32

The offset to examine.

Returns

Boolean:

true if the AST node contains the specified offset; otherwise, false.

Remarks

This method returns false if the offset falls on the EndOffset offset since this method indicates if the offset is encompassed by the AST node. This method also returns false if the AST node doesn't have known offsets.

FindChildNode(Int32)

Searches through the child nodes for a node that contains the specified offset.

IAstNode FindChildNode(int offset)
Parameter Type Description
offset Int32

The offset to check.

Returns

IAstNode:

The child IAstNode that contains the specified offset, if any.

FindDescendantNode(Int32)

Recursively searches through the descendant nodes for a node that contains the specified offset.

IAstNode FindDescendantNode(int offset)
Parameter Type Description
offset Int32

The offset to check.

Returns

IAstNode:

The descendant IAstNode that contains the specified offset, if any.

ToTreeString(Int32)

Outputs the contents of the AST node in tree form.

string ToTreeString(int indentLevel)
Parameter Type Description
indentLevel Int32

The indentation level.

Returns

String:

A string containing the tree form of the AST node.