3 Object to handle compiler errors
4 so they can be passed off to trees.
6 There are a few things we do with diagnostics
7 a) the popup list with a tree of file => { errors} for each type
8 b) the syntax highlighting.
17 public class CompileError : Object
20 public JsRender.JsRender file = null;
21 public string title = "";
23 public GLib.ListStore lines { get; set ; } // so it triggers updates?
25 //public CompileError? parent = null;
26 public string category = "";
27 public string msg = "";
28 public int line { get; set; default = -1; }
29 public Lsp.Diagnostic? diag = null;
31 public CompileError.new_jserror(JsRender.JsRender file, string category, int line, string msg)
33 this.lines = new GLib.ListStore(typeof(CompileError));
37 this.category = category;
42 public CompileError.new_from_diagnostic(JsRender.JsRender file, Lsp.Diagnostic diag)
45 this.category = diag.category;
46 this.line = (int) diag.range.start.line;
47 this.msg = diag.message;
48 this.lines = new GLib.ListStore(typeof(CompileError));
50 //GLib.debug("new error %s : %d %s %s", file.path, this.line, this.category, this.msg);
56 public CompileError.new_from_file(JsRender.JsRender file, string category)
59 this.category = category;
60 this.lines = new GLib.ListStore(typeof(CompileError));
61 this.title = file.relpath + " (" + lines.get_n_items().to_string() + ")";
64 public string file_line { // sorting?
67 return this.line == -1 ? this.file.relpath :
68 (this.file.relpath + ":" + this.line.to_string("%09d"));
71 public string linemsg {
74 return this.line == -1 ?
75 GLib.Markup.escape_text( this.file.relpath + "(" + this.lines.n_items.to_string() + ")") :
76 GLib.Markup.escape_text(this.line.to_string() + ": " + this.msg);
80 public bool hasErrors() {
81 return this.lines.get_n_items() > 0;