aboutsummaryrefslogtreecommitdiff
path: root/bin/src/traits.rs
diff options
context:
space:
mode:
Diffstat (limited to 'bin/src/traits.rs')
-rw-r--r--bin/src/traits.rs18
1 files changed, 16 insertions, 2 deletions
diff --git a/bin/src/traits.rs b/bin/src/traits.rs
index 465abe4..a8ec70f 100644
--- a/bin/src/traits.rs
+++ b/bin/src/traits.rs
@@ -9,6 +9,7 @@ use ariadne::{
9 CharSet, Color, Config as CliConfig, Fmt, Label, LabelAttach, Report as CliReport, 9 CharSet, Color, Config as CliConfig, Fmt, Label, LabelAttach, Report as CliReport,
10 ReportKind as CliReportKind, Source, 10 ReportKind as CliReportKind, Source,
11}; 11};
12use lib::Severity;
12use rnix::{TextRange, TextSize}; 13use rnix::{TextRange, TextSize};
13use vfs::ReadOnlyVfs; 14use vfs::ReadOnlyVfs;
14 15
@@ -57,11 +58,16 @@ fn write_stderr<T: Write>(
57 .map(|d| d.at.start().into()) 58 .map(|d| d.at.start().into())
58 .min() 59 .min()
59 .unwrap_or(0usize); 60 .unwrap_or(0usize);
61 let report_kind = match report.severity {
62 Severity::Warn => CliReportKind::Warning,
63 Severity::Error => CliReportKind::Error,
64 Severity::Hint => CliReportKind::Advice,
65 };
60 report 66 report
61 .diagnostics 67 .diagnostics
62 .iter() 68 .iter()
63 .fold( 69 .fold(
64 CliReport::build(CliReportKind::Warning, src_id, offset) 70 CliReport::build(report_kind, src_id, offset)
65 .with_config( 71 .with_config(
66 CliConfig::default() 72 CliConfig::default()
67 .with_cross_gap(true) 73 .with_cross_gap(true)
@@ -103,7 +109,11 @@ fn write_errfmt<T: Write>(
103 filename = path.to_str().unwrap_or("<unknown>"), 109 filename = path.to_str().unwrap_or("<unknown>"),
104 linenumber = line, 110 linenumber = line,
105 columnnumber = col, 111 columnnumber = col,
106 errortype = "W", 112 errortype = match report.severity {
113 Severity::Warn => "W",
114 Severity::Error => "E",
115 Severity::Hint => "I", /* "info" message */
116 },
107 errornumber = report.code, 117 errornumber = report.code,
108 errormessage = diagnostic.message 118 errormessage = diagnostic.message
109 )?; 119 )?;
@@ -118,6 +128,7 @@ mod json {
118 128
119 use std::io::{self, Write}; 129 use std::io::{self, Write};
120 130
131 use lib::Severity;
121 use rnix::TextRange; 132 use rnix::TextRange;
122 use serde::Serialize; 133 use serde::Serialize;
123 use serde_json; 134 use serde_json;
@@ -134,6 +145,7 @@ mod json {
134 struct JsonReport<'μ> { 145 struct JsonReport<'μ> {
135 note: &'static str, 146 note: &'static str,
136 code: u32, 147 code: u32,
148 severity: &'μ Severity,
137 diagnostics: Vec<JsonDiagnostic<'μ>>, 149 diagnostics: Vec<JsonDiagnostic<'μ>>,
138 } 150 }
139 151
@@ -192,6 +204,7 @@ mod json {
192 .map(|r| { 204 .map(|r| {
193 let note = r.note; 205 let note = r.note;
194 let code = r.code; 206 let code = r.code;
207 let severity = &r.severity;
195 let diagnostics = r 208 let diagnostics = r
196 .diagnostics 209 .diagnostics
197 .iter() 210 .iter()
@@ -207,6 +220,7 @@ mod json {
207 JsonReport { 220 JsonReport {
208 note, 221 note,
209 code, 222 code,
223 severity,
210 diagnostics, 224 diagnostics,
211 } 225 }
212 }) 226 })