mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 12:54:58 +00:00
Rerail split_import API onto AST
The code is more verbose and less efficient now, but should be reusable in add_import context as well
This commit is contained in:
parent
d75577fcee
commit
ea0c124219
3 changed files with 72 additions and 19 deletions
|
@ -259,6 +259,24 @@ impl ast::UseItem {
|
|||
}
|
||||
}
|
||||
|
||||
impl ast::UseTree {
|
||||
#[must_use]
|
||||
pub fn with_path(&self, path: ast::Path) -> ast::UseTree {
|
||||
if let Some(old) = self.path() {
|
||||
return replace_descendants(self, iter::once((old, path)));
|
||||
}
|
||||
self.clone()
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn with_use_tree_list(&self, use_tree_list: ast::UseTreeList) -> ast::UseTree {
|
||||
if let Some(old) = self.use_tree_list() {
|
||||
return replace_descendants(self, iter::once((old, use_tree_list)));
|
||||
}
|
||||
self.clone()
|
||||
}
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn strip_attrs_and_docs<N: ast::AttrsOwner>(node: &N) -> N {
|
||||
N::cast(strip_attrs_and_docs_inner(node.syntax().clone())).unwrap()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue