pass line information from coffee parseErrors to the worker
This commit is contained in:
parent
2f9a6e5ba7
commit
4dd3475fd9
4 changed files with 19 additions and 22 deletions
File diff suppressed because one or more lines are too long
|
|
@ -49,7 +49,11 @@ module.exports = {
|
|||
try {
|
||||
coffee.parse("a = 12 f");
|
||||
} catch (e) {
|
||||
assert.ok((e + "").indexOf("Parse error on line 1: Unexpected 'IDENTIFIER'") >= 0);
|
||||
assert.equal(e.message, "Unexpected 'IDENTIFIER'");
|
||||
assert.equal(e.location.first_line, 0);
|
||||
assert.equal(e.location.first_column, 7);
|
||||
assert.equal(e.location.last_line, 0);
|
||||
assert.equal(e.location.last_column, 7);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -53,27 +53,16 @@ oop.inherits(Worker, Mirror);
|
|||
try {
|
||||
coffee.parse(value);
|
||||
} catch(e) {
|
||||
var m = e.message.match(/Parse error on line (\d+): (.*)/);
|
||||
if (m) {
|
||||
var loc = e.location;
|
||||
if (loc) {
|
||||
this.sender.emit("error", {
|
||||
row: parseInt(m[1], 10) - 1,
|
||||
column: null,
|
||||
text: m[2],
|
||||
row: loc.first_line,
|
||||
column: loc.first_column,
|
||||
endRow: loc.last_line,
|
||||
endColumn: loc.last_column,
|
||||
text: e.message,
|
||||
type: "error"
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (e instanceof SyntaxError) {
|
||||
var m = e.message.match(/ on line (\d+)/);
|
||||
if (m) {
|
||||
this.sender.emit("error", {
|
||||
row: parseInt(m[1], 10) - 1,
|
||||
column: null,
|
||||
text: e.message.replace(m[0], ""),
|
||||
type: "error"
|
||||
});
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -124,6 +124,8 @@ void function(){
|
|||
fs.writeFile(x.path, data, "utf-8", function(err){
|
||||
if (err) throw err
|
||||
console.log("File " + x.name + " saved.")
|
||||
console.warn("mode/coffee/coffee-script file needs to updated manually")
|
||||
console.warn("mode/coffee/parser.js: parseError function needs to be modified")
|
||||
})
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue