[−][src]Struct rslint_parser::Parse
A utility struct for managing the result of a parser job
Implementations
impl<T> Parse<T>
[src]
pub fn new(green: GreenNode, errors: Vec<ParserError>) -> Parse<T>
[src]
pub fn green(self) -> GreenNode
[src]
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.
pub fn syntax(&self) -> SyntaxNode
[src]
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)");
pub fn errors(&self) -> &[ParserError]
[src]
Get the errors which ocurred when parsing
impl<T: AstNode> Parse<T>
[src]
pub fn to_syntax(self) -> Parse<SyntaxNode>
[src]
Convert the result to an untyped SyntaxNode parse.
pub fn tree(&self) -> T
[src]
Convert this parse result into a typed AST node.
Panics
Panics if the node represented by this parse result mismatches.
pub fn try_tree(&self) -> Option<T>
[src]
Try to convert this parse's untyped syntax node into an AST node.
pub fn ok(self) -> Result<T, Vec<ParserError>>
[src]
Convert this parse into a result
Trait Implementations
Auto Trait Implementations
impl<T> RefUnwindSafe for Parse<T>
impl<T> Send for Parse<T>
impl<T> Sync for Parse<T>
impl<T> Unpin for Parse<T>
impl<T> UnwindSafe for Parse<T>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Erasable for T
unsafe fn unerase(this: NonNull<Erased>) -> NonNull<T>
const ACK_1_1_0: bool
fn erase(this: NonNull<Self>) -> NonNull<Erased>
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,