Warning
This commit is contained in:
@@ -11,5 +11,5 @@ void main() {
|
||||
// statistics::register(&mut app_instance);
|
||||
|
||||
app_instance.boot();
|
||||
app_instance.rund();
|
||||
app_instance.run();
|
||||
}
|
||||
+30
-2
@@ -20,6 +20,7 @@ pub struct MistDiagnosticMessage {
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum MistDiagnostic {
|
||||
Error(MistDiagnosticMessage),
|
||||
Warning(MistDiagnosticMessage),
|
||||
}
|
||||
|
||||
pub fn build(
|
||||
@@ -51,6 +52,7 @@ pub fn build(
|
||||
.or_insert_with(|| get_mapping(&fs::read_to_string(file_name).unwrap()));
|
||||
|
||||
for span in msg.message.spans {
|
||||
if span.is_primary {
|
||||
let mist_span =
|
||||
find_mapping(&map, &RustMap(span.line_end, span.column_start)).unwrap();
|
||||
|
||||
@@ -59,12 +61,25 @@ pub fn build(
|
||||
.replacen(&config.output, &config.src, 1)
|
||||
.replace(".rs", ".mist");
|
||||
|
||||
diagnostics.push(MistDiagnostic::Error(MistDiagnosticMessage {
|
||||
let mist_msg = MistDiagnosticMessage {
|
||||
message: span.label.unwrap_or(msg.message.message.clone()),
|
||||
src_path: mist_file,
|
||||
line: mist_span.1.0,
|
||||
column: mist_span.1.1,
|
||||
}));
|
||||
};
|
||||
|
||||
match msg.message.level {
|
||||
cargo_metadata::diagnostic::DiagnosticLevel::Error => {
|
||||
diagnostics.push(MistDiagnostic::Error(mist_msg))
|
||||
}
|
||||
|
||||
cargo_metadata::diagnostic::DiagnosticLevel::Warning => {
|
||||
diagnostics.push(MistDiagnostic::Warning(mist_msg))
|
||||
}
|
||||
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,6 +114,19 @@ pub fn print_diagnostics(diagnostics: Vec<MistDiagnostic>) {
|
||||
line.unwrap_or_default(),
|
||||
)
|
||||
}
|
||||
|
||||
MistDiagnostic::Warning(msg) => {
|
||||
let line = get_line(&mut files, &msg);
|
||||
|
||||
println!(
|
||||
"\n{}:{}:{}\n \x1b[33mWarning\x1b[0m: {}\n\t{}",
|
||||
msg.src_path,
|
||||
msg.line + 1,
|
||||
msg.column,
|
||||
msg.message,
|
||||
line.unwrap_or_default(),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user