use narcissus in the worker to detect syntax errors
This commit is contained in:
parent
bd7b145a7f
commit
d24cce4851
2 changed files with 30 additions and 3 deletions
|
|
@ -144,7 +144,7 @@ oop.inherits(Mode, TextMode);
|
|||
row: error.line-1,
|
||||
column: error.character-1,
|
||||
text: error.reason,
|
||||
type: "error",
|
||||
type: "warning",
|
||||
lint: error
|
||||
})
|
||||
}
|
||||
|
|
@ -152,6 +152,10 @@ oop.inherits(Mode, TextMode);
|
|||
session.setAnnotations(errors)
|
||||
});
|
||||
|
||||
worker.on("narcissus", function(e) {
|
||||
session.setAnnotations([e.data]);
|
||||
});
|
||||
|
||||
worker.on("terminate", function() {
|
||||
session.clearAnnotations();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -15,8 +15,31 @@ oop.inherits(JavaScriptWorker, Mirror);
|
|||
(function() {
|
||||
|
||||
this.onUpdate = function() {
|
||||
lint(this.doc.getValue(), {undef: false, onevar: false, passfail: false});
|
||||
this.sender.emit("jslint", lint.errors);
|
||||
var value = this.doc.getValue();
|
||||
|
||||
var start = new Date();
|
||||
var parser = require("ace/narcissus/jsparse");
|
||||
try {
|
||||
parser.parse(value);
|
||||
} catch(e) {
|
||||
console.log("narcissus")
|
||||
console.log(e);
|
||||
sender.emit("narcissus", {
|
||||
row: e.lineno-1,
|
||||
column: null, // TODO convert e.cursor
|
||||
text: e.message,
|
||||
type: "error"
|
||||
});
|
||||
return;
|
||||
} finally {
|
||||
console.log("parse time: " + (new Date() - start));
|
||||
}
|
||||
|
||||
var start = new Date();
|
||||
console.log("jslint")
|
||||
lint(value, {undef: false, onevar: false, passfail: false});
|
||||
this.sender.emit("jslint", lint.errors);
|
||||
console.log("lint time: " + (new Date() - start));
|
||||
}
|
||||
|
||||
}).call(JavaScriptWorker.prototype);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue