diff options
author | Kirill Bulatov <[email protected]> | 2020-12-04 08:02:22 +0000 |
---|---|---|
committer | Kirill Bulatov <[email protected]> | 2020-12-07 21:41:08 +0000 |
commit | 93bc009a5968c964693299263689b50b2efe9abc (patch) | |
tree | 88661f1cf81dc71fd531ad7ca323a85b270053ae /crates/completion | |
parent | 74c3bbacc9b352057f2fc7ab69bd13e53022beb0 (diff) |
Remove the state
Diffstat (limited to 'crates/completion')
-rw-r--r-- | crates/completion/src/item.rs | 30 | ||||
-rw-r--r-- | crates/completion/src/lib.rs | 5 |
2 files changed, 4 insertions, 31 deletions
diff --git a/crates/completion/src/item.rs b/crates/completion/src/item.rs index dd25ca75c..2dadf7e5b 100644 --- a/crates/completion/src/item.rs +++ b/crates/completion/src/item.rs | |||
@@ -4,10 +4,10 @@ use std::fmt; | |||
4 | 4 | ||
5 | use hir::{Documentation, ModPath, Mutability}; | 5 | use hir::{Documentation, ModPath, Mutability}; |
6 | use ide_db::helpers::{ | 6 | use ide_db::helpers::{ |
7 | insert_use::{self, ImportScope, ImportScopePtr, MergeBehaviour}, | 7 | insert_use::{self, ImportScope, MergeBehaviour}, |
8 | mod_path_to_ast, | 8 | mod_path_to_ast, |
9 | }; | 9 | }; |
10 | use syntax::{algo, SyntaxNode, TextRange}; | 10 | use syntax::{algo, TextRange}; |
11 | use text_edit::TextEdit; | 11 | use text_edit::TextEdit; |
12 | 12 | ||
13 | use crate::config::SnippetCap; | 13 | use crate::config::SnippetCap; |
@@ -275,32 +275,8 @@ pub struct ImportEdit { | |||
275 | pub merge_behaviour: Option<MergeBehaviour>, | 275 | pub merge_behaviour: Option<MergeBehaviour>, |
276 | } | 276 | } |
277 | 277 | ||
278 | #[derive(Debug, Clone)] | ||
279 | pub struct ImportEditPtr { | ||
280 | pub import_path: ModPath, | ||
281 | pub import_scope: ImportScopePtr, | ||
282 | pub merge_behaviour: Option<MergeBehaviour>, | ||
283 | } | ||
284 | |||
285 | impl ImportEditPtr { | ||
286 | pub fn into_import_edit(self, root: &SyntaxNode) -> Option<ImportEdit> { | ||
287 | Some(ImportEdit { | ||
288 | import_path: self.import_path, | ||
289 | import_scope: self.import_scope.into_scope(root)?, | ||
290 | merge_behaviour: self.merge_behaviour, | ||
291 | }) | ||
292 | } | ||
293 | } | ||
294 | |||
295 | impl ImportEdit { | 278 | impl ImportEdit { |
296 | pub fn get_edit_ptr(&self) -> ImportEditPtr { | 279 | // TODO kb remove this at all now, since it's used only once? |
297 | ImportEditPtr { | ||
298 | import_path: self.import_path.clone(), | ||
299 | import_scope: self.import_scope.get_ptr(), | ||
300 | merge_behaviour: self.merge_behaviour, | ||
301 | } | ||
302 | } | ||
303 | |||
304 | /// Attempts to insert the import to the given scope, producing a text edit. | 280 | /// Attempts to insert the import to the given scope, producing a text edit. |
305 | /// May return no edit in edge cases, such as scope already containing the import. | 281 | /// May return no edit in edge cases, such as scope already containing the import. |
306 | pub fn to_text_edit(&self) -> Option<TextEdit> { | 282 | pub fn to_text_edit(&self) -> Option<TextEdit> { |
diff --git a/crates/completion/src/lib.rs b/crates/completion/src/lib.rs index c277cd466..c57203c80 100644 --- a/crates/completion/src/lib.rs +++ b/crates/completion/src/lib.rs | |||
@@ -18,10 +18,7 @@ use crate::{completions::Completions, context::CompletionContext, item::Completi | |||
18 | 18 | ||
19 | pub use crate::{ | 19 | pub use crate::{ |
20 | config::{CompletionConfig, CompletionResolveCapability}, | 20 | config::{CompletionConfig, CompletionResolveCapability}, |
21 | item::{ | 21 | item::{CompletionItem, CompletionItemKind, CompletionScore, ImportEdit, InsertTextFormat}, |
22 | CompletionItem, CompletionItemKind, CompletionScore, ImportEdit, ImportEditPtr, | ||
23 | InsertTextFormat, | ||
24 | }, | ||
25 | }; | 22 | }; |
26 | 23 | ||
27 | //FIXME: split the following feature into fine-grained features. | 24 | //FIXME: split the following feature into fine-grained features. |