2 // valac TreeBuilder.vala --pkg libvala-0.24 --pkg posix -o /tmp/treebuilder
4 public class MyReport : Vala.Report {
6 public overide void err (Vala.SourceReference? source, string message) {
9 stderr.printf ("My error: %s\n", message);
11 stderr.printf ("%s: My error: %s\n", source.to_string (), message);
13 this.report_source (source);
20 public class TreeBuilder : Vala.CodeVisitor {
22 public Vala.CodeContext create_valac_tree () {
24 var context = new Vala.CodeContext ();
25 Vala.CodeContext.push (context);
27 context.experimental = false;
28 context.experimental_non_null = false;
29 context.vapi_directories = { "/usr/share/vala-0.24/vapi" };
30 context.report.enable_warnings = true;
31 context.metadata_directories = { };
32 context.gir_directories = {};
35 context.basedir = Posix.realpath (".");
37 context.directory = context.basedir;
40 // add default packages:
41 //if (settings.profile == "gobject-2.0" || settings.profile == "gobject" || settings.profile == null) {
42 context.profile = Vala.Profile.GOBJECT;
43 // context.add_define ("GOBJECT");
45 //add_depencies (context, settings.packages);
46 //if (reporter.errors > 0) {
50 var source_file = new Vala.SourceFile (context,
51 Vala.SourceFileType.SOURCE,
52 "/home/alan/gitlive/app.Builder.js/tests/TreeBuilder.vala");
54 //if (source_package == null) {
55 //source_package = register_package (new Package (settings.pkg_name, false, null));
58 //register_source_file (source_package, source_file);
60 //if (context.profile == Vala.Profile.GOBJECT) {
61 // import the GLib namespace by default (namespace of backend-specific standard library)
62 var ns_ref = new Vala.UsingDirective (new Vala.UnresolvedSymbol (null, "GLib", null));
63 source_file.add_using_directive (ns_ref);
64 context.root.add_using_directive (ns_ref);
67 context.add_source_file (source_file);
70 //add_documented_files (context, settings.source_files);
72 Vala.Parser parser = new Vala.Parser ();
73 parser.parse (context);
74 //gir_parser.parse (context);
75 if (context.report.get_errors () > 0) {
84 if (context.report.get_errors () > 0) {
95 int main (string[] args) {
97 var a = new TreeBuilder();
98 a.create_valac_tree();