Skip to content

Commit 0075075

Browse files
committed
syntax,ssr: Implement statement parsing
1 parent 2fd670d commit 0075075

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

crates/ssr/src/parsing.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ impl ParsedRule {
7878
builder.try_add(ast::Item::parse(&raw_pattern), raw_template.map(ast::Item::parse));
7979
builder.try_add(ast::Path::parse(&raw_pattern), raw_template.map(ast::Path::parse));
8080
builder.try_add(ast::Pat::parse(&raw_pattern), raw_template.map(ast::Pat::parse));
81+
builder.try_add(ast::Stmt::parse(&raw_pattern), raw_template.map(ast::Stmt::parse));
8182
builder.build()
8283
}
8384
}

crates/syntax/src/lib.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,13 @@ impl ast::Attr {
212212
}
213213
}
214214

215+
impl ast::Stmt {
216+
/// Returns `text`, parsed as statement, but only if it has no errors.
217+
pub fn parse(text: &str) -> Result<Self, ()> {
218+
parsing::parse_text_fragment(text, parser::FragmentKind::Statement)
219+
}
220+
}
221+
215222
/// Matches a `SyntaxNode` against an `ast` type.
216223
///
217224
/// # Example:

0 commit comments

Comments
 (0)