Skip to main content

SyntaxNode

Enum SyntaxNode 

Source
#[non_exhaustive]
pub enum SyntaxNode {
Show 66 variants Annotation { name: String, arguments_id: Option<NodeId>, }, Argument, ArgumentList, ArrayInitializer { variable_type: Option<String>, }, Assignment { variable_id: NodeId, value_id: Option<NodeId>, operator: Option<String>, }, Attribute { name: String, }, AwaitExpression { expression_id: NodeId, }, BinaryOperation { operator: String, left_id: Option<NodeId>, right_id: Option<NodeId>, }, Break, CatchClause { block_id: Option<NodeId>, catch_declaration: Option<NodeId>, }, CatchDeclaration, Class { name: String, block_id: Option<NodeId>, modifiers_id: Option<NodeId>, inherited_class: Option<String>, access_modifiers: Option<String>, }, ClassBody, Comment { comment: String, }, Continue, Declaration { name: String, block_id: Option<NodeId>, access_modifiers: Option<String>, }, DeclarationBlock, Default, DoStatement { block_id: NodeId, condition_id: NodeId, }, ElementAccess { expression_id: NodeId, arguments_id: Option<NodeId>, }, ElseClause { block_id: NodeId, }, ExecutionBlock, Export { expression: Option<String>, declaration_id: Option<NodeId>, alias: Option<String>, default_id: Option<NodeId>, }, ExpressionStatement, File, FinallyClause { block_id: Option<NodeId>, }, ForEachStatement { variable_id: NodeId, iterable_item_id: NodeId, block_id: Option<NodeId>, }, ForStatement { block_id: NodeId, initializer_id: Option<NodeId>, condition_id: Option<NodeId>, update_id: Option<NodeId>, }, If { condition_id: NodeId, true_id: Option<NodeId>, false_id: Option<NodeId>, initializer: Option<NodeId>, }, Import { expression: Option<String>, alias: Option<String>, method_name: Option<String>, import_type: Option<String>, module_name: Option<String>, }, JsxElement, LambdaFunctionType, Literal { value: String, value_type: String, }, MemberAccess { member: String, expression: String, expression_id: NodeId, symbol_scope: Option<NodeId>, }, Metadata { path: String, structure: BTreeMap<String, FileStructData>, instances: BTreeMap<String, BTreeMap<String, FileInstanceData>>, imports: Vec<String>, package: Option<String>, }, MethodDeclaration { name: Option<String>, access_modifiers: Option<String>, block_id: Option<NodeId>, modifiers_id: Option<NodeId>, parameters_id: Option<NodeId>, }, MethodInvocation { expression: String, object: Option<String>, symbol_scope: Option<NodeId>, expression_id: Option<NodeId>, arguments_id: Option<NodeId>, object_id: Option<NodeId>, block_id: Option<NodeId>, receiver_type_fqn: Option<String>, }, MissingNode { node_type: String, }, Modifiers, ModuleImport { expression: String, alias: Option<String>, module_name: Option<String>, }, NamedArgument { value_id: NodeId, argument_name: Option<String>, }, Namespace { name: String, block_id: Option<NodeId>, }, NewExpression { constructor_id: NodeId, arguments_id: Option<NodeId>, }, Object { name: Option<String>, tf_reference: Option<String>, }, ObjectCreation { name: String, arguments_id: Option<NodeId>, initializer_id: Option<NodeId>, }, Pair { key_id: NodeId, value_id: NodeId, }, Parameter { variable: Option<String>, variable_type: Option<String>, value_id: Option<NodeId>, parameter_mode: Option<String>, }, ParameterList, ParenthesizedExpression, ReservedWord { value: String, }, RestPattern { value_id: NodeId, }, Return { value_id: Option<NodeId>, }, Selector { selector_name: Option<String>, }, SpreadElement { value_id: NodeId, }, SwitchBody, SwitchSection { case_expression: String, }, SwitchStatement { block_id: NodeId, value_id: NodeId, }, SymbolLookup { symbol: String, symbol_scope: Option<NodeId>, value: Option<String>, }, TernaryOperation { condition_id: NodeId, true_id: NodeId, false_id: NodeId, }, This { value: String, }, ThrowStatement { expression_id: Option<NodeId>, }, TryStatement { block_id: NodeId, resources_id: Option<NodeId>, }, UnaryExpression { operator: String, operand_id: NodeId, }, UsingStatement { block_id: NodeId, declaration_id: Option<NodeId>, }, VariableDeclaration { variable: String, variable_type: Option<String>, value_id: Option<NodeId>, variable_id: Option<NodeId>, access_modifier: Option<String>, }, WhileStatement { block_id: NodeId, condition_id: Option<NodeId>, },
}
Expand description

A tree-sitter-independent syntax node: one variant per label the readers emit.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Annotation

A decorator/annotation applied to a declaration.

Fields

§name: String

The node’s name, as written.

§arguments_id: Option<NodeId>

Id of the argument list node, if any.

§

Argument

A single call argument.

§

ArgumentList

A call’s argument list.

§

ArrayInitializer

An array literal initializer.

Fields

§variable_type: Option<String>

The declared variable’s type, as written, if any.

§

Assignment

An assignment expression.

Fields

§variable_id: NodeId

Id of the declared variable’s node.

§value_id: Option<NodeId>

Id of the value node, if any.

§operator: Option<String>

The operator, as written, if any.

§

Attribute

An attribute applied to a declaration (non-annotation form).

Fields

§name: String

The node’s name, as written.

§

AwaitExpression

An await expression.

Fields

§expression_id: NodeId

Id of the expression node.

§

BinaryOperation

A binary operator expression.

Fields

§operator: String

The operator, as written.

§left_id: Option<NodeId>

Id of the left-hand operand node, if any.

§right_id: Option<NodeId>

Id of the right-hand operand node, if any.

§

Break

A break statement.

§

CatchClause

A catch clause of a try statement.

Fields

§block_id: Option<NodeId>

Id of the node’s body block, if any.

§catch_declaration: Option<NodeId>

Id of the exception variable declaration, if any.

§

CatchDeclaration

The exception variable declared by a catch clause.

§

Class

A class declaration.

Fields

§name: String

The node’s name, as written.

§block_id: Option<NodeId>

Id of the node’s body block, if any.

§modifiers_id: Option<NodeId>

Id of the modifiers node, if any.

§inherited_class: Option<String>

The name of the class this one extends, if any.

§access_modifiers: Option<String>

The access modifier keywords, as written, if any.

§

ClassBody

A class’s member list.

§

Comment

A source comment.

Fields

§comment: String

The comment text, including its delimiters.

§

Continue

A continue statement.

§

Declaration

A generic (language-agnostic) declaration.

Fields

§name: String

The node’s name, as written.

§block_id: Option<NodeId>

Id of the node’s body block, if any.

§access_modifiers: Option<String>

The access modifier keywords, as written, if any.

§

DeclarationBlock

A block holding one or more declarations.

§

Default

A default label or value.

§

DoStatement

A do/while loop.

Fields

§block_id: NodeId

Id of the node’s body block.

§condition_id: NodeId

Id of the condition expression node.

§

ElementAccess

An indexed element access (e.g. a[i]).

Fields

§expression_id: NodeId

Id of the expression node.

§arguments_id: Option<NodeId>

Id of the argument list node, if any.

§

ElseClause

The else branch of a conditional.

Fields

§block_id: NodeId

Id of the node’s body block.

§

ExecutionBlock

A block of executable statements.

§

Export

An export statement.

Fields

§expression: Option<String>

The expression, as written, if any.

§declaration_id: Option<NodeId>

Id of the declaration node, if any.

§alias: Option<String>

The bound local alias, if any.

§default_id: Option<NodeId>

Id of the default export’s declaration node, if any.

§

ExpressionStatement

A statement that is a bare expression.

§

File

The file’s root node.

§

FinallyClause

The finally clause of a try statement.

Fields

§block_id: Option<NodeId>

Id of the node’s body block, if any.

§

ForEachStatement

A for-each/for-in loop.

Fields

§variable_id: NodeId

Id of the declared variable’s node.

§iterable_item_id: NodeId

Id of the collection being iterated.

§block_id: Option<NodeId>

Id of the node’s body block, if any.

§

ForStatement

A classic C-style for loop.

Fields

§block_id: NodeId

Id of the node’s body block.

§initializer_id: Option<NodeId>

Id of the loop’s initializer node, if any.

§condition_id: Option<NodeId>

Id of the condition expression node, if any.

§update_id: Option<NodeId>

Id of the loop’s update node, if any.

§

If

An if conditional.

Fields

§condition_id: NodeId

Id of the condition expression node.

§true_id: Option<NodeId>

Id of the branch taken when the condition is true, if any.

§false_id: Option<NodeId>

Id of the branch taken when the condition is false, if any.

§initializer: Option<NodeId>

Id of the condition’s initializer node (e.g. an if let binding), if any.

§

Import

An import statement.

Fields

§expression: Option<String>

The expression, as written, if any.

§alias: Option<String>

The bound local alias, if any.

§method_name: Option<String>

The imported method’s name, if any.

§import_type: Option<String>

The import’s kind keyword (e.g. type), if any.

§module_name: Option<String>

The imported module’s name, if any.

§

JsxElement

A JSX element.

§

LambdaFunctionType

A lambda/closure’s declared type.

§

Literal

A literal value.

Fields

§value: String

The literal value, as written.

§value_type: String

The literal’s type keyword.

§

MemberAccess

A member access expression (e.g. a.b).

Fields

§member: String

The accessed member’s name.

§expression: String

The expression, as written.

§expression_id: NodeId

Id of the expression node.

§symbol_scope: Option<NodeId>

Id of the node that scopes this symbol lookup, if any.

§

Metadata

A file’s top-level metadata: structure, instances and imports.

Fields

§path: String

The file’s path.

§structure: BTreeMap<String, FileStructData>

The file’s top-level members, keyed by name.

§instances: BTreeMap<String, BTreeMap<String, FileInstanceData>>

Per-object metadata instances, keyed by qualified name.

§imports: Vec<String>

The names this file imports.

§package: Option<String>

The file’s package/namespace name, if any.

§

MethodDeclaration

A method or function declaration.

Fields

§name: Option<String>

The node’s name, as written, if any.

§access_modifiers: Option<String>

The access modifier keywords, as written, if any.

§block_id: Option<NodeId>

Id of the node’s body block, if any.

§modifiers_id: Option<NodeId>

Id of the modifiers node, if any.

§parameters_id: Option<NodeId>

Id of the parameter list node, if any.

§

MethodInvocation

A method or function call.

Fields

§expression: String

The expression, as written.

§object: Option<String>

The receiver’s textual expression, if any.

§symbol_scope: Option<NodeId>

Id of the node that scopes this symbol lookup, if any.

§expression_id: Option<NodeId>

Id of the expression node, if any.

§arguments_id: Option<NodeId>

Id of the argument list node, if any.

§object_id: Option<NodeId>

Id of the receiver node, if any.

§block_id: Option<NodeId>

Id of the node’s body block, if any.

§receiver_type_fqn: Option<String>

The receiver’s fully qualified type name, when resolved, if any.

§

MissingNode

A node the grammar could not classify.

Fields

§node_type: String

The original (unmapped) tree-sitter node type.

§

Modifiers

A declaration’s modifier list (e.g. public static).

§

ModuleImport

A whole-module import.

Fields

§expression: String

The expression, as written.

§alias: Option<String>

The bound local alias, if any.

§module_name: Option<String>

The imported module’s name, if any.

§

NamedArgument

A call argument passed by name.

Fields

§value_id: NodeId

Id of the value node.

§argument_name: Option<String>

The named argument’s parameter name, if any.

§

Namespace

A namespace/module declaration.

Fields

§name: String

The node’s name, as written.

§block_id: Option<NodeId>

Id of the node’s body block, if any.

§

NewExpression

An object-construction expression (new X(...)).

Fields

§constructor_id: NodeId

Id of the constructor being invoked.

§arguments_id: Option<NodeId>

Id of the argument list node, if any.

§

Object

An object literal or reference (e.g. a Terraform resource block).

Fields

§name: Option<String>

The node’s name, as written, if any.

§tf_reference: Option<String>

The Terraform block’s reference expression, if any.

§

ObjectCreation

An object instantiation with an initializer.

Fields

§name: String

The node’s name, as written.

§arguments_id: Option<NodeId>

Id of the argument list node, if any.

§initializer_id: Option<NodeId>

Id of the loop’s initializer node, if any.

§

Pair

A key/value pair (e.g. in a map or object literal).

Fields

§key_id: NodeId

Id of the pair’s key node.

§value_id: NodeId

Id of the value node.

§

Parameter

A function/method parameter.

Fields

§variable: Option<String>

The declared variable’s name, if any.

§variable_type: Option<String>

The declared variable’s type, as written, if any.

§value_id: Option<NodeId>

Id of the value node, if any.

§parameter_mode: Option<String>

The parameter’s passing mode keyword (e.g. ref), if any.

§

ParameterList

A function/method’s parameter list.

§

ParenthesizedExpression

A parenthesized expression.

§

ReservedWord

A language reserved word used as a value (e.g. self).

Fields

§value: String

The literal value, as written.

§

RestPattern

A rest/spread binding pattern (e.g. ...rest).

Fields

§value_id: NodeId

Id of the value node.

§

Return

A return statement.

Fields

§value_id: Option<NodeId>

Id of the value node, if any.

§

Selector

A Go-style type selector.

Fields

§selector_name: Option<String>

The selector’s name, if any.

§

SpreadElement

A spread element in a call or literal (e.g. ...xs).

Fields

§value_id: NodeId

Id of the value node.

§

SwitchBody

A switch statement’s body.

§

SwitchSection

One case/when section of a switch.

Fields

§case_expression: String

The case label’s expression, as written.

§

SwitchStatement

A switch statement.

Fields

§block_id: NodeId

Id of the node’s body block.

§value_id: NodeId

Id of the value node.

§

SymbolLookup

A bare symbol reference.

Fields

§symbol: String

The looked-up symbol’s name.

§symbol_scope: Option<NodeId>

Id of the node that scopes this symbol lookup, if any.

§value: Option<String>

The literal value, as written, if any.

§

TernaryOperation

A ternary conditional expression (a ? b : c).

Fields

§condition_id: NodeId

Id of the condition expression node.

§true_id: NodeId

Id of the branch taken when the condition is true.

§false_id: NodeId

Id of the branch taken when the condition is false.

§

This

A this/self reference.

Fields

§value: String

The literal value, as written.

§

ThrowStatement

A throw/raise statement.

Fields

§expression_id: Option<NodeId>

Id of the expression node, if any.

§

TryStatement

A try statement.

Fields

§block_id: NodeId

Id of the node’s body block.

§resources_id: Option<NodeId>

Id of the try-with-resources declaration node, if any.

§

UnaryExpression

A unary operator expression.

Fields

§operator: String

The operator, as written.

§operand_id: NodeId

Id of the operand node.

§

UsingStatement

A using/with resource-scoped statement.

Fields

§block_id: NodeId

Id of the node’s body block.

§declaration_id: Option<NodeId>

Id of the declaration node, if any.

§

VariableDeclaration

A variable declaration.

Fields

§variable: String

The declared variable’s name.

§variable_type: Option<String>

The declared variable’s type, as written, if any.

§value_id: Option<NodeId>

Id of the value node, if any.

§variable_id: Option<NodeId>

Id of the declared variable’s node, if any.

§access_modifier: Option<String>

The access modifier keyword, if any.

§

WhileStatement

A while loop.

Fields

§block_id: NodeId

Id of the node’s body block.

§condition_id: Option<NodeId>

Id of the condition expression node, if any.

Implementations§

Source§

impl SyntaxNode

Source

pub const fn arguments_id(&self) -> Option<NodeId>

Id of this node’s argument list, for variants that take one.

Source

pub const fn block_id(&self) -> Option<NodeId>

Id of this node’s body block, for variants that have one.

Source

pub fn name(&self) -> Option<&str>

This node’s declared name, for variants that are named.

Source

pub fn variable(&self) -> Option<&str>

The declared variable’s name, for variants that declare one.

Source

pub const fn symbol(&self) -> Option<&str>

The looked-up symbol’s name, for Self::SymbolLookup.

Source

pub fn expression(&self) -> Option<&str>

This node’s expression text, for variants that carry one.

Source

pub fn alias(&self) -> Option<&str>

The bound local alias, for import/export variants that have one.

Source

pub fn value(&self) -> Option<&str>

This node’s literal value, as written, for variants that have one.

Source

pub const fn object_id(&self) -> Option<NodeId>

Id of the call receiver node, for Self::MethodInvocation.

Source

pub const fn value_id(&self) -> Option<NodeId>

Id of this node’s value node, for variants that carry one.

Source

pub const fn variable_id(&self) -> Option<NodeId>

Id of the declared variable’s node, for variants that declare one.

Source

pub fn label_type(&self) -> &'static str

This node’s syntax-kind label, e.g. "MethodDeclaration".

Trait Implementations§

Source§

impl Clone for SyntaxNode

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SyntaxNode

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for SyntaxNode

Source§

impl<'_enum> From<&'_enum SyntaxNode> for SyntaxKind

Source§

fn from(val: &'_enum SyntaxNode) -> SyntaxKind

Converts to this type from the input type.
Source§

impl From<SyntaxNode> for SyntaxKind

Source§

fn from(val: SyntaxNode) -> SyntaxKind

Converts to this type from the input type.
Source§

impl IntoDiscriminant for SyntaxNode

Source§

type Discriminant = SyntaxKind

Enum listing the same variants as this enum but without any data fields
Source§

fn discriminant(&self) -> Self::Discriminant

Source§

impl PartialEq for SyntaxNode

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for SyntaxNode

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.