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") {
20 if (line_errors.has_key(source.begin.line)) {
21 line_errors(source.begin.line
22 var line = source.begin.line;
24 stderr.printf ("%s: My error: %s\n", source.to_string (), message);
26 //Vala.Report.report_source (source);
34 public class ValaSource : Vala.CodeVisitor {
36 public Vala.CodeContext check (JsRender.Gtk file) {
41 var context = new Vala.CodeContext ();
42 Vala.CodeContext.push (context);
44 context.experimental = false;
45 context.experimental_non_null = false;
46 context.vapi_directories = { "/usr/share/vala-0.24/vapi" };
47 context.report.enable_warnings = true;
48 context.metadata_directories = { };
49 context.gir_directories = {};
50 context.report = new ValaSourceReport();
52 context.basedir = Posix.realpath (".");
54 context.directory = context.basedir;
57 // add default packages:
58 //if (settings.profile == "gobject-2.0" || settings.profile == "gobject" || settings.profile == null) {
59 context.profile = Vala.Profile.GOBJECT;
60 // context.add_define ("GOBJECT");
62 //add_depencies (context, settings.packages);
63 //if (reporter.errors > 0) {
67 var source_file = new Vala.SourceFile (
69 Vala.SourceFileType.SOURCE,
73 //context.add_source_file (testcode);
76 // source_file = new Vala.SourceFile (context,
77 // Vala.SourceFileType.SOURCE,
78 // "/home/alan/gitlive/app.Builder.js/tests/TreeBuilder.vala");
80 //if (source_package == null) {
81 //source_package = register_package (new Package (settings.pkg_name, false, null));
84 //register_source_file (source_package, source_file);
86 context.add_external_package ("glib-2.0");
87 context.add_external_package ("gobject-2.0");
88 context.add_external_package ("libvala-0.24");
89 //context.add_external_package ("posix");
90 //if (context.profile == Vala.Profile.GOBJECT) {
91 // import the GLib namespace by default (namespace of backend-specific standard library)
92 var ns_ref = new Vala.UsingDirective (new Vala.UnresolvedSymbol (null, "GLib", null));
93 source_file.add_using_directive (ns_ref);
94 context.root.add_using_directive (ns_ref);
97 context.add_source_file (source_file);
100 //add_documented_files (context, settings.source_files);
102 Vala.Parser parser = new Vala.Parser ();
103 parser.parse (context);
104 //gir_parser.parse (context);
105 if (context.report.get_errors () > 0) {
114 if (context.report.get_errors () > 0) {
115 print("check got errors");
127 int main (string[] args) {
129 var a = new TreeBuilder();
130 a.create_valac_tree();