diff options
author | Aleksey Kladov <[email protected]> | 2020-05-22 17:03:08 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2020-05-22 17:04:26 +0100 |
commit | 2c04aad2d2a52ce52d6ea6452faf8d1788f0c83f (patch) | |
tree | 281b8320f78424383e0f45f2bfd678c07a5360ae /crates/ra_ide/src/lib.rs | |
parent | 2075e77ee5784e72396c64c9ca059763508219ff (diff) |
KISS SourceChange
The idea behind requiring the label is a noble one, but we are not
really using it consistently anyway, and it should be easy to retrofit
later, should we need it.
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 | ||