mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-26 09:49:15 +00:00
internal: Migrate inline_local_variable to SyntaxEditor
This commit is contained in:
parent
62dea277cc
commit
c6ea7cbafa
2 changed files with 58 additions and 35 deletions
|
|
@ -783,6 +783,27 @@ impl SyntaxFactory {
|
|||
ast
|
||||
}
|
||||
|
||||
pub fn record_expr_field(
|
||||
&self,
|
||||
name: ast::NameRef,
|
||||
expr: Option<ast::Expr>,
|
||||
) -> ast::RecordExprField {
|
||||
let ast = make::record_expr_field(name.clone(), expr.clone()).clone_for_update();
|
||||
|
||||
if let Some(mut mapping) = self.mappings() {
|
||||
let mut builder = SyntaxMappingBuilder::new(ast.syntax().clone());
|
||||
|
||||
builder.map_node(name.syntax().clone(), ast.name_ref().unwrap().syntax().clone());
|
||||
if let Some(expr) = expr {
|
||||
builder.map_node(expr.syntax().clone(), ast.expr().unwrap().syntax().clone());
|
||||
}
|
||||
|
||||
builder.finish(&mut mapping);
|
||||
}
|
||||
|
||||
ast
|
||||
}
|
||||
|
||||
pub fn record_field_list(
|
||||
&self,
|
||||
fields: impl IntoIterator<Item = ast::RecordField>,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue