mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-29 10:58:02 +00:00
refactor: editor for destructure_struct_binding
Signed-off-by: Prajwal S N <prajwalnadig21@gmail.com>
This commit is contained in:
parent
bee999863b
commit
c254537465
4 changed files with 76 additions and 99 deletions
|
|
@ -643,8 +643,8 @@ pub fn expr_method_call(
|
|||
) -> ast::Expr {
|
||||
expr_from_text(&format!("{receiver}.{method}{arg_list}"))
|
||||
}
|
||||
pub fn expr_macro_call(f: ast::Expr, arg_list: ast::ArgList) -> ast::Expr {
|
||||
expr_from_text(&format!("{f}!{arg_list}"))
|
||||
pub fn expr_macro(path: ast::Path, arg_list: ast::ArgList) -> ast::MacroExpr {
|
||||
expr_from_text(&format!("{path}!{arg_list}"))
|
||||
}
|
||||
pub fn expr_ref(expr: ast::Expr, exclusive: bool) -> ast::Expr {
|
||||
expr_from_text(&if exclusive { format!("&mut {expr}") } else { format!("&{expr}") })
|
||||
|
|
|
|||
|
|
@ -241,7 +241,7 @@ impl SyntaxFactory {
|
|||
ast
|
||||
}
|
||||
|
||||
pub fn record_pat_field(self, name_ref: ast::NameRef, pat: ast::Pat) -> ast::RecordPatField {
|
||||
pub fn record_pat_field(&self, name_ref: ast::NameRef, pat: ast::Pat) -> ast::RecordPatField {
|
||||
let ast = make::record_pat_field(name_ref.clone(), pat.clone()).clone_for_update();
|
||||
|
||||
if let Some(mut mapping) = self.mappings() {
|
||||
|
|
@ -290,6 +290,10 @@ impl SyntaxFactory {
|
|||
ast
|
||||
}
|
||||
|
||||
pub fn rest_pat(&self) -> ast::RestPat {
|
||||
make::rest_pat().clone_for_update()
|
||||
}
|
||||
|
||||
pub fn block_expr(
|
||||
&self,
|
||||
statements: impl IntoIterator<Item = ast::Stmt>,
|
||||
|
|
@ -597,6 +601,21 @@ impl SyntaxFactory {
|
|||
ast
|
||||
}
|
||||
|
||||
pub fn expr_macro(&self, path: ast::Path, args: ast::ArgList) -> ast::MacroExpr {
|
||||
let ast = make::expr_macro(path.clone(), args.clone()).clone_for_update();
|
||||
|
||||
if let Some(mut mapping) = self.mappings() {
|
||||
let macro_call = ast.macro_call().unwrap();
|
||||
let mut builder = SyntaxMappingBuilder::new(macro_call.syntax().clone());
|
||||
builder.map_node(path.syntax().clone(), macro_call.path().unwrap().syntax().clone());
|
||||
builder
|
||||
.map_node(args.syntax().clone(), macro_call.token_tree().unwrap().syntax().clone());
|
||||
builder.finish(&mut mapping);
|
||||
}
|
||||
|
||||
ast
|
||||
}
|
||||
|
||||
pub fn match_arm(
|
||||
&self,
|
||||
pat: ast::Pat,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue