if (file.language != "js") {
return ret;
}
- if (ptype != "listener" && property[0] == '|') {
+ if (ptype != "listener" && property.length > 0 && property[0] == '|') {
return ret;
}
testcode, out errmsg);
if (line < 0) {
+ if (ptype == "file") {
+ return this.validateJavascriptCompression(code);
+ }
print("no errors\n");
return ret;
}
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.
+
+ // standard error format: file %s, line %s, Error
+
+ var p = new JSDOC.Packer();
+ p.keepWhite = false;
+ p.skipScope = false;
+ p.dumpTokens = false;
+ p.cleanup = false;
+ var estr = "";
+ var ret = new Gee.HashMap<int,string>();
+ try {
+ p.packFile(code, "ANONFILE","");
+ } catch (JSDOC.TokenReaderError e) {
+ estr = e.message;
+ } catch (JSDOC.ScopeParserError e) {
+ estr = e.message;
+ }
+ if (estr.length > 0 ) {
+
+ var bits = estr.split(",");
+ if (bits.length > 2) {
+ var linebits = bits[1].strip().split(" ");
+ if (linebits.length > 1) {
+ var line = int.parse(linebits[1]);
+ // line is correct - but our standard for error messages is to do it start at '0'
+ ret.set(line -1 , bits[2]);
+ }
+
+ }
+ }
+
+ return ret;
+
+ }
+
+
public abstract void fillPack(JsRender.Node node,JsRender.Node parent);
public abstract void load();