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) {
15 //stderr.printf ("My error: %s\n", message);
18 var line = source.begin.line;
20 stderr.printf ("%s: My error: %s\n", source.to_string (), message);
22 //Vala.Report.report_source (source);
30 public class ValaSource : Vala.CodeVisitor {
32 public Vala.CodeContext check (JsRender.Gtk file) {
37 var context = new Vala.CodeContext ();
38 Vala.CodeContext.push (context);
40 context.experimental = false;
41 context.experimental_non_null = false;
42 context.vapi_directories = { "/usr/share/vala-0.24/vapi" };
43 context.report.enable_warnings = true;
44 context.metadata_directories = { };
45 context.gir_directories = {};
46 context.report = new ValaSourceReport();
48 context.basedir = Posix.realpath (".");
50 context.directory = context.basedir;
53 // add default packages:
54 //if (settings.profile == "gobject-2.0" || settings.profile == "gobject" || settings.profile == null) {
55 context.profile = Vala.Profile.GOBJECT;
56 // context.add_define ("GOBJECT");
58 //add_depencies (context, settings.packages);
59 //if (reporter.errors > 0) {
63 var source_file = new Vala.SourceFile (
65 Vala.SourceFileType.SOURCE,
69 //context.add_source_file (testcode);
72 // source_file = new Vala.SourceFile (context,
73 // Vala.SourceFileType.SOURCE,
74 // "/home/alan/gitlive/app.Builder.js/tests/TreeBuilder.vala");
76 //if (source_package == null) {
77 //source_package = register_package (new Package (settings.pkg_name, false, null));
80 //register_source_file (source_package, source_file);
82 context.add_external_package ("glib-2.0");
83 context.add_external_package ("gobject-2.0");
84 context.add_external_package ("libvala-0.24");
85 //context.add_external_package ("posix");
86 //if (context.profile == Vala.Profile.GOBJECT) {
87 // import the GLib namespace by default (namespace of backend-specific standard library)
88 var ns_ref = new Vala.UsingDirective (new Vala.UnresolvedSymbol (null, "GLib", null));
89 source_file.add_using_directive (ns_ref);
90 context.root.add_using_directive (ns_ref);
93 context.add_source_file (source_file);
96 //add_documented_files (context, settings.source_files);
98 Vala.Parser parser = new Vala.Parser ();
99 parser.parse (context);
100 //gir_parser.parse (context);
101 if (context.report.get_errors () > 0) {
110 if (context.report.get_errors () > 0) {
111 print("check got errors");
123 int main (string[] args) {
125 var a = new TreeBuilder();
126 a.create_valac_tree();