Skip to main content

Node

Enum Node 

Source
pub enum Node {
Show 71 variants Program { body: List, source_type: SourceType, }, Expression { expression: NodeId, directive: bool, }, Block { body: List, }, Empty, Debugger, With { object: NodeId, body: NodeId, }, Return { argument: Option<NodeId>, }, Labeled { label: NodeId, body: NodeId, }, Break { label: Option<NodeId>, }, Continue { label: Option<NodeId>, }, If { test: NodeId, consequent: NodeId, alternate: Option<NodeId>, }, Switch { discriminant: NodeId, cases: List, }, SwitchCase { test: Option<NodeId>, consequent: List, }, Throw { argument: NodeId, }, Try { block: NodeId, handler: Option<NodeId>, finalizer: Option<NodeId>, }, CatchClause { param: Option<NodeId>, body: NodeId, }, While { test: NodeId, body: NodeId, }, DoWhile { body: NodeId, test: NodeId, }, For { init: Option<NodeId>, test: Option<NodeId>, update: Option<NodeId>, body: NodeId, }, ForIn { left: NodeId, right: NodeId, body: NodeId, }, ForOf { left: NodeId, right: NodeId, body: NodeId, is_await: bool, }, VariableDeclaration { kind: VarKind, declarations: List, }, VariableDeclarator { id: NodeId, init: Option<NodeId>, }, Function(Function), Class(Class), ClassBody { body: List, }, Method { key: NodeId, value: NodeId, kind: MethodKind, computed: bool, is_static: bool, }, Field { key: NodeId, value: Option<NodeId>, computed: bool, is_static: bool, }, StaticBlock { body: List, }, Identifier, PrivateIdentifier, Literal(LiteralKind), This, Super, Array { elements: List, comma_after_spread: bool, }, Elision, Object { properties: List, comma_after_spread: bool, }, Property { key: NodeId, value: NodeId, kind: PropertyKind, method: bool, shorthand: bool, computed: bool, }, Template { quasis: List, expressions: List, }, TemplateElement { tail: bool, cooked: bool, }, TaggedTemplate { tag: NodeId, quasi: NodeId, }, Unary { operator: UnaryOp, argument: NodeId, }, Update { operator: UpdateOp, prefix: bool, argument: NodeId, }, Binary { operator: BinaryOp, left: NodeId, right: NodeId, }, Logical { operator: LogicalOp, left: NodeId, right: NodeId, }, Assign { operator: AssignOp, left: NodeId, right: NodeId, }, Conditional { test: NodeId, consequent: NodeId, alternate: NodeId, }, Call { callee: NodeId, arguments: List, optional: bool, }, New { callee: NodeId, arguments: List, }, Member { object: NodeId, property: NodeId, computed: bool, optional: bool, }, Chain { expression: NodeId, }, Sequence { expressions: List, }, Yield { argument: Option<NodeId>, delegate: bool, }, Await { argument: NodeId, }, Spread { argument: NodeId, }, MetaProperty { meta: NodeId, property: NodeId, }, Import { source: NodeId, options: Option<NodeId>, }, Paren { expression: NodeId, }, ImportDeclaration { specifiers: List, source: NodeId, attributes: List, }, ImportSpecifier { imported: NodeId, local: NodeId, }, ImportDefaultSpecifier { local: NodeId, }, ImportNamespaceSpecifier { local: NodeId, }, ImportAttribute { key: NodeId, value: NodeId, }, ExportNamed { declaration: Option<NodeId>, specifiers: List, source: Option<NodeId>, attributes: List, }, ExportSpecifier { local: NodeId, exported: NodeId, }, ExportDefault { declaration: NodeId, }, ExportAll { exported: Option<NodeId>, source: NodeId, attributes: List, }, ObjectPattern { properties: List, }, ArrayPattern { elements: List, }, Rest { argument: NodeId, }, AssignmentPattern { left: NodeId, right: NodeId, },
}
Expand description

A node. The variants are ESTree’s node types, named without their Statement and Expression suffixes where those are plain.

Variants§

§

Program

The whole source. Its span is the whole input.

Fields

§body: List
§source_type: SourceType
§

Expression

An expression as a statement; directive when it’s a string in a directive prologue, like "use strict".

Fields

§expression: NodeId
§directive: bool
§

Block

Fields

§body: List
§

Empty

§

Debugger

§

With

Fields

§object: NodeId
§body: NodeId
§

Return

Fields

§argument: Option<NodeId>
§

Labeled

Fields

§label: NodeId
§body: NodeId
§

Break

Fields

§

Continue

Fields

§

If

Fields

§test: NodeId
§consequent: NodeId
§alternate: Option<NodeId>
§

Switch

Fields

§discriminant: NodeId
§cases: List
§

SwitchCase

Fields

§consequent: List
§

Throw

Fields

§argument: NodeId
§

Try

Fields

§block: NodeId
§handler: Option<NodeId>
§finalizer: Option<NodeId>
§

CatchClause

Fields

§body: NodeId
§

While

Fields

§test: NodeId
§body: NodeId
§

DoWhile

Fields

§body: NodeId
§test: NodeId
§

For

Fields

§update: Option<NodeId>
§body: NodeId
§

ForIn

Fields

§left: NodeId
§right: NodeId
§body: NodeId
§

ForOf

Fields

§left: NodeId
§right: NodeId
§body: NodeId
§is_await: bool
§

VariableDeclaration

Fields

§kind: VarKind
§declarations: List
§

VariableDeclarator

Fields

§

Function(Function)

§

Class(Class)

§

ClassBody

Fields

§body: List
§

Method

A class method; value is its function.

Fields

§value: NodeId
§computed: bool
§is_static: bool
§

Field

A class field, ESTree’s PropertyDefinition.

Fields

§computed: bool
§is_static: bool
§

StaticBlock

Fields

§body: List
§

Identifier

§

PrivateIdentifier

#name; the span includes the #.

§

Literal(LiteralKind)

§

This

§

Super

§

Array

elements has a Node::Elision for each hole.

Fields

§elements: List
§comma_after_spread: bool
§

Elision

A hole in an array: the nothing between [, and ,].

§

Object

Fields

§properties: List
§comma_after_spread: bool
§

Property

An object literal’s or object pattern’s property.

Fields

§value: NodeId
§method: bool
§shorthand: bool
§computed: bool
§

Template

Fields

§quasis: List
§expressions: List
§

TemplateElement

A template’s text between delimiters; the span leaves the delimiters out, as acorn’s does. cooked is false for a tagged template’s invalid escape, whose cooked value is undefined.

Fields

§tail: bool
§cooked: bool
§

TaggedTemplate

Fields

§quasi: NodeId
§

Unary

Fields

§operator: UnaryOp
§argument: NodeId
§

Update

Fields

§operator: UpdateOp
§prefix: bool
§argument: NodeId
§

Binary

Fields

§operator: BinaryOp
§left: NodeId
§right: NodeId
§

Logical

Fields

§operator: LogicalOp
§left: NodeId
§right: NodeId
§

Assign

Fields

§operator: AssignOp
§left: NodeId
§right: NodeId
§

Conditional

Fields

§test: NodeId
§consequent: NodeId
§alternate: NodeId
§

Call

Fields

§callee: NodeId
§arguments: List
§optional: bool
§

New

Fields

§callee: NodeId
§arguments: List
§

Member

Fields

§object: NodeId
§property: NodeId
§computed: bool
§optional: bool
§

Chain

An optional chain, a?.b.c, from its start to its end.

Fields

§expression: NodeId
§

Sequence

Fields

§expressions: List
§

Yield

Fields

§argument: Option<NodeId>
§delegate: bool
§

Await

Fields

§argument: NodeId
§

Spread

Fields

§argument: NodeId
§

MetaProperty

new.target or import.meta.

Fields

§meta: NodeId
§property: NodeId
§

Import

import(source) or import(source, options).

Fields

§source: NodeId
§options: Option<NodeId>
§

Paren

A parenthesized expression. ESTree has no such node, and Ast::to_estree writes the expression inside instead.

Fields

§expression: NodeId
§

ImportDeclaration

import ... from "source" with { ... }; attributes are Node::ImportAttributes.

Fields

§specifiers: List
§source: NodeId
§attributes: List
§

ImportSpecifier

imported as local, or one name as both; imported may be a string literal.

Fields

§imported: NodeId
§local: NodeId
§

ImportDefaultSpecifier

Fields

§local: NodeId
§

ImportNamespaceSpecifier

* as local.

Fields

§local: NodeId
§

ImportAttribute

type: "json" in a with clause.

Fields

§value: NodeId
§

ExportNamed

export with a declaration, or with { ... } and maybe a source.

Fields

§declaration: Option<NodeId>
§specifiers: List
§source: Option<NodeId>
§attributes: List
§

ExportSpecifier

local as exported, or one name as both; either may be a string literal.

Fields

§local: NodeId
§exported: NodeId
§

ExportDefault

export default, with a declaration or an expression.

Fields

§declaration: NodeId
§

ExportAll

export * from "source", or export * as exported from ....

Fields

§exported: Option<NodeId>
§source: NodeId
§attributes: List
§

ObjectPattern

Fields

§properties: List
§

ArrayPattern

Fields

§elements: List
§

Rest

Fields

§argument: NodeId
§

AssignmentPattern

Fields

§left: NodeId
§right: NodeId

Trait Implementations§

Source§

impl Clone for Node

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 Copy for Node

Source§

impl Debug for Node

Source§

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

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

impl Eq for Node

Source§

impl Hash for Node

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Node

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 Node

Auto Trait Implementations§

§

impl Forget for Node

§

impl Freeze for Node

§

impl Move for Node

§

impl RefUnwindSafe for Node

§

impl Send for Node

§

impl Sync for Node

§

impl Unpin for Node

§

impl UnsafeUnpin for Node

§

impl UnwindSafe for Node

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.