Struct rowan::SyntaxNode

source ·
pub struct SyntaxNode<T: Types> { /* private fields */ }
Expand description

Akn immutable lazy constructed syntax tree with offsets and parent pointers.

The design is close to https://github.com/apple/swift/tree/bc3189a2d265bf7728ea0cfeb55f032bfe5beaf1/lib/Syntax

All nodes constituting a tree share the ownership by a tree. Internally, and Arc is used, but outside world observes nodes as &SyntaxNode or TreeArc<SyntaxNode>, where a TreeArc is an Arc-like smart pointer.

Implementations

Creates a new SyntaxNode, whihc becomes the root of the tree.

Switch this node to owned flavor.

Get the green node for this node

Get the root node but with the children replaced. See replace_with.

Returns a green tree, equal to the green tree this node belongs two, except with this node substitute. The complexity of operation is proportional to the depth of the tree TODO: naming is unfortunate, the return value is not current node, it is the new root node.

Returns true if this node is a leaf node.

Text of this node if it is a leaf.

Get root data.

Get kind of this node.

Get text range, covered by this node.

Get the parent node.

Get first child.

Get last child.

Get next sibling.

Get previous sibling.

Get iterator over children.

All ancestors of the current node, including itself

Traverse the subtree rooted at the current node (including the current node) in preorder.

Returns common ancestor of the two nodes. Precondition: nodes must be from the same tree.

Find a leaf in the subtree corresponding to this node, which covers the offset. Precondition: offset must be withing node’s range.

Return the deepest node in the current subtree that fully contains the range. If the range is empty and is contained in two leaf nodes, either one can be returned. Precondition: range must be contained withing the current node

Trait Implementations

Formats the value using the given formatter. Read more
Formats the value using the given formatter. Read more
Feeds this value into the given Hasher. Read more
Feeds a slice of this type into the given Hasher. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
Underlying representation of a newtype.
Cast the underlying repr into a wrapper.
Cast wrapper to the underlying repr.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Converts the given value to a String. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.