mirror of
https://github.com/jashkenas/coffeescript.git
synced 2022-11-09 12:23:24 -05:00

Conflicts: Cakefile lib/coffee-script/coffee-script.js lib/coffee-script/command.js lib/coffee-script/nodes.js lib/coffee-script/repl.js src/coffee-script.coffee src/helpers.coffee src/nodes.coffee src/repl.coffee
53 lines
2.2 KiB
JavaScript
53 lines
2.2 KiB
JavaScript
// Generated by CoffeeScript 1.6.1
|
|
(function() {
|
|
var CompilerError, repeat,
|
|
__hasProp = {}.hasOwnProperty,
|
|
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
|
|
|
|
repeat = require('./helpers').repeat;
|
|
|
|
exports.CompilerError = CompilerError = (function(_super) {
|
|
|
|
__extends(CompilerError, _super);
|
|
|
|
CompilerError.prototype.name = 'CompilerError';
|
|
|
|
function CompilerError(message, startLine, startColumn, endLine, endColumn) {
|
|
this.message = message;
|
|
this.startLine = startLine;
|
|
this.startColumn = startColumn;
|
|
this.endLine = endLine != null ? endLine : this.startLine;
|
|
this.endColumn = endColumn != null ? endColumn : this.startColumn;
|
|
if (typeof Error.captureStackTrace === "function") {
|
|
Error.captureStackTrace(this, CompilerError);
|
|
}
|
|
}
|
|
|
|
CompilerError.fromLocationData = function(message, _arg) {
|
|
var first_column, first_line, last_column, last_line;
|
|
first_line = _arg.first_line, first_column = _arg.first_column, last_line = _arg.last_line, last_column = _arg.last_column;
|
|
return new CompilerError(message, first_line, first_column, last_line, last_column);
|
|
};
|
|
|
|
CompilerError.prototype.prettyMessage = function(fileName, code, useColors) {
|
|
var colorize, end, errorLine, marker, message, start;
|
|
errorLine = code.split('\n')[this.startLine];
|
|
start = this.startColumn;
|
|
end = this.startLine === this.endLine ? this.endColumn + 1 : errorLine.length;
|
|
marker = repeat(' ', start) + repeat('^', end - start);
|
|
if (useColors) {
|
|
colorize = function(str) {
|
|
return "\x1B[1;31m" + str + "\x1B[0m";
|
|
};
|
|
errorLine = errorLine.slice(0, start) + colorize(errorLine.slice(start, end)) + errorLine.slice(end);
|
|
marker = colorize(marker);
|
|
}
|
|
message = "" + fileName + ":" + (this.startLine + 1) + ":" + (this.startColumn + 1) + ": error: " + this.message + "\n" + errorLine + "\n" + marker;
|
|
return message;
|
|
};
|
|
|
|
return CompilerError;
|
|
|
|
})(Error);
|
|
|
|
}).call(this);
|