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 --- Cargo.lock | 2 +- bin/Cargo.toml | 2 +- bin/src/traits.rs | 14 +++++++++++--- flake.nix | 2 +- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index cb4a625..1a75d27 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -388,7 +388,7 @@ checksum = "b203e79e90905594272c1c97c7af701533d42adaab0beb3859018e477d54a3b0" [[package]] name = "statix" -version = "0.2.4" +version = "0.2.5" dependencies = [ "ariadne", "clap", 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 { diff --git a/flake.nix b/flake.nix index bb28517..765bea3 100644 --- a/flake.nix +++ b/flake.nix @@ -49,7 +49,7 @@ statix = with final; pkgs.stdenv.mkDerivation { pname = "statix"; - version = "v0.2.4"; + version = "v0.2.5"; src = builtins.path { path = ./.; name = "statix"; -- cgit v1.2.3