2 // valac TreeBuilder.vala --pkg libvala-0.24 --pkg posix -o /tmp/treebuilder
6 public class MyReport : Vala.Report {
8 public override void err (Vala.SourceReference? source, string message) {
11 stderr.printf ("My error: %s\n", message);
13 stderr.printf ("%s: My error: %s\n", source.to_string (), message);
15 //Vala.Report.report_source (source);
23 public class TreeBuilder : Vala.CodeVisitor {
25 public Vala.CodeContext check (JsRender.Gtk file) {
30 var context = new Vala.CodeContext ();
31 Vala.CodeContext.push (context);
33 context.experimental = false;
34 context.experimental_non_null = false;
35 context.vapi_directories = { "/usr/share/vala-0.24/vapi" };
36 context.report.enable_warnings = true;
37 context.metadata_directories = { };
38 context.gir_directories = {};
39 context.report = new MyReport();
41 context.basedir = Posix.realpath (".");
43 context.directory = context.basedir;
46 // add default packages:
47 //if (settings.profile == "gobject-2.0" || settings.profile == "gobject" || settings.profile == null) {
48 context.profile = Vala.Profile.GOBJECT;
49 // context.add_define ("GOBJECT");
51 //add_depencies (context, settings.packages);
52 //if (reporter.errors > 0) {
56 var source_file = new Vala.SourceFile (
58 Vala.SourceFileType.SOURCE,
61 //context.add_source_file (testcode);
64 // source_file = new Vala.SourceFile (context,
65 // Vala.SourceFileType.SOURCE,
66 // "/home/alan/gitlive/app.Builder.js/tests/TreeBuilder.vala");
68 //if (source_package == null) {
69 //source_package = register_package (new Package (settings.pkg_name, false, null));
72 //register_source_file (source_package, source_file);
74 context.add_external_package ("glib-2.0");
75 context.add_external_package ("gobject-2.0");
76 context.add_external_package ("libvala-0.24");
77 //context.add_external_package ("posix");
78 //if (context.profile == Vala.Profile.GOBJECT) {
79 // import the GLib namespace by default (namespace of backend-specific standard library)
80 var ns_ref = new Vala.UsingDirective (new Vala.UnresolvedSymbol (null, "GLib", null));
81 source_file.add_using_directive (ns_ref);
82 context.root.add_using_directive (ns_ref);
85 context.add_source_file (source_file);
88 //add_documented_files (context, settings.source_files);
90 Vala.Parser parser = new Vala.Parser ();
91 parser.parse (context);
92 //gir_parser.parse (context);
93 if (context.report.get_errors () > 0) {
102 if (context.report.get_errors () > 0) {
103 print("check got errors");
115 int main (string[] args) {
117 var a = new TreeBuilder();
118 a.create_valac_tree();