compiler: print warnings in magenta
parent
0106eb1cf6
commit
6b08cbcb7a
|
@ -70,14 +70,14 @@ pub fn formatted_error(kind, emsg, filepath string, pos token.Position) string {
|
|||
}
|
||||
column := imax(0, pos.pos - p - 1)
|
||||
position := '${path}:${pos.line_nr+1}:${util.imax(1,column+1)}:'
|
||||
scontext := source_context(source, column, pos).join('\n')
|
||||
scontext := source_context(kind, source, column, pos).join('\n')
|
||||
final_position := if emanager.support_color { term.bold(position) } else { position }
|
||||
mut final_kind := kind
|
||||
if emanager.support_color {
|
||||
final_kind = if kind.contains('error') {
|
||||
term.bold(term.red(kind))
|
||||
} else {
|
||||
term.bold(term.bright_blue(kind))
|
||||
term.bold(term.magenta(kind))
|
||||
}
|
||||
}
|
||||
final_msg := emsg // if emanager.support_color { term.bold(emsg) } else { emsg }
|
||||
|
@ -86,7 +86,7 @@ pub fn formatted_error(kind, emsg, filepath string, pos token.Position) string {
|
|||
return '$final_position $final_kind $final_msg $final_context'.trim_space()
|
||||
}
|
||||
|
||||
pub fn source_context(source string, column int, pos token.Position) []string {
|
||||
pub fn source_context(kind, source string, column int, pos token.Position) []string {
|
||||
mut clines := []string{}
|
||||
if source.len == 0 {
|
||||
return clines
|
||||
|
@ -99,7 +99,11 @@ pub fn source_context(source string, column int, pos token.Position) []string {
|
|||
sline := source_lines[iline]
|
||||
mut cline := '${iline+1:5d}| ' + sline.replace('\t', tab_spaces)
|
||||
if iline == pos.line_nr && emanager.support_color {
|
||||
cline = term.red(cline)
|
||||
cline = if kind.contains('error') {
|
||||
term.red(cline)
|
||||
} else {
|
||||
term.magenta(cline)
|
||||
}
|
||||
}
|
||||
clines << cline
|
||||
//
|
||||
|
|
Loading…
Reference in New Issue