add whitespace option and move util.errorWithNode to File

This commit is contained in:
Sebastian McKenzie
2014-11-03 11:09:58 +11:00
parent bf61c1e85d
commit 85f0f6fb14
2 changed files with 25 additions and 24 deletions

View File

@@ -73,16 +73,6 @@ exports.getIds = function (node) {
return ids;
};
exports.errorWithNode = function (node, msg) {
var line = node.loc.start.line;
var col = node.loc.start.column;
var err = new SyntaxError("Line " + line + ": " + msg);
err.lineNumber = line;
err.column = col;
return err;
};
exports.canCompile = function (filename) {
var ext = path.extname(filename);
return _.contains([".js", ".es6"], ext);
@@ -202,20 +192,14 @@ exports.repeat = function (width, cha) {
exports.parse = function (opts, code, callback) {
try {
var recastOpts = {};
if (opts.sourceMap) {
recastOpts.sourceFileName = opts.sourceFileName;
recastOpts.sourceRoot = opts.sourceRoot;
}
var comments = [];
var tokens = [];
var ast = acorn.parse(code, {
ecmaVersion: Infinity,
strictMode: true,
onComment: comments,
locations: true,
locations: opts.sourceMap,
onToken: tokens,
ranges: true
});