MrKWatkins.Ast Help

Node<TNode> Class

Definition

Abstract base class for nodes in a tree.

public abstract class Node<TNode> where TNode : Node<TNode>

Type Parameters

Name

Description

TNode

Self generic node parameter.

Constructors

Name

Description

Node()

Initialises a new instance of the Node<TNode> class.

Node(IEnumerable<TNode>)

Initialises a new instance of the Node<TNode> class with the specified children.

Properties

Name

Description

Ancestors

Lazily enumerates over the ancestors of this node, i.e. the Parent, grandparent, great-grandparent and so on up to the root node.

Children

The children of this node.

Descendents

Enumerates all descendents of this node in depth first pre-order.

Errors

The Messages with Level Error associated with this node.

HasChildren

Returns true if this node has any Children, false otherwise.

HasErrors

Returns true if this node has any Messages with Level Error, false otherwise.

HasInfos

Returns true if this node has any Messages with Level Info, false otherwise.

HasMessages

Returns true if this node has any Messages, false otherwise.

HasNextSibling

Returns true if this node has a NextSibling, false otherwise.

HasParent

Returns true if this node has a Parent, false otherwise. Nodes will not have parents if they are the root node, or they have just been constructed and not yet added to a parent.

HasPreviousSibling

Returns true if this node has a PreviousSibling, false otherwise.

HasWarnings

Returns true if this node has any Messages with Level Warning, false otherwise.

IndexInParent

The index of this node in the Parent or -1 if this node has no Parent.

Infos

The Messages with Level Info associated with this node.

IsFirstChild

true if this node is the first child in Parent, false if not or if the node has no Parent.

IsLastChild

true if this node is the last child in Parent, false if not or if the node has no Parent.

Messages

The Messages associated with this node.

NextSibling

The next sibling, i.e. the child from the same Parent at the next positional index. Returns null if this node is the last child.

NextSiblings

Lazily enumerates over the next siblings, i.e. the children from the same Parent at subsequent positional indices in ascending index order.

Parent

The parent of this node.

PreviousSibling

The previous sibling, i.e. the child from the same Parent at the previous positional index. Returns null if this node is the first child.

PreviousSiblings

Lazily enumerates over the previous siblings, i.e. the children from the same Parent at precedent positional indices in descending index order.

Root

The root node, i.e. the highest parent above this node. Returns this node if it is the root, i.e. it has no parents.

SourcePosition

The position of the node in the source code.

ThisAndAncestors

Lazily enumerates over this node and its Ancestors, i.e. this node, the Parent, grandparent, great-grandparent and so on up to the root node.

ThisAndDescendents

Enumerates this node then all descendents of this node in depth first pre-order.

ThisAndDescendentsHaveErrors

Returns true if this node or any of its descendents have any Messages with Level Error, false otherwise.

ThisAndDescendentsHaveInfos

Returns true if this node or any of its descendents have any Messages with Level Info, false otherwise.

ThisAndDescendentsHaveMessages

Returns true if this node or any of its descendents have any Messages, false otherwise.

ThisAndDescendentsHaveWarnings

Returns true if this node or any of its descendents have any Messages with Level Warning, false otherwise.

ThisAndDescendentsWithErrors

Lazily enumerates over this node and its descendents returning only those that have Messages with Level Error.

ThisAndDescendentsWithInfos

Lazily enumerates over this node and its descendents returning only those that have Messages with Level Info.

ThisAndDescendentsWithMessages

Lazily enumerates over this node and its descendents returning only those that have Messages.

ThisAndDescendentsWithWarnings

Lazily enumerates over this node and its descendents returning only those that have Messages with Level Warning.

ThisAndNextSiblings

Lazily enumerates over this node then the next siblings, i.e. the children from the same Parent at subsequent positional indices in ascending index order.

ThisAndPreviousSiblings

Lazily enumerates over this node then the previous siblings, i.e. the children from the same Parent at precedent positional indices in descending index order.

Warnings

The Messages with Level Warning associated with this node.

Methods

Name

Description

AddError(String)

Adds a Message with Level Error and the specified text to this node.

AddError(String, String)

Adds a Message with Level Error and the specified text to this node.

AddInfo(String)

Adds a Message with Level Info and the specified text to this node.

AddInfo(String, String)

Adds a Message with Level Info and the specified text to this node.

AddMessage(Message)

Adds a Message to this node.

AddMessage(MessageLevel, String)

Adds a Message with the specified Level and Text to this node.

AddMessage(MessageLevel, String, String)

Adds a Message with the specified Level, Code and Text to this node.

AddNextSibling(TNode)

Adds the specified node as the NextSibling to this node. Existing next siblings will be moved on index to the right to accommodate.

AddPreviousSibling(TNode)

Adds the specified node as the PreviousSibling to this node. This and any next siblings will be moved one index to the right to accommodate.

AddWarning(String)

Adds a Message with Level Warning and the specified text to this node.

AddWarning(String, String)

Adds a Message with Level Warning and the specified text to this node.

AncestorsOfType<TAncestor>()

Lazily enumerates over this node and its Ancestors, returning only ancestors of the specified type.

MoveTo(TNode)

Moves this node to a new parent.

RemoveFromParent()

Removes this node from its Parent.

RemoveNextSibling()

Removes the NextSibling from Parent if it exists.

RemovePreviousSibling()

Removes the PreviousSibling from Parent if it exists.

ReplaceWith(Node<TNode>)

Removes this node from it's parent and puts another node in its place.

ThisAnd(IEnumerable<TNode>)

Lazily enumerates over this node and then the specified enumeration of nodes.

ThisAndAncestorsOfType<TAncestor>()

Lazily enumerates over the Ancestors of this node, returning only ancestors of the specified type.

ToString()

Returns a string that represents the current node. Defaults to the name of the type of the node.

Last modified: 22 November 2024