tests/forkme.vala
[app.Builder.js] / src / Palete / ValaSource.vala
index f2fb636..6a87966 100644 (file)
@@ -2,43 +2,61 @@
 // valac TreeBuilder.vala --pkg libvala-0.24 --pkg posix -o /tmp/treebuilder
 
 namespace Palete {
+        
        
        public class ValaSourceReport  : Vala.Report {
 
-
+               public JsRender.JsRender file;
                
-               public Gee.HashMap<int,string> line_warnings
-               public Gee.HashMap<int,string> line_depr;
+               //public Gee.ArrayList<ValaSourceNotice> notices;
+                
                public Gee.HashMap<int,string> line_errors;
-
-               public ValaSourceReport()
+               
+               public void  compile_notice(string type, string filename, int line, string message) {
+                       GLib.Idle.add(() => {
+                               this.file.compile_notice(type,filename,line,message);
+                               return false;
+                       });
+               }
+               
+        
+               public ValaSourceReport(JsRender.JsRender file)
                {
                        base();
+                       this.file = file;
                        this.line_errors = new Gee.HashMap<int,string> ();
-                       this.line_depr = new Gee.HashMap<int,string> ();
-                       this.line_warnings = new Gee.HashMap<int,string> ();
+                       //this.notices = new Gee.ArrayList<ValaSourceNotice>();
                }
                
                public override void warn (Vala.SourceReference? source, string message) {
-                       errors++;
+                        
                        if (source == null) {
                                return;
                                //stderr.printf ("My error: %s\n", message);
                        }
+                       
                        if (source.file.filename != "~~~~~testfile.vala") {
-                               print ("Warning: %d:  %s\n", source.begin.line, message);
+                               this.compile_notice("WARN", source.file.filename , source.begin.line, message);
                                return;
                        }
-                       var pre = "";
-                       if (line_errors.has_key(source.begin.line)) {
-                               pre = line_warnings.get(source.begin.line) + "\n";
-                               
+                       this.compile_notice("WARN", this.file.path, source.begin.line, message);
+                       
+               }
+               public override void depr (Vala.SourceReference? source, string message) {
+                        
+                       if (source == null) {
+                               return;
+                               //stderr.printf ("My error: %s\n", message);
                        }
-                       line_warnings.set(source.begin.line, pre +  "Warn: " + message);
-                       print ("Test file: Got error error: %d: %s\n", source.begin.line, message);
+                       
+                       if (source.file.filename != "~~~~~testfile.vala") {
+                               this.compile_notice("DEPR", source.file.filename, source.begin.line, message);
+                               return;
+                       }
+                       this.compile_notice("DEPR",  this.file.path, source.begin.line, message);
+                       
                }
                
-               
                public override void err (Vala.SourceReference? source, string message) {
                        errors++;
                        if (source == null) {
@@ -46,6 +64,7 @@ namespace Palete {
                                //stderr.printf ("My error: %s\n", message);
                        }
                        if (source.file.filename != "~~~~~testfile.vala") {
+                               this.compile_notice("ERR", source.file.filename, source.begin.line, message);
                                print ("Other file: Got error error: %d:  %s\n", source.begin.line, message);
                                return;
                        }
@@ -55,6 +74,7 @@ namespace Palete {
                                
                        }
                        line_errors.set(source.begin.line, pre +  message);
+                       this.compile_notice("ERR", this.file.path, source.begin.line, message);
                        print ("Test file: Got error error: %d: %s\n", source.begin.line, message);
                }
                public void dump()
@@ -111,6 +131,8 @@ namespace Palete {
                        
                        hash.set(prop, newval);
                        var tmpstring = JsRender.NodeToVala.mungeFile(this.file);
+                       hash.set(prop, old);
+                       //print("%s\n", tmpstring);
                        var bits = tmpstring.split("/*--VALACHECK-START--*/");
                        var offset =0;
                        if (bits.length > 0) {
@@ -119,7 +141,7 @@ namespace Palete {
                        //this.dumpCode(tmpstring);
                        //print("offset %d\n", offset);
                        yield this.checkStringThread(tmpstring);
-                       hash.set(prop, old);
+                       
                        // modify report
                        
                        var iter = this.report.line_errors.map_iterator();
@@ -204,7 +226,7 @@ namespace Palete {
                        context.thread = true;
                        
                        
-                       this.report = new ValaSourceReport();;
+                       this.report = new ValaSourceReport(this.file);
                        context.report = this.report;
                        
                        
@@ -235,9 +257,9 @@ namespace Palete {
                                var cg =  pr.compilegroups.get(this.file.build_module);
                                for (var i = 0; i < cg.sources.size; i++) {
                                        var path = pr.resolve_path(
-                               pr.resolve_path_combine_path(pr.firstPath(),cg.sources.get(i)));
-                               
-                       if (!FileUtils.test(path, FileTest.EXISTS)) {
+                                                       pr.resolve_path_combine_path(pr.firstPath(),cg.sources.get(i)));
+                                                       
+                                       if (!FileUtils.test(path, FileTest.EXISTS)) {
                                                continue;
                                        }       
                         
@@ -287,7 +309,7 @@ namespace Palete {
                        
                        //context.add_external_package ("libvala-0.24");
                        
-                       
+                       this.report.compile_notice("START", "", 0, "");
 
                
                        //add_documented_files (context, settings.source_files);
@@ -298,7 +320,9 @@ namespace Palete {
                        if (context.report.get_errors () > 0) {
                                print("parse got errors");
                                ((ValaSourceReport)context.report).dump();
+                               
                                Vala.CodeContext.pop ();
+                               this.report.compile_notice("END", "", 0, "");
                                return this.report.line_errors;
                        }
 
@@ -310,17 +334,18 @@ namespace Palete {
                                print("check got errors");
                                ((ValaSourceReport)context.report).dump();
                                Vala.CodeContext.pop ();
+                               this.report.compile_notice("END", "", 0, "");
                                return this.report.line_errors;
                                
                        }
                        
-                       context.codegen = new Vala.GDBusServerModule ();
+                       //context.codegen = new Vala.GDBusServerModule ();
                        
                         
                        context.output = "/tmp/testbuild";
                        valac += " -o " +context.output;
-                       context.codegen.emit (context);
-                        
+                       //context.codegen.emit (context);
+                       /*
                        var ccompiler = new Vala.CCodeCompiler ();
                        var cc_command = Environment.get_variable ("CC");
                        var pkg_config_command = Environment.get_variable ("PKG_CONFIG");
@@ -329,9 +354,14 @@ namespace Palete {
 #else
                        ccompiler.compile (context, cc_command, new string[] { });
 #endif
-
+                       */
  
                        Vala.CodeContext.pop ();
+                       //(new Vala.CodeNode()).get_error_types().clear();
+                       //(new Vala.NullType()).get_type_arguments().clear();
+                       (new Vala.NullType(null)).get_type_arguments().clear();
+                       parser = null;
+                       this.report.compile_notice("END", "", 0, "");
                        print("%s\n", valac);
                        print("ALL OK?\n");
                        return this.report.line_errors;