mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 21:13:37 +00:00
minor: Add expr_bin
constructor to SyntaxFactory
This commit is contained in:
parent
6406048626
commit
fbb392062a
1 changed files with 17 additions and 0 deletions
|
@ -80,6 +80,23 @@ impl SyntaxFactory {
|
|||
ast
|
||||
}
|
||||
|
||||
pub fn expr_bin(&self, lhs: ast::Expr, op: ast::BinaryOp, rhs: ast::Expr) -> ast::BinExpr {
|
||||
let ast::Expr::BinExpr(ast) =
|
||||
make::expr_bin_op(lhs.clone(), op, rhs.clone()).clone_for_update()
|
||||
else {
|
||||
unreachable!()
|
||||
};
|
||||
|
||||
if let Some(mut mapping) = self.mappings() {
|
||||
let mut builder = SyntaxMappingBuilder::new(ast.syntax().clone());
|
||||
builder.map_node(lhs.syntax().clone(), ast.lhs().unwrap().syntax().clone());
|
||||
builder.map_node(rhs.syntax().clone(), ast.rhs().unwrap().syntax().clone());
|
||||
builder.finish(&mut mapping);
|
||||
}
|
||||
|
||||
ast
|
||||
}
|
||||
|
||||
pub fn expr_path(&self, path: ast::Path) -> ast::Expr {
|
||||
let ast::Expr::PathExpr(ast) = make::expr_path(path.clone()).clone_for_update() else {
|
||||
unreachable!()
|
||||
|
|
Loading…
Reference in a new issue