diff options
Diffstat (limited to 'crates/ra_ide/src/lib.rs')
-rw-r--r-- | crates/ra_ide/src/lib.rs | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/crates/ra_ide/src/lib.rs b/crates/ra_ide/src/lib.rs index 97ff67ee8..5ac002d82 100644 --- a/crates/ra_ide/src/lib.rs +++ b/crates/ra_ide/src/lib.rs | |||
@@ -97,8 +97,22 @@ pub type Cancelable<T> = Result<T, Canceled>; | |||
97 | pub struct Diagnostic { | 97 | pub struct Diagnostic { |
98 | pub message: String, | 98 | pub message: String, |
99 | pub range: TextRange, | 99 | pub range: TextRange, |
100 | pub fix: Option<SourceChange>, | ||
101 | pub severity: Severity, | 100 | pub severity: Severity, |
101 | pub fix: Option<Fix>, | ||
102 | } | ||
103 | |||
104 | #[derive(Debug)] | ||
105 | pub struct Fix { | ||
106 | pub label: String, | ||
107 | pub source_change: SourceChange, | ||
108 | } | ||
109 | |||
110 | impl Fix { | ||
111 | pub fn new(label: impl Into<String>, source_change: SourceChange) -> Self { | ||
112 | let label = label.into(); | ||
113 | assert!(label.starts_with(char::is_uppercase) && !label.ends_with('.')); | ||
114 | Self { label, source_change } | ||
115 | } | ||
102 | } | 116 | } |
103 | 117 | ||
104 | /// Info associated with a text range. | 118 | /// Info associated with a text range. |
@@ -493,7 +507,7 @@ impl Analysis { | |||
493 | ) -> Cancelable<Result<SourceChange, SsrError>> { | 507 | ) -> Cancelable<Result<SourceChange, SsrError>> { |
494 | self.with_db(|db| { | 508 | self.with_db(|db| { |
495 | let edits = ssr::parse_search_replace(query, parse_only, db)?; | 509 | let edits = ssr::parse_search_replace(query, parse_only, db)?; |
496 | Ok(SourceChange::source_file_edits("Structural Search Replace", edits)) | 510 | Ok(SourceChange::source_file_edits(edits)) |
497 | }) | 511 | }) |
498 | } | 512 | } |
499 | 513 | ||