diff options
Diffstat (limited to 'crates/ide')
-rw-r--r-- | crates/ide/src/lib.rs | 28 |
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( |