aboutsummaryrefslogtreecommitdiff
path: root/crates/ide/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ide/src/lib.rs')
-rw-r--r--crates/ide/src/lib.rs39
1 files changed, 23 insertions, 16 deletions
diff --git a/crates/ide/src/lib.rs b/crates/ide/src/lib.rs
index 99e45633e..8e5b72044 100644
--- a/crates/ide/src/lib.rs
+++ b/crates/ide/src/lib.rs
@@ -87,7 +87,9 @@ pub use crate::{
87 }, 87 },
88}; 88};
89pub use hir::{Documentation, Semantics}; 89pub use hir::{Documentation, Semantics};
90pub use ide_assists::{Assist, AssistConfig, AssistId, AssistKind}; 90pub use ide_assists::{
91 Assist, AssistConfig, AssistId, AssistKind, AssistResolveStrategy, SingleResolve,
92};
91pub use ide_completion::{ 93pub use ide_completion::{
92 CompletionConfig, CompletionItem, CompletionItemKind, CompletionRelevance, ImportEdit, 94 CompletionConfig, CompletionItem, CompletionItemKind, CompletionRelevance, ImportEdit,
93 InsertTextFormat, 95 InsertTextFormat,
@@ -518,12 +520,13 @@ impl Analysis {
518 pub fn assists( 520 pub fn assists(
519 &self, 521 &self,
520 config: &AssistConfig, 522 config: &AssistConfig,
521 resolve: bool, 523 resolve: AssistResolveStrategy,
522 frange: FileRange, 524 frange: FileRange,
523 ) -> Cancelable<Vec<Assist>> { 525 ) -> Cancelable<Vec<Assist>> {
524 self.with_db(|db| { 526 self.with_db(|db| {
527 let ssr_assists = ssr::ssr_assists(db, &resolve, frange);
525 let mut acc = Assist::get(db, config, resolve, frange); 528 let mut acc = Assist::get(db, config, resolve, frange);
526 ssr::add_ssr_assist(db, &mut acc, resolve, frange); 529 acc.extend(ssr_assists.into_iter());
527 acc 530 acc
528 }) 531 })
529 } 532 }
@@ -532,10 +535,10 @@ impl Analysis {
532 pub fn diagnostics( 535 pub fn diagnostics(
533 &self, 536 &self,
534 config: &DiagnosticsConfig, 537 config: &DiagnosticsConfig,
535 resolve: bool, 538 resolve: AssistResolveStrategy,
536 file_id: FileId, 539 file_id: FileId,
537 ) -> Cancelable<Vec<Diagnostic>> { 540 ) -> Cancelable<Vec<Diagnostic>> {
538 self.with_db(|db| diagnostics::diagnostics(db, config, resolve, file_id)) 541 self.with_db(|db| diagnostics::diagnostics(db, config, &resolve, file_id))
539 } 542 }
540 543
541 /// Convenience function to return assists + quick fixes for diagnostics 544 /// Convenience function to return assists + quick fixes for diagnostics
@@ -543,7 +546,7 @@ impl Analysis {
543 &self, 546 &self,
544 assist_config: &AssistConfig, 547 assist_config: &AssistConfig,
545 diagnostics_config: &DiagnosticsConfig, 548 diagnostics_config: &DiagnosticsConfig,
546 resolve: bool, 549 resolve: AssistResolveStrategy,
547 frange: FileRange, 550 frange: FileRange,
548 ) -> Cancelable<Vec<Assist>> { 551 ) -> Cancelable<Vec<Assist>> {
549 let include_fixes = match &assist_config.allowed { 552 let include_fixes = match &assist_config.allowed {
@@ -552,17 +555,21 @@ impl Analysis {
552 }; 555 };
553 556
554 self.with_db(|db| { 557 self.with_db(|db| {
558 let ssr_assists = ssr::ssr_assists(db, &resolve, frange);
559 let diagnostic_assists = if include_fixes {
560 diagnostics::diagnostics(db, diagnostics_config, &resolve, frange.file_id)
561 .into_iter()
562 .filter_map(|it| it.fix)
563 .filter(|it| it.target.intersect(frange.range).is_some())
564 .collect()
565 } else {
566 Vec::new()
567 };
568
555 let mut res = Assist::get(db, assist_config, resolve, frange); 569 let mut res = Assist::get(db, assist_config, resolve, frange);
556 ssr::add_ssr_assist(db, &mut res, resolve, frange); 570 res.extend(ssr_assists.into_iter());
557 571 res.extend(diagnostic_assists.into_iter());
558 if include_fixes { 572
559 res.extend(
560 diagnostics::diagnostics(db, diagnostics_config, resolve, frange.file_id)
561 .into_iter()
562 .filter_map(|it| it.fix)
563 .filter(|it| it.target.intersect(frange.range).is_some()),
564 );
565 }
566 res 573 res
567 }) 574 })
568 } 575 }