SyntaxNode

Trait SyntaxNode 

Source
pub trait SyntaxNode {
    // Provided methods
    fn span(&self) -> Option<Span> { ... }
    fn ident(&self) -> Option<Ident> { ... }
    fn attributes(&self) -> &[AttributeNode]  { ... }
    fn attributes_mut(&mut self) -> &mut [AttributeNode]  { ... }
    fn contains_attribute(&self, attribute: &Attribute) -> bool { ... }
    fn retain_attributes_mut<F>(&mut self, _predicate: F)
       where F: FnMut(&mut Attribute) -> bool { ... }
}
Expand description

Trait implemented for all syntax node types.

This trait is useful for generic implementations over different syntax node types. Node types that do not have a span, an ident, or attributes return None.

Provided Methods§

Source

fn span(&self) -> Option<Span>

Span of a syntax node.

Source

fn ident(&self) -> Option<Ident>

Identifier, if the syntax node is a declaration.

Source

fn attributes(&self) -> &[AttributeNode]

List all attributes of a syntax node.

Source

fn attributes_mut(&mut self) -> &mut [AttributeNode]

List all attributes of a syntax node.

Source

fn contains_attribute(&self, attribute: &Attribute) -> bool

Whether the node contains an attribute.

Source

fn retain_attributes_mut<F>(&mut self, _predicate: F)
where F: FnMut(&mut Attribute) -> bool,

Remove attributes with predicate.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl SyntaxNode for Expression

Source§

impl SyntaxNode for GlobalDeclaration

Source§

impl SyntaxNode for GlobalDirective

Source§

impl SyntaxNode for LiteralExpression

Source§

impl SyntaxNode for Statement

Source§

impl SyntaxNode for AssignmentStatement

Source§

impl SyntaxNode for BinaryExpression

Source§

impl SyntaxNode for BreakIfStatement

Source§

impl SyntaxNode for BreakStatement

Source§

impl SyntaxNode for CompoundStatement

Source§

impl SyntaxNode for ConstAssert

Source§

impl SyntaxNode for ContinueStatement

Source§

impl SyntaxNode for ContinuingStatement

Source§

impl SyntaxNode for Declaration

Source§

impl SyntaxNode for DecrementStatement

Source§

impl SyntaxNode for DiagnosticDirective

Source§

impl SyntaxNode for DiscardStatement

Source§

impl SyntaxNode for ElseClause

Source§

impl SyntaxNode for ElseIfClause

Source§

impl SyntaxNode for EnableDirective

Source§

impl SyntaxNode for ForStatement

Source§

impl SyntaxNode for FormalParameter

Source§

impl SyntaxNode for Function

Source§

impl SyntaxNode for FunctionCall

Source§

impl SyntaxNode for FunctionCallStatement

Source§

impl SyntaxNode for IfClause

Source§

impl SyntaxNode for IfStatement

Source§

impl SyntaxNode for IncrementStatement

Source§

impl SyntaxNode for IndexingExpression

Source§

impl SyntaxNode for LoopStatement

Source§

impl SyntaxNode for NamedComponentExpression

Source§

impl SyntaxNode for ParenthesizedExpression

Source§

impl SyntaxNode for RequiresDirective

Source§

impl SyntaxNode for ReturnStatement

Source§

impl SyntaxNode for Struct

Source§

impl SyntaxNode for StructMember

Source§

impl SyntaxNode for SwitchClause

Source§

impl SyntaxNode for SwitchStatement

Source§

impl SyntaxNode for TypeAlias

Source§

impl SyntaxNode for TypeExpression

Source§

impl SyntaxNode for UnaryExpression

Source§

impl SyntaxNode for WhileStatement

Source§

impl<T: SyntaxNode> SyntaxNode for Spanned<T>