aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_assists/src
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2020-02-06 15:40:28 +0000
committerAleksey Kladov <[email protected]>2020-02-06 15:40:28 +0000
commita173e31890c1eb03d9d4c123986baae4154cd4fa (patch)
treea2b4de01cd6128b70f0fc0cf4156b6537304ae56 /crates/ra_assists/src
parentff0f0fc31e84deb7aebf8ab6ec510051d531c9f2 (diff)
Make assists use ImportsLocator directly
Diffstat (limited to 'crates/ra_assists/src')
-rw-r--r--crates/ra_assists/src/lib.rs18
1 files changed, 9 insertions, 9 deletions
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;
16use either::Either; 16use either::Either;
17use hir::{db::HirDatabase, ModuleDef}; 17use hir::{db::HirDatabase, ModuleDef};
18use ra_db::FileRange; 18use ra_db::FileRange;
19use ra_ide_db::{imports_locator::ImportsLocatorIde, RootDatabase};
19use ra_syntax::{TextRange, TextUnit}; 20use ra_syntax::{TextRange, TextUnit};
20use ra_text_edit::TextEdit; 21use 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
92impl 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.
96pub fn assists_with_imports_locator<H, F>( 103pub 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>
101where
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()