aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide/src/lib.rs
diff options
context:
space:
mode:
authorKirill Bulatov <[email protected]>2020-08-11 15:13:40 +0100
committerKirill Bulatov <[email protected]>2020-08-11 15:13:40 +0100
commit188ec3459e795732ad097758f7bf6b6b95bdbf5e (patch)
treeb24e4118f73f9828616fa97f16a499fc78bae656 /crates/ra_ide/src/lib.rs
parent37aa68f050fae0079db7b6ebd81bacea4441fb7e (diff)
Simplify fix structure
Diffstat (limited to 'crates/ra_ide/src/lib.rs')
-rw-r--r--crates/ra_ide/src/lib.rs12
1 files changed, 9 insertions, 3 deletions
diff --git a/crates/ra_ide/src/lib.rs b/crates/ra_ide/src/lib.rs
index 45a4b2421..89fcb6f17 100644
--- a/crates/ra_ide/src/lib.rs
+++ b/crates/ra_ide/src/lib.rs
@@ -105,20 +105,26 @@ pub struct Diagnostic {
105 pub message: String, 105 pub message: String,
106 pub range: TextRange, 106 pub range: TextRange,
107 pub severity: Severity, 107 pub severity: Severity,
108 pub fix: Option<(Fix, TextRange)>, 108 pub fix: Option<Fix>,
109} 109}
110 110
111#[derive(Debug)] 111#[derive(Debug)]
112pub struct Fix { 112pub struct Fix {
113 pub label: String, 113 pub label: String,
114 pub source_change: SourceChange, 114 pub source_change: SourceChange,
115 /// Allows to trigger the fix only when the caret is in the range given
116 pub fix_trigger_range: TextRange,
115} 117}
116 118
117impl Fix { 119impl Fix {
118 pub fn new(label: impl Into<String>, source_change: SourceChange) -> Self { 120 pub fn new(
121 label: impl Into<String>,
122 source_change: SourceChange,
123 fix_trigger_range: TextRange,
124 ) -> Self {
119 let label = label.into(); 125 let label = label.into();
120 assert!(label.starts_with(char::is_uppercase) && !label.ends_with('.')); 126 assert!(label.starts_with(char::is_uppercase) && !label.ends_with('.'));
121 Self { label, source_change } 127 Self { label, source_change, fix_trigger_range }
122 } 128 }
123} 129}
124 130