Permalink
Browse files

expose start and end line data from esprima

  • Loading branch information...
1 parent aa4cc2b commit 82744f05673402fb860c0a3e43fc3dc0ba4b0407 @substack committed May 15, 2012
Showing with 7 additions and 2 deletions.
  1. +7 −2 index.js
View
@@ -21,6 +21,7 @@ function Fritter (context) {
catchVar : identifier(6)
};
this.stack = [];
+ this.current = undefined;
this.context = context;
this.nodes = [];
this.defineContext();
@@ -70,7 +71,8 @@ Fritter.prototype.defineContext = function () {
if (caught.indexOf(err) < 0) {
caught.push(err);
self.emit('error', err, {
- stack : self.stack.slice()
+ stack : self.stack.slice(),
+ current : self.current
});
}
@@ -87,6 +89,7 @@ Fritter.prototype.defineContext = function () {
};
Fritter.prototype.include = function (src, opts) {
+ var self = this;
if (typeof src === 'object') {
opts = src;
src = opts.source;
@@ -95,7 +98,7 @@ Fritter.prototype.include = function (src, opts) {
var nodes = this.nodes;
var names = this.names;
- var src_ = falafel(src, function (node) {
+ var src_ = falafel({ source : src, loc : true }, function (node) {
if (node.type === 'FunctionExpression'
|| node.type === 'FunctionDeclaration') {
var inner = node.body.source().slice(1,-1); // inside the brackets
@@ -113,6 +116,8 @@ Fritter.prototype.include = function (src, opts) {
+ '))'
);
if (opts.filename) node.filename = opts.filename;
+ node.start = node.loc.start;
+ node.end = node.loc.end;
nodes.push(node);
}
});

0 comments on commit 82744f0

Please sign in to comment.