From 1679a376f30c5ad8971c0f855074a3f489fee5fa Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Mon, 3 May 2021 18:03:28 +0300 Subject: Resolve single assist only --- crates/ide/src/diagnostics.rs | 6 +++--- crates/ide/src/diagnostics/fixes.rs | 16 ++++++++-------- crates/ide/src/diagnostics/unlinked_file.rs | 2 +- crates/ide/src/lib.rs | 8 ++++---- crates/ide/src/ssr.rs | 4 ++-- 5 files changed, 18 insertions(+), 18 deletions(-) (limited to 'crates/ide') diff --git a/crates/ide/src/diagnostics.rs b/crates/ide/src/diagnostics.rs index 455f20c93..b14f908b7 100644 --- a/crates/ide/src/diagnostics.rs +++ b/crates/ide/src/diagnostics.rs @@ -85,7 +85,7 @@ pub struct DiagnosticsConfig { pub(crate) fn diagnostics( db: &RootDatabase, config: &DiagnosticsConfig, - resolve: AssistResolveStrategy, + resolve: &AssistResolveStrategy, file_id: FileId, ) -> Vec { let _p = profile::span("diagnostics"); @@ -213,7 +213,7 @@ pub(crate) fn diagnostics( fn diagnostic_with_fix( d: &D, sema: &Semantics, - resolve: AssistResolveStrategy, + resolve: &AssistResolveStrategy, ) -> Diagnostic { Diagnostic::error(sema.diagnostics_display_range(d.display_source()).range, d.message()) .with_fix(d.fix(&sema, resolve)) @@ -223,7 +223,7 @@ fn diagnostic_with_fix( fn warning_with_fix( d: &D, sema: &Semantics, - resolve: AssistResolveStrategy, + resolve: &AssistResolveStrategy, ) -> Diagnostic { Diagnostic::hint(sema.diagnostics_display_range(d.display_source()).range, d.message()) .with_fix(d.fix(&sema, resolve)) diff --git a/crates/ide/src/diagnostics/fixes.rs b/crates/ide/src/diagnostics/fixes.rs index f23064eac..15821500f 100644 --- a/crates/ide/src/diagnostics/fixes.rs +++ b/crates/ide/src/diagnostics/fixes.rs @@ -39,7 +39,7 @@ pub(crate) trait DiagnosticWithFix: Diagnostic { fn fix( &self, sema: &Semantics, - _resolve: AssistResolveStrategy, + _resolve: &AssistResolveStrategy, ) -> Option; } @@ -47,7 +47,7 @@ impl DiagnosticWithFix for UnresolvedModule { fn fix( &self, sema: &Semantics, - _resolve: AssistResolveStrategy, + _resolve: &AssistResolveStrategy, ) -> Option { let root = sema.db.parse_or_expand(self.file)?; let unresolved_module = self.decl.to_node(&root); @@ -71,7 +71,7 @@ impl DiagnosticWithFix for NoSuchField { fn fix( &self, sema: &Semantics, - _resolve: AssistResolveStrategy, + _resolve: &AssistResolveStrategy, ) -> Option { let root = sema.db.parse_or_expand(self.file)?; missing_record_expr_field_fix( @@ -86,7 +86,7 @@ impl DiagnosticWithFix for MissingFields { fn fix( &self, sema: &Semantics, - _resolve: AssistResolveStrategy, + _resolve: &AssistResolveStrategy, ) -> Option { // Note that although we could add a diagnostics to // fill the missing tuple field, e.g : @@ -126,7 +126,7 @@ impl DiagnosticWithFix for MissingOkOrSomeInTailExpr { fn fix( &self, sema: &Semantics, - _resolve: AssistResolveStrategy, + _resolve: &AssistResolveStrategy, ) -> Option { let root = sema.db.parse_or_expand(self.file)?; let tail_expr = self.expr.to_node(&root); @@ -143,7 +143,7 @@ impl DiagnosticWithFix for RemoveThisSemicolon { fn fix( &self, sema: &Semantics, - _resolve: AssistResolveStrategy, + _resolve: &AssistResolveStrategy, ) -> Option { let root = sema.db.parse_or_expand(self.file)?; @@ -167,7 +167,7 @@ impl DiagnosticWithFix for IncorrectCase { fn fix( &self, sema: &Semantics, - resolve: AssistResolveStrategy, + resolve: &AssistResolveStrategy, ) -> Option { let root = sema.db.parse_or_expand(self.file)?; let name_node = self.ident.to_node(&root); @@ -191,7 +191,7 @@ impl DiagnosticWithFix for ReplaceFilterMapNextWithFindMap { fn fix( &self, sema: &Semantics, - _resolve: AssistResolveStrategy, + _resolve: &AssistResolveStrategy, ) -> Option { let root = sema.db.parse_or_expand(self.file)?; let next_expr = self.next_expr.to_node(&root); diff --git a/crates/ide/src/diagnostics/unlinked_file.rs b/crates/ide/src/diagnostics/unlinked_file.rs index e48528bed..93fd25dea 100644 --- a/crates/ide/src/diagnostics/unlinked_file.rs +++ b/crates/ide/src/diagnostics/unlinked_file.rs @@ -54,7 +54,7 @@ impl DiagnosticWithFix for UnlinkedFile { fn fix( &self, sema: &hir::Semantics, - _resolve: AssistResolveStrategy, + _resolve: &AssistResolveStrategy, ) -> Option { // If there's an existing module that could add a `mod` item to include the unlinked file, // suggest that as a fix. diff --git a/crates/ide/src/lib.rs b/crates/ide/src/lib.rs index 6847b7e83..6a88236e3 100644 --- a/crates/ide/src/lib.rs +++ b/crates/ide/src/lib.rs @@ -522,7 +522,7 @@ impl Analysis { frange: FileRange, ) -> Cancelable> { self.with_db(|db| { - let ssr_assists = ssr::ssr_assists(db, resolve, frange); + let ssr_assists = ssr::ssr_assists(db, &resolve, frange); let mut acc = Assist::get(db, config, resolve, frange); acc.extend(ssr_assists.into_iter()); acc @@ -536,7 +536,7 @@ impl Analysis { resolve: AssistResolveStrategy, file_id: FileId, ) -> Cancelable> { - self.with_db(|db| diagnostics::diagnostics(db, config, resolve, file_id)) + self.with_db(|db| diagnostics::diagnostics(db, config, &resolve, file_id)) } /// Convenience function to return assists + quick fixes for diagnostics @@ -553,9 +553,9 @@ impl Analysis { }; self.with_db(|db| { - let ssr_assists = ssr::ssr_assists(db, resolve, frange); + let ssr_assists = ssr::ssr_assists(db, &resolve, frange); let diagnostic_assists = if include_fixes { - diagnostics::diagnostics(db, diagnostics_config, resolve, frange.file_id) + diagnostics::diagnostics(db, diagnostics_config, &resolve, frange.file_id) .into_iter() .filter_map(|it| it.fix) .filter(|it| it.target.intersect(frange.range).is_some()) diff --git a/crates/ide/src/ssr.rs b/crates/ide/src/ssr.rs index 785ce3010..1695e52ec 100644 --- a/crates/ide/src/ssr.rs +++ b/crates/ide/src/ssr.rs @@ -7,7 +7,7 @@ use ide_db::{base_db::FileRange, label::Label, source_change::SourceChange, Root pub(crate) fn ssr_assists( db: &RootDatabase, - resolve: AssistResolveStrategy, + resolve: &AssistResolveStrategy, frange: FileRange, ) -> Vec { let mut ssr_assists = Vec::with_capacity(2); @@ -73,7 +73,7 @@ mod tests { let mut local_roots = FxHashSet::default(); local_roots.insert(ide_db::base_db::fixture::WORKSPACE); db.set_local_roots_with_durability(Arc::new(local_roots), Durability::HIGH); - ssr_assists(&db, resolve, FileRange { file_id, range: range_or_offset.into() }) + ssr_assists(&db, &resolve, FileRange { file_id, range: range_or_offset.into() }) } #[test] -- cgit v1.2.3