aboutsummaryrefslogtreecommitdiff
path: root/crates/completion
diff options
context:
space:
mode:
authorKirill Bulatov <[email protected]>2020-11-24 21:25:13 +0000
committerKirill Bulatov <[email protected]>2020-11-27 16:28:41 +0000
commitf4ae3650d855554575f866264a3c8197dfd12835 (patch)
tree5db591ff6ed18f196ddde87858d14e9b9ded6dc6 /crates/completion
parent0993f9067cfc14cded484906283d1df8e8741e8e (diff)
Extract the import code into the shared module
Diffstat (limited to 'crates/completion')
-rw-r--r--crates/completion/Cargo.toml2
-rw-r--r--crates/completion/src/completions/record.rs4
-rw-r--r--crates/completion/src/completions/unqualified_path.rs2
-rw-r--r--crates/completion/src/config.rs2
-rw-r--r--crates/completion/src/item.rs7
-rw-r--r--crates/completion/src/render.rs2
-rw-r--r--crates/completion/src/render/enum_variant.rs2
-rw-r--r--crates/completion/src/render/function.rs2
-rw-r--r--crates/completion/src/render/macro_.rs3
9 files changed, 15 insertions, 11 deletions
diff --git a/crates/completion/Cargo.toml b/crates/completion/Cargo.toml
index e7df9d955..102de33f8 100644
--- a/crates/completion/Cargo.toml
+++ b/crates/completion/Cargo.toml
@@ -15,7 +15,6 @@ log = "0.4.8"
15rustc-hash = "1.1.0" 15rustc-hash = "1.1.0"
16either = "1.6.1" 16either = "1.6.1"
17 17
18assists = { path = "../assists", version = "0.0.0" }
19stdx = { path = "../stdx", version = "0.0.0" } 18stdx = { path = "../stdx", version = "0.0.0" }
20syntax = { path = "../syntax", version = "0.0.0" } 19syntax = { path = "../syntax", version = "0.0.0" }
21text_edit = { path = "../text_edit", version = "0.0.0" } 20text_edit = { path = "../text_edit", version = "0.0.0" }
@@ -23,6 +22,7 @@ base_db = { path = "../base_db", version = "0.0.0" }
23ide_db = { path = "../ide_db", version = "0.0.0" } 22ide_db = { path = "../ide_db", version = "0.0.0" }
24profile = { path = "../profile", version = "0.0.0" } 23profile = { path = "../profile", version = "0.0.0" }
25test_utils = { path = "../test_utils", version = "0.0.0" } 24test_utils = { path = "../test_utils", version = "0.0.0" }
25ide_helpers = { path = "../ide_helpers", version = "0.0.0" }
26 26
27# completions crate should depend only on the top-level `hir` package. if you need 27# completions crate should depend only on the top-level `hir` package. if you need
28# something from some `hir_xxx` subpackage, reexport the API via `hir`. 28# something from some `hir_xxx` subpackage, reexport the API via `hir`.
diff --git a/crates/completion/src/completions/record.rs b/crates/completion/src/completions/record.rs
index 2049b9d09..218a1923c 100644
--- a/crates/completion/src/completions/record.rs
+++ b/crates/completion/src/completions/record.rs
@@ -1,5 +1,5 @@
1//! Complete fields in record literals and patterns. 1//! Complete fields in record literals and patterns.
2use assists::utils::FamousDefs; 2use ide_helpers::FamousDefs;
3use syntax::ast::Expr; 3use syntax::ast::Expr;
4 4
5use crate::{ 5use crate::{
@@ -45,8 +45,8 @@ pub(crate) fn complete_record(acc: &mut Completions, ctx: &CompletionContext) ->
45 45
46#[cfg(test)] 46#[cfg(test)]
47mod tests { 47mod tests {
48 use assists::utils::FamousDefs;
49 use expect_test::{expect, Expect}; 48 use expect_test::{expect, Expect};
49 use ide_helpers::FamousDefs;
50 50
51 use crate::{test_utils::completion_list, CompletionKind}; 51 use crate::{test_utils::completion_list, CompletionKind};
52 52
diff --git a/crates/completion/src/completions/unqualified_path.rs b/crates/completion/src/completions/unqualified_path.rs
index 3bd776905..db5dbb7dd 100644
--- a/crates/completion/src/completions/unqualified_path.rs
+++ b/crates/completion/src/completions/unqualified_path.rs
@@ -1,9 +1,9 @@
1//! Completion of names from the current scope, e.g. locals and imported items. 1//! Completion of names from the current scope, e.g. locals and imported items.
2 2
3use assists::utils::ImportScope;
4use either::Either; 3use either::Either;
5use hir::{Adt, ModuleDef, ScopeDef, Type}; 4use hir::{Adt, ModuleDef, ScopeDef, Type};
6use ide_db::imports_locator; 5use ide_db::imports_locator;
6use ide_helpers::insert_use::ImportScope;
7use syntax::AstNode; 7use syntax::AstNode;
8use test_utils::mark; 8use test_utils::mark;
9 9
diff --git a/crates/completion/src/config.rs b/crates/completion/src/config.rs
index f50735372..1995b0754 100644
--- a/crates/completion/src/config.rs
+++ b/crates/completion/src/config.rs
@@ -4,7 +4,7 @@
4//! module, and we use to statically check that we only produce snippet 4//! module, and we use to statically check that we only produce snippet
5//! completions if we are allowed to. 5//! completions if we are allowed to.
6 6
7use assists::utils::MergeBehaviour; 7use ide_helpers::insert_use::MergeBehaviour;
8 8
9#[derive(Clone, Debug, PartialEq, Eq)] 9#[derive(Clone, Debug, PartialEq, Eq)]
10pub struct CompletionConfig { 10pub struct CompletionConfig {
diff --git a/crates/completion/src/item.rs b/crates/completion/src/item.rs
index 7b62c2c4e..675cef8c4 100644
--- a/crates/completion/src/item.rs
+++ b/crates/completion/src/item.rs
@@ -2,8 +2,11 @@
2 2
3use std::fmt; 3use std::fmt;
4 4
5use assists::utils::{insert_use, mod_path_to_ast, ImportScope, MergeBehaviour};
6use hir::{Documentation, ModPath, Mutability}; 5use hir::{Documentation, ModPath, Mutability};
6use ide_helpers::{
7 insert_use::{self, ImportScope, MergeBehaviour},
8 mod_path_to_ast,
9};
7use syntax::{algo, TextRange}; 10use syntax::{algo, TextRange};
8use text_edit::TextEdit; 11use text_edit::TextEdit;
9 12
@@ -300,7 +303,7 @@ impl Builder {
300 label = format!("{}::{}", import_path_without_last_segment, label); 303 label = format!("{}::{}", import_path_without_last_segment, label);
301 } 304 }
302 305
303 let rewriter = insert_use(&import_scope, import, merge_behaviour); 306 let rewriter = insert_use::insert_use(&import_scope, import, merge_behaviour);
304 if let Some(old_ast) = rewriter.rewrite_root() { 307 if let Some(old_ast) = rewriter.rewrite_root() {
305 algo::diff(&old_ast, &rewriter.rewrite(&old_ast)).into_text_edit(&mut text_edits); 308 algo::diff(&old_ast, &rewriter.rewrite(&old_ast)).into_text_edit(&mut text_edits);
306 } 309 }
diff --git a/crates/completion/src/render.rs b/crates/completion/src/render.rs
index bce02f577..e9704c27c 100644
--- a/crates/completion/src/render.rs
+++ b/crates/completion/src/render.rs
@@ -9,9 +9,9 @@ pub(crate) mod type_alias;
9 9
10mod builder_ext; 10mod builder_ext;
11 11
12use assists::utils::{ImportScope, MergeBehaviour};
13use hir::{Documentation, HasAttrs, HirDisplay, ModPath, Mutability, ScopeDef, Type}; 12use hir::{Documentation, HasAttrs, HirDisplay, ModPath, Mutability, ScopeDef, Type};
14use ide_db::RootDatabase; 13use ide_db::RootDatabase;
14use ide_helpers::insert_use::{ImportScope, MergeBehaviour};
15use syntax::TextRange; 15use syntax::TextRange;
16use test_utils::mark; 16use test_utils::mark;
17 17
diff --git a/crates/completion/src/render/enum_variant.rs b/crates/completion/src/render/enum_variant.rs
index 64e742b77..5d4fbb641 100644
--- a/crates/completion/src/render/enum_variant.rs
+++ b/crates/completion/src/render/enum_variant.rs
@@ -1,7 +1,7 @@
1//! Renderer for `enum` variants. 1//! Renderer for `enum` variants.
2 2
3use assists::utils::{ImportScope, MergeBehaviour};
4use hir::{HasAttrs, HirDisplay, ModPath, StructKind}; 3use hir::{HasAttrs, HirDisplay, ModPath, StructKind};
4use ide_helpers::insert_use::{ImportScope, MergeBehaviour};
5use itertools::Itertools; 5use itertools::Itertools;
6use test_utils::mark; 6use test_utils::mark;
7 7
diff --git a/crates/completion/src/render/function.rs b/crates/completion/src/render/function.rs
index e8b726ad6..07e99058a 100644
--- a/crates/completion/src/render/function.rs
+++ b/crates/completion/src/render/function.rs
@@ -1,7 +1,7 @@
1//! Renderer for function calls. 1//! Renderer for function calls.
2 2
3use assists::utils::{ImportScope, MergeBehaviour};
4use hir::{HasSource, ModPath, Type}; 3use hir::{HasSource, ModPath, Type};
4use ide_helpers::insert_use::{ImportScope, MergeBehaviour};
5use syntax::{ast::Fn, display::function_declaration}; 5use syntax::{ast::Fn, display::function_declaration};
6 6
7use crate::{ 7use crate::{
diff --git a/crates/completion/src/render/macro_.rs b/crates/completion/src/render/macro_.rs
index 91055a296..b1284f201 100644
--- a/crates/completion/src/render/macro_.rs
+++ b/crates/completion/src/render/macro_.rs
@@ -1,7 +1,7 @@
1//! Renderer for macro invocations. 1//! Renderer for macro invocations.
2 2
3use assists::utils::{ImportScope, MergeBehaviour};
4use hir::{Documentation, HasSource, ModPath}; 3use hir::{Documentation, HasSource, ModPath};
4use ide_helpers::insert_use::{ImportScope, MergeBehaviour};
5use syntax::display::macro_label; 5use syntax::display::macro_label;
6use test_utils::mark; 6use test_utils::mark;
7 7
@@ -12,6 +12,7 @@ use crate::{
12 12
13pub(crate) fn render_macro<'a>( 13pub(crate) fn render_macro<'a>(
14 ctx: RenderContext<'a>, 14 ctx: RenderContext<'a>,
15 // TODO kb add some object instead of a tuple?
15 import_data: Option<(ModPath, ImportScope, Option<MergeBehaviour>)>, 16 import_data: Option<(ModPath, ImportScope, Option<MergeBehaviour>)>,
16 name: String, 17 name: String,
17 macro_: hir::MacroDef, 18 macro_: hir::MacroDef,