diff options
Diffstat (limited to 'crates/ra_assists')
-rw-r--r-- | crates/ra_assists/Cargo.toml | 1 | ||||
-rw-r--r-- | crates/ra_assists/src/lib.rs | 18 |
2 files changed, 10 insertions, 9 deletions
diff --git a/crates/ra_assists/Cargo.toml b/crates/ra_assists/Cargo.toml index 9d3091b91..6973038d4 100644 --- a/crates/ra_assists/Cargo.toml +++ b/crates/ra_assists/Cargo.toml | |||
@@ -18,5 +18,6 @@ ra_text_edit = { path = "../ra_text_edit" } | |||
18 | ra_fmt = { path = "../ra_fmt" } | 18 | ra_fmt = { path = "../ra_fmt" } |
19 | ra_prof = { path = "../ra_prof" } | 19 | ra_prof = { path = "../ra_prof" } |
20 | ra_db = { path = "../ra_db" } | 20 | ra_db = { path = "../ra_db" } |
21 | ra_ide_db = { path = "../ra_ide_db" } | ||
21 | hir = { path = "../ra_hir", package = "ra_hir" } | 22 | hir = { path = "../ra_hir", package = "ra_hir" } |
22 | test_utils = { path = "../test_utils" } | 23 | test_utils = { path = "../test_utils" } |
diff --git a/crates/ra_assists/src/lib.rs b/crates/ra_assists/src/lib.rs index 625ebc4a2..0ebb8e8b0 100644 --- a/crates/ra_assists/src/lib.rs +++ b/crates/ra_assists/src/lib.rs | |||
@@ -16,6 +16,7 @@ pub mod ast_transform; | |||
16 | use either::Either; | 16 | use either::Either; |
17 | use hir::{db::HirDatabase, ModuleDef}; | 17 | use hir::{db::HirDatabase, ModuleDef}; |
18 | use ra_db::FileRange; | 18 | use ra_db::FileRange; |
19 | use ra_ide_db::{imports_locator::ImportsLocatorIde, RootDatabase}; | ||
19 | use ra_syntax::{TextRange, TextUnit}; | 20 | use ra_syntax::{TextRange, TextUnit}; |
20 | use ra_text_edit::TextEdit; | 21 | use ra_text_edit::TextEdit; |
21 | 22 | ||
@@ -88,20 +89,19 @@ pub trait ImportsLocator { | |||
88 | fn find_imports(&mut self, name_to_import: &str) -> Vec<ModuleDef>; | 89 | fn find_imports(&mut self, name_to_import: &str) -> Vec<ModuleDef>; |
89 | } | 90 | } |
90 | 91 | ||
92 | impl ImportsLocator for ImportsLocatorIde<'_> { | ||
93 | fn find_imports(&mut self, name_to_import: &str) -> Vec<ModuleDef> { | ||
94 | self.find_imports(name_to_import) | ||
95 | } | ||
96 | } | ||
97 | |||
91 | /// Return all the assists applicable at the given position | 98 | /// Return all the assists applicable at the given position |
92 | /// and additional assists that need the imports locator functionality to work. | 99 | /// and additional assists that need the imports locator functionality to work. |
93 | /// | 100 | /// |
94 | /// Assists are returned in the "resolved" state, that is with edit fully | 101 | /// Assists are returned in the "resolved" state, that is with edit fully |
95 | /// computed. | 102 | /// computed. |
96 | pub fn assists_with_imports_locator<H, F>( | 103 | pub fn assists_with_imports_locator(db: &RootDatabase, range: FileRange) -> Vec<ResolvedAssist> { |
97 | db: &H, | 104 | let mut imports_locator = ImportsLocatorIde::new(db); |
98 | range: FileRange, | ||
99 | mut imports_locator: F, | ||
100 | ) -> Vec<ResolvedAssist> | ||
101 | where | ||
102 | H: HirDatabase + 'static, | ||
103 | F: ImportsLocator, | ||
104 | { | ||
105 | AssistCtx::with_ctx(db, range, true, |ctx| { | 105 | AssistCtx::with_ctx(db, range, true, |ctx| { |
106 | let mut assists = assists::all() | 106 | let mut assists = assists::all() |
107 | .iter() | 107 | .iter() |