De-emph minimized spans, add better debugging output
This commit is contained in:
parent
ae1e73affe
commit
3e9747af49
4 changed files with 37 additions and 17 deletions
|
@ -526,6 +526,10 @@ impl Destination {
|
||||||
}
|
}
|
||||||
Style::OldSkoolNote => {
|
Style::OldSkoolNote => {
|
||||||
self.start_attr(term::Attr::Bold)?;
|
self.start_attr(term::Attr::Bold)?;
|
||||||
|
self.start_attr(term::Attr::ForegroundColor(term::color::BRIGHT_GREEN))?;
|
||||||
|
}
|
||||||
|
Style::OldSkoolNoteText => {
|
||||||
|
self.start_attr(term::Attr::Bold)?;
|
||||||
}
|
}
|
||||||
Style::UnderlinePrimary | Style::LabelPrimary => {
|
Style::UnderlinePrimary | Style::LabelPrimary => {
|
||||||
self.start_attr(term::Attr::Bold)?;
|
self.start_attr(term::Attr::Bold)?;
|
||||||
|
|
|
@ -58,6 +58,9 @@ struct Annotation {
|
||||||
/// Is this annotation derived from primary span
|
/// Is this annotation derived from primary span
|
||||||
is_primary: bool,
|
is_primary: bool,
|
||||||
|
|
||||||
|
/// Is this a large span minimized down to a smaller span
|
||||||
|
is_minimized: bool,
|
||||||
|
|
||||||
/// Optional label to display adjacent to the annotation.
|
/// Optional label to display adjacent to the annotation.
|
||||||
label: Option<String>,
|
label: Option<String>,
|
||||||
}
|
}
|
||||||
|
@ -90,6 +93,7 @@ pub enum Style {
|
||||||
UnderlineSecondary,
|
UnderlineSecondary,
|
||||||
LabelPrimary,
|
LabelPrimary,
|
||||||
LabelSecondary,
|
LabelSecondary,
|
||||||
|
OldSkoolNoteText,
|
||||||
OldSkoolNote,
|
OldSkoolNote,
|
||||||
NoStyle,
|
NoStyle,
|
||||||
}
|
}
|
||||||
|
@ -383,10 +387,10 @@ impl FileInfo {
|
||||||
// Basically, although this loses information, multi-line spans just
|
// Basically, although this loses information, multi-line spans just
|
||||||
// never look good.
|
// never look good.
|
||||||
|
|
||||||
let (line, start_col, mut end_col) = if lines.len() == 1 {
|
let (line, start_col, mut end_col, is_minimized) = if lines.len() == 1 {
|
||||||
(lines[0].line_index, lines[0].start_col, lines[0].end_col)
|
(lines[0].line_index, lines[0].start_col, lines[0].end_col, false)
|
||||||
} else {
|
} else {
|
||||||
(lines[0].line_index, lines[0].start_col, CharPos(lines[0].start_col.0 + 1))
|
(lines[0].line_index, lines[0].start_col, CharPos(lines[0].start_col.0 + 1), true)
|
||||||
};
|
};
|
||||||
|
|
||||||
// Watch out for "empty spans". If we get a span like 6..6, we
|
// Watch out for "empty spans". If we get a span like 6..6, we
|
||||||
|
@ -402,6 +406,7 @@ impl FileInfo {
|
||||||
self.lines[index].push_annotation(start_col,
|
self.lines[index].push_annotation(start_col,
|
||||||
end_col,
|
end_col,
|
||||||
is_primary,
|
is_primary,
|
||||||
|
is_minimized,
|
||||||
label);
|
label);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -498,6 +503,7 @@ impl FileInfo {
|
||||||
match self.primary_span {
|
match self.primary_span {
|
||||||
Some(span) => {
|
Some(span) => {
|
||||||
let lo = codemap.lookup_char_pos(span.lo);
|
let lo = codemap.lookup_char_pos(span.lo);
|
||||||
|
let hi = codemap.lookup_char_pos(span.hi);
|
||||||
//Before each secondary line in old skool-mode, print the label
|
//Before each secondary line in old skool-mode, print the label
|
||||||
//as an old-style note
|
//as an old-style note
|
||||||
if !line.annotations[0].is_primary {
|
if !line.annotations[0].is_primary {
|
||||||
|
@ -507,14 +513,15 @@ impl FileInfo {
|
||||||
text: lo.file.name.clone(),
|
text: lo.file.name.clone(),
|
||||||
style: Style::FileNameStyle,
|
style: Style::FileNameStyle,
|
||||||
}, StyledString {
|
}, StyledString {
|
||||||
text: format!(":{}:{}: ", lo.line, lo.col.0 + 1),
|
text: format!(":{}:{}: {}:{} ", lo.line, lo.col.0 + 1,
|
||||||
|
hi.line, hi.col.0+1),
|
||||||
style: Style::LineAndColumn,
|
style: Style::LineAndColumn,
|
||||||
}, StyledString {
|
}, StyledString {
|
||||||
text: format!("note: "),
|
text: format!("note: "),
|
||||||
style: Style::LabelSecondary,
|
style: Style::OldSkoolNote,
|
||||||
}, StyledString {
|
}, StyledString {
|
||||||
text: format!("{}", ann),
|
text: format!("{}", ann),
|
||||||
style: Style::OldSkoolNote,
|
style: Style::OldSkoolNoteText,
|
||||||
}],
|
}],
|
||||||
kind: RenderedLineKind::Annotations,
|
kind: RenderedLineKind::Annotations,
|
||||||
});
|
});
|
||||||
|
@ -621,7 +628,7 @@ impl FileInfo {
|
||||||
if annotation.is_primary {
|
if annotation.is_primary {
|
||||||
Style::UnderlinePrimary
|
Style::UnderlinePrimary
|
||||||
} else {
|
} else {
|
||||||
Style::UnderlineSecondary
|
Style::OldSkoolNote
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -629,7 +636,7 @@ impl FileInfo {
|
||||||
if annotation.is_primary {
|
if annotation.is_primary {
|
||||||
Style::UnderlinePrimary
|
Style::UnderlinePrimary
|
||||||
} else {
|
} else {
|
||||||
Style::UnderlineSecondary
|
Style::OldSkoolNote
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -638,10 +645,14 @@ impl FileInfo {
|
||||||
for p in annotation.start_col .. annotation.end_col {
|
for p in annotation.start_col .. annotation.end_col {
|
||||||
if annotation.is_primary {
|
if annotation.is_primary {
|
||||||
styled_buffer.putc(1, p, '^', Style::UnderlinePrimary);
|
styled_buffer.putc(1, p, '^', Style::UnderlinePrimary);
|
||||||
styled_buffer.set_style(0, p, Style::UnderlinePrimary);
|
if !annotation.is_minimized {
|
||||||
|
styled_buffer.set_style(0, p, Style::UnderlinePrimary);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
styled_buffer.putc(1, p, '-', Style::UnderlineSecondary);
|
styled_buffer.putc(1, p, '-', Style::UnderlineSecondary);
|
||||||
styled_buffer.set_style(0, p, Style::UnderlineSecondary);
|
if !annotation.is_minimized {
|
||||||
|
styled_buffer.set_style(0, p, Style::UnderlineSecondary);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -842,11 +853,13 @@ impl Line {
|
||||||
start: CharPos,
|
start: CharPos,
|
||||||
end: CharPos,
|
end: CharPos,
|
||||||
is_primary: bool,
|
is_primary: bool,
|
||||||
|
is_minimized: bool,
|
||||||
label: Option<String>) {
|
label: Option<String>) {
|
||||||
self.annotations.push(Annotation {
|
self.annotations.push(Annotation {
|
||||||
start_col: start.0,
|
start_col: start.0,
|
||||||
end_col: end.0,
|
end_col: end.0,
|
||||||
is_primary: is_primary,
|
is_primary: is_primary,
|
||||||
|
is_minimized: is_minimized,
|
||||||
label: label,
|
label: label,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@ use errors::{Error, ErrorKind};
|
||||||
use rustc_serialize::json;
|
use rustc_serialize::json;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
use runtest::{fatal_proc_rec, ProcRes};
|
||||||
|
|
||||||
// These structs are a subset of the ones found in
|
// These structs are a subset of the ones found in
|
||||||
// `syntax::errors::json`.
|
// `syntax::errors::json`.
|
||||||
|
@ -55,13 +56,13 @@ struct DiagnosticCode {
|
||||||
explanation: Option<String>,
|
explanation: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn parse_output(file_name: &str, output: &str) -> Vec<Error> {
|
pub fn parse_output(file_name: &str, output: &str, proc_res: &ProcRes) -> Vec<Error> {
|
||||||
output.lines()
|
output.lines()
|
||||||
.flat_map(|line| parse_line(file_name, line))
|
.flat_map(|line| parse_line(file_name, line, output, proc_res))
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_line(file_name: &str, line: &str) -> Vec<Error> {
|
fn parse_line(file_name: &str, line: &str, output: &str, proc_res: &ProcRes) -> Vec<Error> {
|
||||||
// The compiler sometimes intermingles non-JSON stuff into the
|
// The compiler sometimes intermingles non-JSON stuff into the
|
||||||
// output. This hack just skips over such lines. Yuck.
|
// output. This hack just skips over such lines. Yuck.
|
||||||
if line.chars().next() == Some('{') {
|
if line.chars().next() == Some('{') {
|
||||||
|
@ -72,7 +73,9 @@ fn parse_line(file_name: &str, line: &str) -> Vec<Error> {
|
||||||
expected_errors
|
expected_errors
|
||||||
}
|
}
|
||||||
Err(error) => {
|
Err(error) => {
|
||||||
panic!("failed to decode compiler output as json: `{}`", error);
|
fatal_proc_rec(None, &format!(
|
||||||
|
"failed to decode compiler output as json: `{}`\noutput: {}\nline: {}",
|
||||||
|
error, line, output), proc_res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1001,7 +1001,7 @@ actual:\n\
|
||||||
let expect_note = expected_errors.iter().any(|ee| ee.kind == Some(ErrorKind::Note));
|
let expect_note = expected_errors.iter().any(|ee| ee.kind == Some(ErrorKind::Note));
|
||||||
|
|
||||||
// Parse the JSON output from the compiler and extract out the messages.
|
// Parse the JSON output from the compiler and extract out the messages.
|
||||||
let actual_errors = json::parse_output(&file_name, &proc_res.stderr);
|
let actual_errors = json::parse_output(&file_name, &proc_res.stderr, &proc_res);
|
||||||
let mut unexpected = 0;
|
let mut unexpected = 0;
|
||||||
let mut not_found = 0;
|
let mut not_found = 0;
|
||||||
let mut found = vec![false; expected_errors.len()];
|
let mut found = vec![false; expected_errors.len()];
|
||||||
|
@ -1528,7 +1528,7 @@ actual:\n\
|
||||||
self.error(err); panic!();
|
self.error(err); panic!();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fatal_proc_rec(&self, err: &str, proc_res: &ProcRes) -> ! {
|
pub fn fatal_proc_rec(&self, err: &str, proc_res: &ProcRes) -> ! {
|
||||||
self.error(err);
|
self.error(err);
|
||||||
print!("\
|
print!("\
|
||||||
status: {}\n\
|
status: {}\n\
|
||||||
|
@ -2197,7 +2197,7 @@ struct ProcArgs {
|
||||||
args: Vec<String>,
|
args: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ProcRes {
|
pub struct ProcRes {
|
||||||
status: Status,
|
status: Status,
|
||||||
stdout: String,
|
stdout: String,
|
||||||
stderr: String,
|
stderr: String,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue