add SyntaxFactory::record_expr to hide clone_for_update

This commit is contained in:
Hmikihiro 2025-07-29 20:59:50 +09:00
parent 475ebb8fef
commit ec02abf97a
2 changed files with 30 additions and 8 deletions

View file

@ -939,6 +939,24 @@ impl SyntaxFactory {
ast
}
pub fn record_expr(
&self,
path: ast::Path,
fields: ast::RecordExprFieldList,
) -> ast::RecordExpr {
let ast = make::record_expr(path.clone(), fields.clone()).clone_for_update();
if let Some(mut mapping) = self.mappings() {
let mut builder = SyntaxMappingBuilder::new(ast.syntax().clone());
builder.map_node(path.syntax().clone(), ast.path().unwrap().syntax().clone());
builder.map_node(
fields.syntax().clone(),
ast.record_expr_field_list().unwrap().syntax().clone(),
);
builder.finish(&mut mapping);
}
ast
}
pub fn record_expr_field(
&self,
name: ast::NameRef,