aboutsummaryrefslogtreecommitdiff
path: root/crates/ide/src/diagnostics/fixes.rs
blob: a2e792b3b61a43997906e2fede40dcf8aec551d2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
//! Provides a way to attach fixes to the diagnostics.
//! The same module also has all curret custom fixes for the diagnostics implemented.
mod change_case;
mod create_field;
mod remove_semicolon;
mod replace_with_find_map;
mod wrap_tail_expr;

use hir::{diagnostics::Diagnostic, Semantics};
use ide_assists::AssistResolveStrategy;
use ide_db::RootDatabase;

use crate::Assist;

/// A [Diagnostic] that potentially has some fixes available.
///
/// [Diagnostic]: hir::diagnostics::Diagnostic
pub(crate) trait DiagnosticWithFixes: Diagnostic {
    /// `resolve` determines if the diagnostic should fill in the `edit` field
    /// of the assist.
    ///
    /// If `resolve` is false, the edit will be computed later, on demand, and
    /// can be omitted.
    fn fixes(
        &self,
        sema: &Semantics<RootDatabase>,
        _resolve: &AssistResolveStrategy,
    ) -> Option<Vec<Assist>>;
}