improve json output for suggestions, bump to v0.2.5

This commit is contained in:
Akshay 2021-10-28 17:27:16 +05:30
parent 6e8dd004ea
commit c3cede18c9
4 changed files with 14 additions and 6 deletions

2
Cargo.lock generated
View File

@ -388,7 +388,7 @@ checksum = "b203e79e90905594272c1c97c7af701533d42adaab0beb3859018e477d54a3b0"
[[package]]
name = "statix"
version = "0.2.4"
version = "0.2.5"
dependencies = [
"ariadne",
"clap",

View File

@ -1,6 +1,6 @@
[package]
name = "statix"
version = "0.2.4"
version = "0.2.5"
edition = "2018"
license = "MIT"
authors = [ "Akshay <nerdy@peppe.rs>" ]

View File

@ -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>,
suggestion: Option<JsonSuggestion>,
}
#[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::<Vec<_>>();
JsonReport {

View File

@ -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";