X-Git-Url: http://git.roojs.org/?a=blobdiff_plain;f=tests%2FTreeBuilder.vala;h=fa9147403817c8c23595c2879a0639ac886b4b7d;hb=fd48eb7398d7c37db2fd01eaf7fbfb3bfc288a9e;hp=2e182d8903aac0000419e1fe945d4f4b32306a7f;hpb=f157e4b046af76f8f486ef5ea59fd6256bac848f;p=app.Builder.js diff --git a/tests/TreeBuilder.vala b/tests/TreeBuilder.vala index 2e182d890..fa9147403 100644 --- a/tests/TreeBuilder.vala +++ b/tests/TreeBuilder.vala @@ -4,30 +4,47 @@ namespace Palete { public class ValaSourceReport : Vala.Report { - + + + + + Gee.HashMap line_errors; + + public ValaSourceReport() + { + base(); + this.line_errors = new Gee.HashMap (); + } + public override void err (Vala.SourceReference? source, string message) { errors++; if (source == null) { - stderr.printf ("My error: %s\n", message); - } else { - stderr.printf ("%s: My error: %s\n", source.to_string (), message); - - //Vala.Report.report_source (source); - + return; + //stderr.printf ("My error: %s\n", message); + } + if (source.file != "~~~~~testfile.vala") { + return; } + var pre = ""; + if (line_errors.has_key(source.begin.line)) { + pre = line_errors.get(source.begin.line) + "\n"; + + } + line_errors.set(source.begin.line, pre + message); } } public class ValaSource : Vala.CodeVisitor { - - public Vala.CodeContext check (JsRender.Gtk file) { - // init context: + Vala.CodeContext context; + + public ValaSource(JsRender.Gtk file) { + base(); + // init context: - - var context = new Vala.CodeContext (); + context = new Vala.CodeContext (); Vala.CodeContext.push (context); context.experimental = false; @@ -56,6 +73,7 @@ namespace Palete { var source_file = new Vala.SourceFile ( context, Vala.SourceFileType.SOURCE, + "~~~~~testfile.vala", file.toSource() ); //context.add_source_file (testcode); @@ -92,7 +110,8 @@ namespace Palete { //gir_parser.parse (context); if (context.report.get_errors () > 0) { print("got errors"); - return context; + Vala.CodeContext.pop (context); + return; } @@ -101,10 +120,12 @@ namespace Palete { context.check (); if (context.report.get_errors () > 0) { print("check got errors"); - return context; + Vala.CodeContext.pop (context); + return; } + Vala.CodeContext.pop (context); print("ALL OK?\n"); - return context; + return; } // // startpoint: @@ -114,7 +135,7 @@ namespace Palete { int main (string[] args) { - var a = new TreeBuilder(); + var a = new ValaSource(); a.create_valac_tree(); return 0; }