From a173e31890c1eb03d9d4c123986baae4154cd4fa Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 6 Feb 2020 16:40:28 +0100 Subject: Make assists use ImportsLocator directly --- crates/ra_assists/src/lib.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'crates/ra_assists/src') 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; use either::Either; use hir::{db::HirDatabase, ModuleDef}; use ra_db::FileRange; +use ra_ide_db::{imports_locator::ImportsLocatorIde, RootDatabase}; use ra_syntax::{TextRange, TextUnit}; use ra_text_edit::TextEdit; @@ -88,20 +89,19 @@ pub trait ImportsLocator { fn find_imports(&mut self, name_to_import: &str) -> Vec; } +impl ImportsLocator for ImportsLocatorIde<'_> { + fn find_imports(&mut self, name_to_import: &str) -> Vec { + self.find_imports(name_to_import) + } +} + /// Return all the assists applicable at the given position /// and additional assists that need the imports locator functionality to work. /// /// Assists are returned in the "resolved" state, that is with edit fully /// computed. -pub fn assists_with_imports_locator( - db: &H, - range: FileRange, - mut imports_locator: F, -) -> Vec -where - H: HirDatabase + 'static, - F: ImportsLocator, -{ +pub fn assists_with_imports_locator(db: &RootDatabase, range: FileRange) -> Vec { + let mut imports_locator = ImportsLocatorIde::new(db); AssistCtx::with_ctx(db, range, true, |ctx| { let mut assists = assists::all() .iter() -- cgit v1.2.3