From c3cede18c9440d05385f0a7fd7ae2ef628ce74aa Mon Sep 17 00:00:00 2001 From: Akshay Date: Thu, 28 Oct 2021 17:27:16 +0530 Subject: improve json output for suggestions, bump to v0.2.5 --- bin/Cargo.toml | 2 +- bin/src/traits.rs | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) (limited to 'bin') diff --git a/bin/Cargo.toml b/bin/Cargo.toml index 3bbc532..cc15c23 100644 --- a/bin/Cargo.toml +++ b/bin/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "statix" -version = "0.2.4" +version = "0.2.5" edition = "2018" license = "MIT" authors = [ "Akshay " ] 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 { use std::io::{self, Write}; - use lib::Suggestion; use rnix::TextRange; use serde::Serialize; use serde_json; @@ -142,7 +141,13 @@ mod json { struct JsonDiagnostic<'μ> { at: JsonSpan, message: &'μ String, - suggestion: &'μ Option, + suggestion: Option, + } + + #[derive(Serialize)] + struct JsonSuggestion { + at: JsonSpan, + fix: String, } #[derive(Serialize)] @@ -193,7 +198,10 @@ mod json { .map(|d| JsonDiagnostic { at: JsonSpan::from_textrange(d.at, src), message: &d.message, - suggestion: &d.suggestion, + suggestion: d.suggestion.as_ref().map(|s| JsonSuggestion { + at: JsonSpan::from_textrange(s.at, src), + fix: s.fix.to_string(), + }), }) .collect::>(); JsonReport { -- cgit v1.2.3