tests/TreeBuilder.vala.c
[app.Builder.js] / tests / TreeBuilder.vala
index 1649262..3898e37 100644 (file)
@@ -1,6 +1,22 @@
 
 // valac TreeBuilder.vala --pkg libvala-0.24 --pkg posix -o /tmp/treebuilder
 
+public class MyReport  : Vala.Report {
+       
+       public override void err (Vala.SourceReference? source, string message) {
+               errors++;
+               if (source == null) {
+                       stderr.printf ("My error: %s\n", message);
+               } else {
+                       stderr.printf ("%s: My error: %s\n", source.to_string (), message);
+               
+                       //Vala.Report.report_source (source);
+                       
+               }
+       }
+       
+
+}
 
 public class TreeBuilder : Vala.CodeVisitor {
        
@@ -15,7 +31,7 @@ public class TreeBuilder : Vala.CodeVisitor {
                context.report.enable_warnings = true;
                context.metadata_directories = { };
                context.gir_directories = {};
-
+               context.report = new MyReport();
                
                context.basedir = Posix.realpath (".");
                
@@ -32,6 +48,18 @@ public class TreeBuilder : Vala.CodeVisitor {
                //      return context;
                //}
 
+               var testcode = new Vala.SourceFile (
+                       context, 
+                       Vala.SourceFileType.SOURCE, 
+                       "/dev/null",
+                       "void atest() { 
+                           var x = 1; 
+                           a++;
+                       }"
+                    );
+               context.add_source_file (testcode);
+
+               
                var source_file = new Vala.SourceFile (context, 
                                Vala.SourceFileType.SOURCE, 
                                "/home/alan/gitlive/app.Builder.js/tests/TreeBuilder.vala");
@@ -42,6 +70,10 @@ public class TreeBuilder : Vala.CodeVisitor {
 
                //register_source_file (source_package, source_file);
 
+               context.add_external_package ("glib-2.0");
+               context.add_external_package ("gobject-2.0");
+               context.add_external_package ("libvala-0.24");
+               context.add_external_package ("posix");
                //if (context.profile == Vala.Profile.GOBJECT) {
                        // import the GLib namespace by default (namespace of backend-specific standard library)
                        var ns_ref = new Vala.UsingDirective (new Vala.UnresolvedSymbol (null, "GLib", null));