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
Auto Trait Implementations
impl<T> RefUnwindSafe for Parse<T>
impl<T> UnwindSafe for Parse<T>
Blanket Implementations
Mutably borrows from an owned value. Read more
Whether this implementor has acknowledged the 1.1.0 update to
unerase
’s documented implementation requirements. Read more