mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-08-20 10:30:34 +00:00
syntax,ssr: Implement statement parsing
This commit is contained in:
parent
354c1daedc
commit
cc081b7e1c
31 changed files with 167 additions and 0 deletions
|
@ -212,6 +212,13 @@ impl ast::Attr {
|
|||
}
|
||||
}
|
||||
|
||||
impl ast::Stmt {
|
||||
/// Returns `text`, parsed as statement, but only if it has no errors.
|
||||
pub fn parse(text: &str) -> Result<Self, ()> {
|
||||
parsing::parse_text_fragment(text, parser::FragmentKind::Statement)
|
||||
}
|
||||
}
|
||||
|
||||
/// Matches a `SyntaxNode` against an `ast` type.
|
||||
///
|
||||
/// # Example:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue