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);
17 if (source.file != "~~~~~testfile.vala") {
21 if (line_errors.has_key(source.begin.line)) {
22 pre = line_errors.get(source.begin.line) + "\n";
25 line_errors.set(source.begin.line, pre + message);
31 public class ValaSource : Vala.CodeVisitor {
33 public Vala.CodeContext check (JsRender.Gtk file) {
38 var context = new Vala.CodeContext ();
39 Vala.CodeContext.push (context);
41 context.experimental = false;
42 context.experimental_non_null = false;
43 context.vapi_directories = { "/usr/share/vala-0.24/vapi" };
44 context.report.enable_warnings = true;
45 context.metadata_directories = { };
46 context.gir_directories = {};
47 context.report = new ValaSourceReport();
49 context.basedir = Posix.realpath (".");
51 context.directory = context.basedir;
54 // add default packages:
55 //if (settings.profile == "gobject-2.0" || settings.profile == "gobject" || settings.profile == null) {
56 context.profile = Vala.Profile.GOBJECT;
57 // context.add_define ("GOBJECT");
59 //add_depencies (context, settings.packages);
60 //if (reporter.errors > 0) {
64 var source_file = new Vala.SourceFile (
66 Vala.SourceFileType.SOURCE,
70 //context.add_source_file (testcode);
73 // source_file = new Vala.SourceFile (context,
74 // Vala.SourceFileType.SOURCE,
75 // "/home/alan/gitlive/app.Builder.js/tests/TreeBuilder.vala");
77 //if (source_package == null) {
78 //source_package = register_package (new Package (settings.pkg_name, false, null));
81 //register_source_file (source_package, source_file);
83 context.add_external_package ("glib-2.0");
84 context.add_external_package ("gobject-2.0");
85 context.add_external_package ("libvala-0.24");
86 //context.add_external_package ("posix");
87 //if (context.profile == Vala.Profile.GOBJECT) {
88 // import the GLib namespace by default (namespace of backend-specific standard library)
89 var ns_ref = new Vala.UsingDirective (new Vala.UnresolvedSymbol (null, "GLib", null));
90 source_file.add_using_directive (ns_ref);
91 context.root.add_using_directive (ns_ref);
94 context.add_source_file (source_file);
97 //add_documented_files (context, settings.source_files);
99 Vala.Parser parser = new Vala.Parser ();
100 parser.parse (context);
101 //gir_parser.parse (context);
102 if (context.report.get_errors () > 0) {
111 if (context.report.get_errors () > 0) {
112 print("check got errors");
124 int main (string[] args) {
126 var a = new TreeBuilder();
127 a.create_valac_tree();