Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide-db/src/source_change.rs')
-rw-r--r--crates/ide-db/src/source_change.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/crates/ide-db/src/source_change.rs b/crates/ide-db/src/source_change.rs
index b1b58d6568..16c0d8d97a 100644
--- a/crates/ide-db/src/source_change.rs
+++ b/crates/ide-db/src/source_change.rs
@@ -5,6 +5,7 @@
use std::{collections::hash_map::Entry, fmt, iter, mem};
+use crate::imports::insert_use::{ImportScope, ImportScopeKind};
use crate::text_edit::{TextEdit, TextEditBuilder};
use crate::{SnippetCap, assists::Command, syntax_helpers::tree_diff::diff};
use base_db::AnchoredPathBuf;
@@ -367,6 +368,17 @@ impl SourceChangeBuilder {
pub fn make_mut<N: AstNode>(&mut self, node: N) -> N {
self.mutated_tree.get_or_insert_with(|| TreeMutator::new(node.syntax())).make_mut(&node)
}
+
+ pub fn make_import_scope_mut(&mut self, scope: ImportScope) -> ImportScope {
+ ImportScope {
+ kind: match scope.kind.clone() {
+ ImportScopeKind::File(it) => ImportScopeKind::File(self.make_mut(it)),
+ ImportScopeKind::Module(it) => ImportScopeKind::Module(self.make_mut(it)),
+ ImportScopeKind::Block(it) => ImportScopeKind::Block(self.make_mut(it)),
+ },
+ required_cfgs: scope.required_cfgs.iter().map(|it| self.make_mut(it.clone())).collect(),
+ }
+ }
/// Returns a copy of the `node`, suitable for mutation.
///
/// Syntax trees in rust-analyzer are typically immutable, and mutating