aboutsummaryrefslogtreecommitdiff
path: root/crates/ide/src
diff options
context:
space:
mode:
authorKirill Bulatov <[email protected]>2021-05-03 16:03:28 +0100
committerKirill Bulatov <[email protected]>2021-05-03 16:03:28 +0100
commit1679a376f30c5ad8971c0f855074a3f489fee5fa (patch)
tree1ffe5d504426f6e1d9cbf1c56d9e6b91ab9ac43d /crates/ide/src
parente5cdcb8b124f5b7d59950429787e760e46388f72 (diff)
Resolve single assist only
Diffstat (limited to 'crates/ide/src')
-rw-r--r--crates/ide/src/diagnostics.rs6
-rw-r--r--crates/ide/src/diagnostics/fixes.rs16
-rw-r--r--crates/ide/src/diagnostics/unlinked_file.rs2
-rw-r--r--crates/ide/src/lib.rs8
-rw-r--r--crates/ide/src/ssr.rs4
5 files changed, 18 insertions, 18 deletions
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 {
85pub(crate) fn diagnostics( 85pub(crate) fn diagnostics(
86 db: &RootDatabase, 86 db: &RootDatabase,
87 config: &DiagnosticsConfig, 87 config: &DiagnosticsConfig,
88 resolve: AssistResolveStrategy, 88 resolve: &AssistResolveStrategy,
89 file_id: FileId, 89 file_id: FileId,
90) -> Vec<Diagnostic> { 90) -> Vec<Diagnostic> {
91 let _p = profile::span("diagnostics"); 91 let _p = profile::span("diagnostics");
@@ -213,7 +213,7 @@ pub(crate) fn diagnostics(
213fn diagnostic_with_fix<D: DiagnosticWithFix>( 213fn diagnostic_with_fix<D: DiagnosticWithFix>(
214 d: &D, 214 d: &D,
215 sema: &Semantics<RootDatabase>, 215 sema: &Semantics<RootDatabase>,
216 resolve: AssistResolveStrategy, 216 resolve: &AssistResolveStrategy,
217) -> Diagnostic { 217) -> Diagnostic {
218 Diagnostic::error(sema.diagnostics_display_range(d.display_source()).range, d.message()) 218 Diagnostic::error(sema.diagnostics_display_range(d.display_source()).range, d.message())
219 .with_fix(d.fix(&sema, resolve)) 219 .with_fix(d.fix(&sema, resolve))
@@ -223,7 +223,7 @@ fn diagnostic_with_fix<D: DiagnosticWithFix>(
223fn warning_with_fix<D: DiagnosticWithFix>( 223fn warning_with_fix<D: DiagnosticWithFix>(
224 d: &D, 224 d: &D,
225 sema: &Semantics<RootDatabase>, 225 sema: &Semantics<RootDatabase>,
226 resolve: AssistResolveStrategy, 226 resolve: &AssistResolveStrategy,
227) -> Diagnostic { 227) -> Diagnostic {
228 Diagnostic::hint(sema.diagnostics_display_range(d.display_source()).range, d.message()) 228 Diagnostic::hint(sema.diagnostics_display_range(d.display_source()).range, d.message())
229 .with_fix(d.fix(&sema, resolve)) 229 .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 {
39 fn fix( 39 fn fix(
40 &self, 40 &self,
41 sema: &Semantics<RootDatabase>, 41 sema: &Semantics<RootDatabase>,
42 _resolve: AssistResolveStrategy, 42 _resolve: &AssistResolveStrategy,
43 ) -> Option<Assist>; 43 ) -> Option<Assist>;
44} 44}
45 45
@@ -47,7 +47,7 @@ impl DiagnosticWithFix for UnresolvedModule {
47 fn fix( 47 fn fix(
48 &self, 48 &self,
49 sema: &Semantics<RootDatabase>, 49 sema: &Semantics<RootDatabase>,
50 _resolve: AssistResolveStrategy, 50 _resolve: &AssistResolveStrategy,
51 ) -> Option<Assist> { 51 ) -> Option<Assist> {
52 let root = sema.db.parse_or_expand(self.file)?; 52 let root = sema.db.parse_or_expand(self.file)?;
53 let unresolved_module = self.decl.to_node(&root); 53 let unresolved_module = self.decl.to_node(&root);
@@ -71,7 +71,7 @@ impl DiagnosticWithFix for NoSuchField {
71 fn fix( 71 fn fix(
72 &self, 72 &self,
73 sema: &Semantics<RootDatabase>, 73 sema: &Semantics<RootDatabase>,
74 _resolve: AssistResolveStrategy, 74 _resolve: &AssistResolveStrategy,
75 ) -> Option<Assist> { 75 ) -> Option<Assist> {
76 let root = sema.db.parse_or_expand(self.file)?; 76 let root = sema.db.parse_or_expand(self.file)?;
77 missing_record_expr_field_fix( 77 missing_record_expr_field_fix(
@@ -86,7 +86,7 @@ impl DiagnosticWithFix for MissingFields {
86 fn fix( 86 fn fix(
87 &self, 87 &self,
88 sema: &Semantics<RootDatabase>, 88 sema: &Semantics<RootDatabase>,
89 _resolve: AssistResolveStrategy, 89 _resolve: &AssistResolveStrategy,
90 ) -> Option<Assist> { 90 ) -> Option<Assist> {
91 // Note that although we could add a diagnostics to 91 // Note that although we could add a diagnostics to
92 // fill the missing tuple field, e.g : 92 // fill the missing tuple field, e.g :
@@ -126,7 +126,7 @@ impl DiagnosticWithFix for MissingOkOrSomeInTailExpr {
126 fn fix( 126 fn fix(
127 &self, 127 &self,
128 sema: &Semantics<RootDatabase>, 128 sema: &Semantics<RootDatabase>,
129 _resolve: AssistResolveStrategy, 129 _resolve: &AssistResolveStrategy,
130 ) -> Option<Assist> { 130 ) -> Option<Assist> {
131 let root = sema.db.parse_or_expand(self.file)?; 131 let root = sema.db.parse_or_expand(self.file)?;
132 let tail_expr = self.expr.to_node(&root); 132 let tail_expr = self.expr.to_node(&root);
@@ -143,7 +143,7 @@ impl DiagnosticWithFix for RemoveThisSemicolon {
143 fn fix( 143 fn fix(
144 &self, 144 &self,
145 sema: &Semantics<RootDatabase>, 145 sema: &Semantics<RootDatabase>,
146 _resolve: AssistResolveStrategy, 146 _resolve: &AssistResolveStrategy,
147 ) -> Option<Assist> { 147 ) -> Option<Assist> {
148 let root = sema.db.parse_or_expand(self.file)?; 148 let root = sema.db.parse_or_expand(self.file)?;
149 149
@@ -167,7 +167,7 @@ impl DiagnosticWithFix for IncorrectCase {
167 fn fix( 167 fn fix(
168 &self, 168 &self,
169 sema: &Semantics<RootDatabase>, 169 sema: &Semantics<RootDatabase>,
170 resolve: AssistResolveStrategy, 170 resolve: &AssistResolveStrategy,
171 ) -> Option<Assist> { 171 ) -> Option<Assist> {
172 let root = sema.db.parse_or_expand(self.file)?; 172 let root = sema.db.parse_or_expand(self.file)?;
173 let name_node = self.ident.to_node(&root); 173 let name_node = self.ident.to_node(&root);
@@ -191,7 +191,7 @@ impl DiagnosticWithFix for ReplaceFilterMapNextWithFindMap {
191 fn fix( 191 fn fix(
192 &self, 192 &self,
193 sema: &Semantics<RootDatabase>, 193 sema: &Semantics<RootDatabase>,
194 _resolve: AssistResolveStrategy, 194 _resolve: &AssistResolveStrategy,
195 ) -> Option<Assist> { 195 ) -> Option<Assist> {
196 let root = sema.db.parse_or_expand(self.file)?; 196 let root = sema.db.parse_or_expand(self.file)?;
197 let next_expr = self.next_expr.to_node(&root); 197 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 {
54 fn fix( 54 fn fix(
55 &self, 55 &self,
56 sema: &hir::Semantics<RootDatabase>, 56 sema: &hir::Semantics<RootDatabase>,
57 _resolve: AssistResolveStrategy, 57 _resolve: &AssistResolveStrategy,
58 ) -> Option<Assist> { 58 ) -> Option<Assist> {
59 // If there's an existing module that could add a `mod` item to include the unlinked file, 59 // If there's an existing module that could add a `mod` item to include the unlinked file,
60 // suggest that as a fix. 60 // 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 {
522 frange: FileRange, 522 frange: FileRange,
523 ) -> Cancelable<Vec<Assist>> { 523 ) -> Cancelable<Vec<Assist>> {
524 self.with_db(|db| { 524 self.with_db(|db| {
525 let ssr_assists = ssr::ssr_assists(db, resolve, frange); 525 let ssr_assists = ssr::ssr_assists(db, &resolve, frange);
526 let mut acc = Assist::get(db, config, resolve, frange); 526 let mut acc = Assist::get(db, config, resolve, frange);
527 acc.extend(ssr_assists.into_iter()); 527 acc.extend(ssr_assists.into_iter());
528 acc 528 acc
@@ -536,7 +536,7 @@ impl Analysis {
536 resolve: AssistResolveStrategy, 536 resolve: AssistResolveStrategy,
537 file_id: FileId, 537 file_id: FileId,
538 ) -> Cancelable<Vec<Diagnostic>> { 538 ) -> Cancelable<Vec<Diagnostic>> {
539 self.with_db(|db| diagnostics::diagnostics(db, config, resolve, file_id)) 539 self.with_db(|db| diagnostics::diagnostics(db, config, &resolve, file_id))
540 } 540 }
541 541
542 /// Convenience function to return assists + quick fixes for diagnostics 542 /// Convenience function to return assists + quick fixes for diagnostics
@@ -553,9 +553,9 @@ impl Analysis {
553 }; 553 };
554 554
555 self.with_db(|db| { 555 self.with_db(|db| {
556 let ssr_assists = ssr::ssr_assists(db, resolve, frange); 556 let ssr_assists = ssr::ssr_assists(db, &resolve, frange);
557 let diagnostic_assists = if include_fixes { 557 let diagnostic_assists = if include_fixes {
558 diagnostics::diagnostics(db, diagnostics_config, resolve, frange.file_id) 558 diagnostics::diagnostics(db, diagnostics_config, &resolve, frange.file_id)
559 .into_iter() 559 .into_iter()
560 .filter_map(|it| it.fix) 560 .filter_map(|it| it.fix)
561 .filter(|it| it.target.intersect(frange.range).is_some()) 561 .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
7 7
8pub(crate) fn ssr_assists( 8pub(crate) fn ssr_assists(
9 db: &RootDatabase, 9 db: &RootDatabase,
10 resolve: AssistResolveStrategy, 10 resolve: &AssistResolveStrategy,
11 frange: FileRange, 11 frange: FileRange,
12) -> Vec<Assist> { 12) -> Vec<Assist> {
13 let mut ssr_assists = Vec::with_capacity(2); 13 let mut ssr_assists = Vec::with_capacity(2);
@@ -73,7 +73,7 @@ mod tests {
73 let mut local_roots = FxHashSet::default(); 73 let mut local_roots = FxHashSet::default();
74 local_roots.insert(ide_db::base_db::fixture::WORKSPACE); 74 local_roots.insert(ide_db::base_db::fixture::WORKSPACE);
75 db.set_local_roots_with_durability(Arc::new(local_roots), Durability::HIGH); 75 db.set_local_roots_with_durability(Arc::new(local_roots), Durability::HIGH);
76 ssr_assists(&db, resolve, FileRange { file_id, range: range_or_offset.into() }) 76 ssr_assists(&db, &resolve, FileRange { file_id, range: range_or_offset.into() })
77 } 77 }
78 78
79 #[test] 79 #[test]