aboutsummaryrefslogtreecommitdiff
path: root/crates/ide/src/lib.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2021-04-13 09:27:00 +0100
committerAleksey Kladov <[email protected]>2021-04-13 09:27:00 +0100
commit04b5fcfdb28f18f4d5279b43c2bb2b3f9c082313 (patch)
tree6f15b2ffa1bd22ec7543b1cb9fb059b12d6ec002 /crates/ide/src/lib.rs
parentfe29a9e837c6e9699185ccae55e83902b4f6ef6a (diff)
Ensure that listing&resolving code actions use the same set of actions
Diffstat (limited to 'crates/ide/src/lib.rs')
-rw-r--r--crates/ide/src/lib.rs28
1 files changed, 28 insertions, 0 deletions
diff --git a/crates/ide/src/lib.rs b/crates/ide/src/lib.rs
index 0615b26d3..bbc0d5eec 100644
--- a/crates/ide/src/lib.rs
+++ b/crates/ide/src/lib.rs
@@ -531,6 +531,34 @@ impl Analysis {
531 self.with_db(|db| diagnostics::diagnostics(db, config, file_id)) 531 self.with_db(|db| diagnostics::diagnostics(db, config, file_id))
532 } 532 }
533 533
534 /// Convenience function to return assists + quick fixes for diagnostics
535 pub fn assists_with_fixes(
536 &self,
537 assist_config: &AssistConfig,
538 diagnostics_config: &DiagnosticsConfig,
539 resolve: bool,
540 frange: FileRange,
541 ) -> Cancelable<Vec<Assist>> {
542 let include_fixes = match &assist_config.allowed {
543 Some(it) => it.iter().any(|&it| it == AssistKind::None || it == AssistKind::QuickFix),
544 None => true,
545 };
546
547 self.with_db(|db| {
548 let mut res = Assist::get(db, assist_config, resolve, frange);
549 ssr::add_ssr_assist(db, &mut res, resolve, frange);
550
551 if include_fixes {
552 res.extend(
553 diagnostics::diagnostics(db, diagnostics_config, frange.file_id)
554 .into_iter()
555 .filter_map(|it| it.fix),
556 );
557 }
558 res
559 })
560 }
561
534 /// Returns the edit required to rename reference at the position to the new 562 /// Returns the edit required to rename reference at the position to the new
535 /// name. 563 /// name.
536 pub fn rename( 564 pub fn rename(