aboutsummaryrefslogtreecommitdiff
path: root/bin/src/traits.rs
diff options
context:
space:
mode:
authorAkshay <[email protected]>2021-10-28 12:57:16 +0100
committerAkshay <[email protected]>2021-10-28 13:04:59 +0100
commitc3cede18c9440d05385f0a7fd7ae2ef628ce74aa (patch)
tree1bc616ab9e81636bfb3863ab79e5fb0740d472b4 /bin/src/traits.rs
parent6e8dd004ea6fab9be73f0c7999774b3140733ff0 (diff)
improve json output for suggestions, bump to v0.2.5v0.2.5
Diffstat (limited to 'bin/src/traits.rs')
-rw-r--r--bin/src/traits.rs14
1 files changed, 11 insertions, 3 deletions
diff --git a/bin/src/traits.rs b/bin/src/traits.rs
index 5068764..465abe4 100644
--- a/bin/src/traits.rs
+++ b/bin/src/traits.rs
@@ -118,7 +118,6 @@ mod json {
118 118
119 use std::io::{self, Write}; 119 use std::io::{self, Write};
120 120
121 use lib::Suggestion;
122 use rnix::TextRange; 121 use rnix::TextRange;
123 use serde::Serialize; 122 use serde::Serialize;
124 use serde_json; 123 use serde_json;
@@ -142,7 +141,13 @@ mod json {
142 struct JsonDiagnostic<'μ> { 141 struct JsonDiagnostic<'μ> {
143 at: JsonSpan, 142 at: JsonSpan,
144 message: &'μ String, 143 message: &'μ String,
145 suggestion: &'μ Option<Suggestion>, 144 suggestion: Option<JsonSuggestion>,
145 }
146
147 #[derive(Serialize)]
148 struct JsonSuggestion {
149 at: JsonSpan,
150 fix: String,
146 } 151 }
147 152
148 #[derive(Serialize)] 153 #[derive(Serialize)]
@@ -193,7 +198,10 @@ mod json {
193 .map(|d| JsonDiagnostic { 198 .map(|d| JsonDiagnostic {
194 at: JsonSpan::from_textrange(d.at, src), 199 at: JsonSpan::from_textrange(d.at, src),
195 message: &d.message, 200 message: &d.message,
196 suggestion: &d.suggestion, 201 suggestion: d.suggestion.as_ref().map(|s| JsonSuggestion {
202 at: JsonSpan::from_textrange(s.at, src),
203 fix: s.fix.to_string(),
204 }),
197 }) 205 })
198 .collect::<Vec<_>>(); 206 .collect::<Vec<_>>();
199 JsonReport { 207 JsonReport {