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);
16 stderr.printf ("%s: My error: %s\n", source.to_string (), message);
18 //Vala.Report.report_source (source);
26 public class ValaSource : Vala.CodeVisitor {
28 public Vala.CodeContext check (JsRender.Gtk file) {
33 var context = new Vala.CodeContext ();
34 Vala.CodeContext.push (context);
36 context.experimental = false;
37 context.experimental_non_null = false;
38 context.vapi_directories = { "/usr/share/vala-0.24/vapi" };
39 context.report.enable_warnings = true;
40 context.metadata_directories = { };
41 context.gir_directories = {};
42 context.report = new ValaSourceReport();
44 context.basedir = Posix.realpath (".");
46 context.directory = context.basedir;
49 // add default packages:
50 //if (settings.profile == "gobject-2.0" || settings.profile == "gobject" || settings.profile == null) {
51 context.profile = Vala.Profile.GOBJECT;
52 // context.add_define ("GOBJECT");
54 //add_depencies (context, settings.packages);
55 //if (reporter.errors > 0) {
59 var source_file = new Vala.SourceFile (
61 Vala.SourceFileType.SOURCE,
64 //context.add_source_file (testcode);
67 // source_file = new Vala.SourceFile (context,
68 // Vala.SourceFileType.SOURCE,
69 // "/home/alan/gitlive/app.Builder.js/tests/TreeBuilder.vala");
71 //if (source_package == null) {
72 //source_package = register_package (new Package (settings.pkg_name, false, null));
75 //register_source_file (source_package, source_file);
77 context.add_external_package ("glib-2.0");
78 context.add_external_package ("gobject-2.0");
79 context.add_external_package ("libvala-0.24");
80 //context.add_external_package ("posix");
81 //if (context.profile == Vala.Profile.GOBJECT) {
82 // import the GLib namespace by default (namespace of backend-specific standard library)
83 var ns_ref = new Vala.UsingDirective (new Vala.UnresolvedSymbol (null, "GLib", null));
84 source_file.add_using_directive (ns_ref);
85 context.root.add_using_directive (ns_ref);
88 context.add_source_file (source_file);
91 //add_documented_files (context, settings.source_files);
93 Vala.Parser parser = new Vala.Parser ();
94 parser.parse (context);
95 //gir_parser.parse (context);
96 if (context.report.get_errors () > 0) {
105 if (context.report.get_errors () > 0) {
106 print("check got errors");
118 int main (string[] args) {
120 var a = new TreeBuilder();
121 a.create_valac_tree();