src/Palete/Palete.vala
[app.Builder.js] / src / Palete / Palete.vala
index 06bf729..d82e8b1 100644 (file)
@@ -387,6 +387,9 @@ namespace Palete
                                                                  testcode, out errmsg);
 
                        if (line < 0) {
+                               if (ptype == "file") {
+                                       return this.validateJavascriptCompression(code);
+                               }
                                print("no errors\n");
                                return ret;
                        }
@@ -395,6 +398,29 @@ namespace Palete
                        return ret;
                          
                } 
+               
+               public Gee.HashMap<int,string>  validateJavascriptCompression(string code)
+               {
+                       // this uses the roojspacker code to try and compress the code.
+                       // it should highlight errors before we actually push live the code.
+                       
+                       var p = new JSDOC.Packer();
+                       p.keepWhite = false;
+                       p.skipScope = false;
+                       p.dumpTokens = false;
+                       p.cleanup = false;
+                       try {
+                               p.packFile(code, "ANONFILE","");
+                       } catch (Exception e) {
+                       
+                       }
+                        
+                       var ret = new Gee.HashMap<int,string>();
+                       return ret;
+               
+               }
+               
+               
                      
                public abstract void fillPack(JsRender.Node node,JsRender.Node parent);
                public abstract void load();