aboutsummaryrefslogtreecommitdiff
path: root/crates/ide/src/diagnostics.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ide/src/diagnostics.rs')
-rw-r--r--crates/ide/src/diagnostics.rs13
1 files changed, 4 insertions, 9 deletions
diff --git a/crates/ide/src/diagnostics.rs b/crates/ide/src/diagnostics.rs
index 1f85805d2..3c36c0e15 100644
--- a/crates/ide/src/diagnostics.rs
+++ b/crates/ide/src/diagnostics.rs
@@ -19,7 +19,7 @@ use syntax::{
19}; 19};
20use text_edit::TextEdit; 20use text_edit::TextEdit;
21 21
22use crate::{FileId, SourceChange, SourceFileEdit}; 22use crate::{FileId, Label, SourceChange, SourceFileEdit};
23 23
24use self::fixes::DiagnosticWithFix; 24use self::fixes::DiagnosticWithFix;
25 25
@@ -34,20 +34,15 @@ pub struct Diagnostic {
34 34
35#[derive(Debug)] 35#[derive(Debug)]
36pub struct Fix { 36pub struct Fix {
37 pub label: String, 37 pub label: Label,
38 pub source_change: SourceChange, 38 pub source_change: SourceChange,
39 /// Allows to trigger the fix only when the caret is in the range given 39 /// Allows to trigger the fix only when the caret is in the range given
40 pub fix_trigger_range: TextRange, 40 pub fix_trigger_range: TextRange,
41} 41}
42 42
43impl Fix { 43impl Fix {
44 fn new( 44 fn new(label: &str, source_change: SourceChange, fix_trigger_range: TextRange) -> Self {
45 label: impl Into<String>, 45 let label = Label::new(label);
46 source_change: SourceChange,
47 fix_trigger_range: TextRange,
48 ) -> Self {
49 let label = label.into();
50 assert!(label.starts_with(char::is_uppercase) && !label.ends_with('.'));
51 Self { label, source_change, fix_trigger_range } 46 Self { label, source_change, fix_trigger_range }
52 } 47 }
53} 48}