2 // valac TreeBuilder.vala --pkg libvala-0.24 --pkg posix -o /tmp/treebuilder
6 public class ValaSourceReport : Vala.Report {
9 Gee.HashMap<int,string> line_errors;
11 public override void err (Vala.SourceReference? source, string message) {
14 //stderr.printf ("My error: %s\n", message);
17 stderr.printf ("%s: My error: %s\n", source.to_string (), message);
19 //Vala.Report.report_source (source);
27 public class ValaSource : Vala.CodeVisitor {
29 public Vala.CodeContext check (JsRender.Gtk file) {
34 var context = new Vala.CodeContext ();
35 Vala.CodeContext.push (context);
37 context.experimental = false;
38 context.experimental_non_null = false;
39 context.vapi_directories = { "/usr/share/vala-0.24/vapi" };
40 context.report.enable_warnings = true;
41 context.metadata_directories = { };
42 context.gir_directories = {};
43 context.report = new ValaSourceReport();
45 context.basedir = Posix.realpath (".");
47 context.directory = context.basedir;
50 // add default packages:
51 //if (settings.profile == "gobject-2.0" || settings.profile == "gobject" || settings.profile == null) {
52 context.profile = Vala.Profile.GOBJECT;
53 // context.add_define ("GOBJECT");
55 //add_depencies (context, settings.packages);
56 //if (reporter.errors > 0) {
60 var source_file = new Vala.SourceFile (
62 Vala.SourceFileType.SOURCE,
65 //context.add_source_file (testcode);
68 // source_file = new Vala.SourceFile (context,
69 // Vala.SourceFileType.SOURCE,
70 // "/home/alan/gitlive/app.Builder.js/tests/TreeBuilder.vala");
72 //if (source_package == null) {
73 //source_package = register_package (new Package (settings.pkg_name, false, null));
76 //register_source_file (source_package, source_file);
78 context.add_external_package ("glib-2.0");
79 context.add_external_package ("gobject-2.0");
80 context.add_external_package ("libvala-0.24");
81 //context.add_external_package ("posix");
82 //if (context.profile == Vala.Profile.GOBJECT) {
83 // import the GLib namespace by default (namespace of backend-specific standard library)
84 var ns_ref = new Vala.UsingDirective (new Vala.UnresolvedSymbol (null, "GLib", null));
85 source_file.add_using_directive (ns_ref);
86 context.root.add_using_directive (ns_ref);
89 context.add_source_file (source_file);
92 //add_documented_files (context, settings.source_files);
94 Vala.Parser parser = new Vala.Parser ();
95 parser.parse (context);
96 //gir_parser.parse (context);
97 if (context.report.get_errors () > 0) {
106 if (context.report.get_errors () > 0) {
107 print("check got errors");
119 int main (string[] args) {
121 var a = new TreeBuilder();
122 a.create_valac_tree();