resources/RooUsage.txt
[app.Builder.js] / tests / TreeBuilder.vala
index 2e97b5d..325a3c7 100644 (file)
@@ -3,31 +3,48 @@
 
 namespace Palete {
        
-       public class MyReport  : Vala.Report {
-       
+       public class ValaSourceReport  : Vala.Report {
+
+
+               
+
+               Gee.HashMap<int,string> line_errors;
+
+               public ValaSourceReport()
+               {
+                       base();
+                       this.line_errors = new Gee.HashMap<int,string> ();
+               }
+               
                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);
-                       
+                               return;
+                               //stderr.printf ("My error: %s\n", message);
+                       }
+                       if (source.file != "~~~~~testfile.vala") {
+                               return;
                        }
+                       var pre = "";
+                       if (line_errors.has_key(source.begin.line)) {
+                               pre = line_errors.get(source.begin.line) + "\n";
+                               
+                       }
+                       line_errors.set(source.begin.line, pre +  message);
                }
        
 
        }
 
-       public class TreeBuilder : Vala.CodeVisitor {
-       
-               public Vala.CodeContext check (JsRender.Gtk file) {
-                       // init context:
+       public class ValaSource : Vala.CodeVisitor {
 
+               Vala.CodeContext context;
+               
+               public ValaSource(JsRender.JsRender file) {
+                       base();
+                       // init context:
 
-                       
-                       var context = new Vala.CodeContext ();
+                       context = new Vala.CodeContext ();
                        Vala.CodeContext.push (context);
                
                        context.experimental = false;
@@ -36,7 +53,7 @@ namespace Palete {
                        context.report.enable_warnings = true;
                        context.metadata_directories = { };
                        context.gir_directories = {};
-                       context.report = new MyReport();
+                       context.report = new ValaSourceReport();
                
                        context.basedir = Posix.realpath (".");
                
@@ -56,7 +73,8 @@ namespace Palete {
                        var source_file = new Vala.SourceFile (
                                context, 
                                Vala.SourceFileType.SOURCE, 
-                              file.toSource()
+                                "~~~~~testfile.vala",
+                              NodeToVala.mungeFile(file)
                        );
                        //context.add_source_file (testcode);
 
@@ -91,8 +109,9 @@ namespace Palete {
                        parser.parse (context);
                        //gir_parser.parse (context);
                        if (context.report.get_errors () > 0) {
-                               print("got errors");
-                               return context;
+                               print("parse got errors");
+                               Vala.CodeContext.pop (context);
+                               return;
                        }
 
 
@@ -101,20 +120,23 @@ namespace Palete {
                        context.check ();
                        if (context.report.get_errors () > 0) {
                                print("check got errors");
-                               return context;
+                               Vala.CodeContext.pop (context);
+                               return;
                        }
+                       Vala.CodeContext.pop (context);
                        print("ALL OK?\n");
-                       return context;
+                       return;
                }
        //
                // startpoint:
                //
         
        }
+}
 
 int main (string[] args) {
 
-       var a = new TreeBuilder();
+       var a = new ValaSource(file);
        a.create_valac_tree();
        return 0;
 }