pub type SyntaxNode = SyntaxNode<JsLanguage>;
Aliased Type§
pub struct SyntaxNode { /* private fields */ }
Trait Implementations§
Source§impl SyntaxNodeExt for SyntaxNode
impl SyntaxNodeExt for SyntaxNode
Source§fn tokens(&self) -> Vec<SyntaxToken> ⓘ
fn tokens(&self) -> Vec<SyntaxToken> ⓘ
Get all of the tokens of this node, recursively, including whitespace and comments.
Source§fn lossy_tokens(&self) -> Vec<SyntaxToken> ⓘ
fn lossy_tokens(&self) -> Vec<SyntaxToken> ⓘ
Get all the tokens of this node, recursively, not including whitespace and comments.
Source§fn first_lossy_token(&self) -> Option<SyntaxToken>
fn first_lossy_token(&self) -> Option<SyntaxToken>
Get the first non-whitespace child token.
Source§fn is<T: AstNode>(&self) -> bool
fn is<T: AstNode>(&self) -> bool
Check if the node is a certain AST node and that it can be casted to it.
Source§fn lexical_eq(&self, right: &SyntaxNode) -> bool
fn lexical_eq(&self, right: &SyntaxNode) -> bool
Compare two syntax nodes by comparing their underlying non-whitespace tokens. Read more
Source§fn color(&self) -> String
fn color(&self) -> String
Syntax highlight the node’s text into an ANSI string.
If stdout and stderr are not terminals, this will return the raw
node text.
Source§fn trimmed_range(&self) -> TextRange
fn trimmed_range(&self) -> TextRange
Get the text range of this node, not including any leading or trailing whitespace. Read more
Source§fn trimmed_text(&self) -> SyntaxText
fn trimmed_text(&self) -> SyntaxText
Get the text of this node, not including leading or trailing whitespace Read more
Source§fn in_ts(&self, set: TokenSet) -> bool
fn in_ts(&self, set: TokenSet) -> bool
Check whether this node’s kind is contained in a token set.
Source§fn readable_stmt_name(&self) -> String
fn readable_stmt_name(&self) -> String
Source§fn descendants_with<F>(&self, func: &mut F)
fn descendants_with<F>(&self, func: &mut F)
Go over the descendants of this node, at every descendant call
func
, and keep traversing
the descendants of that node if the function’s return is true
. If the function returns false
then stop traversing the descendants of that node go on to the next child. Read moreSource§fn structural_lossy_token_eq(&self, tokens: &[impl AsRef<str>]) -> bool
fn structural_lossy_token_eq(&self, tokens: &[impl AsRef<str>]) -> bool
Separate all the lossy tokens of this node, then compare each token’s text with the corresponding
text in
tokens
.Source§fn contains_comments(&self) -> bool
fn contains_comments(&self) -> bool
Whether the node contains any comments.
Source§fn child_with_kind(&self, kind: SyntaxKind) -> Option<SyntaxNode>
fn child_with_kind(&self, kind: SyntaxKind) -> Option<SyntaxNode>
Get the first child with a specific kind.
Source§fn expr_parent(&self) -> Option<SyntaxNode>
fn expr_parent(&self) -> Option<SyntaxNode>
Get the parent of this node, recursing through any grouping expressions
Source§fn child_with_ast<T: AstNode>(&self) -> Option<T>
fn child_with_ast<T: AstNode>(&self) -> Option<T>
Get the first child in this node that can be casted to an AST node
Source§fn descendants_with_tokens_with<F>(&self, func: &mut F)
fn descendants_with_tokens_with<F>(&self, func: &mut F)
Same as
descendants_with
but considers tokens too.Source§fn token_with_kind(&self, kind: SyntaxKind) -> Option<SyntaxToken>
fn token_with_kind(&self, kind: SyntaxKind) -> Option<SyntaxToken>
Get a specific token in the node which matches a syntax kind. Read more