Struct rslint_parser::Parse[][src]

pub struct Parse<T> { /* fields omitted */ }
Expand description

A utility struct for managing the result of a parser job

Implementations

Consume the parse result and get its green node. This is useful for multithreaded accesses to the tree as syntax nodes are not sync but green nodes are.

The syntax node represented by this Parse result

use rslint_parser::{parse_text, ast::IfStmt, SyntaxNodeExt, SyntaxKind, AstNode};

let parse = parse_text(
"
    if (a > 5) {
        /* something */
    }
", 0);

// The first child of the root syntax node (Script) is the if statement.
let if_stmt = parse.syntax().first_child().unwrap();

assert_eq!(if_stmt.kind(), SyntaxKind::IF_STMT);

// The if statement node is untyped, we must first cast it to a typed ast node
// to be able to get properties of it in an easy way.
assert_eq!(if_stmt.to::<IfStmt>().condition().unwrap().syntax().text(), "(a > 5)");

Get the errors which ocurred when parsing

Convert the result to an untyped SyntaxNode parse.

Convert this parse result into a typed AST node.

Panics

Panics if the node represented by this parse result mismatches.

Try to convert this parse’s untyped syntax node into an AST node.

Convert this parse into a result

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

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

Unerase this erased pointer. Read more

Whether this implementor has acknowledged the 1.1.0 update to unerase’s documented implementation requirements. Read more

Turn this erasable pointer into an erased pointer. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. 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.