X-Git-Url: http://git.roojs.org/?a=blobdiff_plain;f=src%2FPalete%2FPalete.vala;h=d82e8b1fe3fb20d6cde6153f23d542e435c0afb4;hb=e8963dbac540c13be86e781c8c1c3a44d012b493;hp=c09b574a68256fa361ba8724de4b87487c53371a;hpb=9b511c0e01aa498435b95af46d1fd6ce67320374;p=app.Builder.js diff --git a/src/Palete/Palete.vala b/src/Palete/Palete.vala index c09b574a6..d82e8b1fe 100644 --- a/src/Palete/Palete.vala +++ b/src/Palete/Palete.vala @@ -1,4 +1,5 @@ +using Gtk; namespace Palete { @@ -364,37 +365,62 @@ namespace Palete string property, string ptype, JsRender.JsRender file, - JsRender.Node node + JsRender.Node? node ) { - print("validate code (%s) %s\n", file.language, code); + print("validate code (%s) ptype=%s property=%s\n", file.language, ptype, property); var ret = new Gee.HashMap(); if (file.language != "js") { return ret; } - if (ptype != "listener" && property[0] == '|') { + if (ptype != "listener" && property.length > 0 && property[0] == '|') { return ret; } //var cd = new JSCore.ClassDefinitionEmpty(); //print("TESTING CODE %s\n", code); string errmsg; + var testcode = ptype == "file" ? code : "var __aaa___ = " + code; var line = Javascript.singleton().validate( - "var __aaa___ = " + code, out errmsg); + testcode, out errmsg); if (line < 0) { + if (ptype == "file") { + return this.validateJavascriptCompression(code); + } print("no errors\n"); return ret; } ret.set(line, errmsg); print("got errors\n"); return ret; + + } + + public Gee.HashMap 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(); + return ret; + } - + + public abstract void fillPack(JsRender.Node node,JsRender.Node parent); public abstract void load(); @@ -404,11 +430,11 @@ namespace Palete public abstract bool typeOptions(string fqn, string key, string type, out string[] opts); public abstract List suggestComplete( JsRender.JsRender file, - JsRender.Node node, + JsRender.Node? node, string proptype, string key, string complete_string - ) + ); }