X-Git-Url: http://git.roojs.org/?p=app.Builder.js;a=blobdiff_plain;f=tests%2FTreeBuilder.vala;h=2a368db3cfe0cc7fb4b46e4ce2370076c8a840b4;hp=2217339dceb5a0ff4a0c29e6ca9883d583ed7ba4;hb=6ac1205104814bc5e9132c8655f8f91fdfe102aa;hpb=599810ce30424e6bf223fb6df1d5d290264e2da5 diff --git a/tests/TreeBuilder.vala b/tests/TreeBuilder.vala index 2217339dc..2a368db3c 100644 --- a/tests/TreeBuilder.vala +++ b/tests/TreeBuilder.vala @@ -1,97 +1,120 @@ // valac TreeBuilder.vala --pkg libvala-0.24 --pkg posix -o /tmp/treebuilder -public class MyReport : Vala.Report { +namespace Palete { - 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); + public class ValaSourceReport : Vala.Report { + + + Gee.HashMap line_errors; + + 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); - this.report_source (source); + //Vala.Report.report_source (source); + } } - } -} + } -public class TreeBuilder : Vala.CodeVisitor { + public class ValaSource : Vala.CodeVisitor { - public Vala.CodeContext create_valac_tree () { - // init context: - var context = new Vala.CodeContext (); - Vala.CodeContext.push (context); + public Vala.CodeContext check (JsRender.Gtk file) { + // init context: + + + + var context = new Vala.CodeContext (); + Vala.CodeContext.push (context); - context.experimental = false; - context.experimental_non_null = false; - context.vapi_directories = { "/usr/share/vala-0.24/vapi" }; - context.report.enable_warnings = true; - context.metadata_directories = { }; - context.gir_directories = {}; - context.erport = new MyReport(); + context.experimental = false; + context.experimental_non_null = false; + context.vapi_directories = { "/usr/share/vala-0.24/vapi" }; + context.report.enable_warnings = true; + context.metadata_directories = { }; + context.gir_directories = {}; + context.report = new ValaSourceReport(); - context.basedir = Posix.realpath ("."); + context.basedir = Posix.realpath ("."); - context.directory = context.basedir; + context.directory = context.basedir; - // add default packages: - //if (settings.profile == "gobject-2.0" || settings.profile == "gobject" || settings.profile == null) { - context.profile = Vala.Profile.GOBJECT; - // context.add_define ("GOBJECT"); - //} - //add_depencies (context, settings.packages); - //if (reporter.errors > 0) { - // return context; - //} + // add default packages: + //if (settings.profile == "gobject-2.0" || settings.profile == "gobject" || settings.profile == null) { + context.profile = Vala.Profile.GOBJECT; + // context.add_define ("GOBJECT"); + //} + //add_depencies (context, settings.packages); + //if (reporter.errors > 0) { + // return context; + //} + + var source_file = new Vala.SourceFile ( + context, + Vala.SourceFileType.SOURCE, + file.toSource() + ); + //context.add_source_file (testcode); - var source_file = new Vala.SourceFile (context, - Vala.SourceFileType.SOURCE, - "/home/alan/gitlive/app.Builder.js/tests/TreeBuilder.vala"); + + // source_file = new Vala.SourceFile (context, + // Vala.SourceFileType.SOURCE, + // "/home/alan/gitlive/app.Builder.js/tests/TreeBuilder.vala"); - //if (source_package == null) { - //source_package = register_package (new Package (settings.pkg_name, false, null)); - //} + //if (source_package == null) { + //source_package = register_package (new Package (settings.pkg_name, false, null)); + //} - //register_source_file (source_package, source_file); + //register_source_file (source_package, source_file); - //if (context.profile == Vala.Profile.GOBJECT) { - // import the GLib namespace by default (namespace of backend-specific standard library) - var ns_ref = new Vala.UsingDirective (new Vala.UnresolvedSymbol (null, "GLib", null)); - source_file.add_using_directive (ns_ref); - context.root.add_using_directive (ns_ref); - //} + context.add_external_package ("glib-2.0"); + context.add_external_package ("gobject-2.0"); + context.add_external_package ("libvala-0.24"); + //context.add_external_package ("posix"); + //if (context.profile == Vala.Profile.GOBJECT) { + // import the GLib namespace by default (namespace of backend-specific standard library) + var ns_ref = new Vala.UsingDirective (new Vala.UnresolvedSymbol (null, "GLib", null)); + source_file.add_using_directive (ns_ref); + context.root.add_using_directive (ns_ref); + //} - context.add_source_file (source_file); + context.add_source_file (source_file); - //add_documented_files (context, settings.source_files); + //add_documented_files (context, settings.source_files); - Vala.Parser parser = new Vala.Parser (); - parser.parse (context); - //gir_parser.parse (context); - if (context.report.get_errors () > 0) { - print("got errors"); + Vala.Parser parser = new Vala.Parser (); + parser.parse (context); + //gir_parser.parse (context); + if (context.report.get_errors () > 0) { + print("got errors"); + return context; + } + + + + // check context: + context.check (); + if (context.report.get_errors () > 0) { + print("check got errors"); + return context; + } + print("ALL OK?\n"); return context; } - - - - // check context: - context.check (); - if (context.report.get_errors () > 0) { - return context; - } - return context; - } -// - // startpoint: // - -} + // startpoint: + // + + } int main (string[] args) {