Merge commit 'a911652360' into sync-from-ra

This commit is contained in:
Laurențiu Nicola 2024-01-21 16:53:06 +02:00
parent 0661390ad4
commit e4866b6ddb
315 changed files with 7088 additions and 4415 deletions

View file

@ -1,6 +1,6 @@
//! Structural editing for ast.
use std::iter::{empty, successors};
use std::iter::{empty, once, successors};
use parser::{SyntaxKind, T};
@ -530,6 +530,25 @@ impl ast::UseTree {
Some(())
}
}
/// Wraps the use tree in use tree list with no top level path (if it isn't already).
///
/// # Examples
///
/// `foo::bar` -> `{foo::bar}`
///
/// `{foo::bar}` -> `{foo::bar}`
pub fn wrap_in_tree_list(&self) {
if self.path().is_none() {
return;
}
let subtree = self.clone_subtree().clone_for_update();
ted::remove_all_iter(self.syntax().children_with_tokens());
ted::append_child(
self.syntax(),
make::use_tree_list(once(subtree)).clone_for_update().syntax(),
);
}
}
impl ast::UseTreeList {