mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-05-03 03:00:14 -04:00
Add location data to tokens generated by the rewriter.
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
this.tagPostfixConditionals();
|
||||
this.addImplicitBraces();
|
||||
this.addImplicitParentheses();
|
||||
this.addLocationDataToGeneratedTokens();
|
||||
return this.tokens;
|
||||
};
|
||||
|
||||
@@ -221,6 +222,31 @@
|
||||
});
|
||||
};
|
||||
|
||||
Rewriter.prototype.addLocationDataToGeneratedTokens = function() {
|
||||
return this.scanTokens(function(token, i, tokens) {
|
||||
var prevToken;
|
||||
if (token.generated && !token.locationData) {
|
||||
if (i > 0) {
|
||||
prevToken = tokens[i - 1];
|
||||
token.locationData = {
|
||||
first_line: prevToken.locationData.last_line,
|
||||
first_column: prevToken.locationData.last_column,
|
||||
last_line: prevToken.locationData.last_line,
|
||||
last_column: prevToken.locationData.last_column
|
||||
};
|
||||
} else {
|
||||
token.locationData = {
|
||||
first_line: 0,
|
||||
first_column: 0,
|
||||
last_line: 0,
|
||||
last_column: 0
|
||||
};
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
});
|
||||
};
|
||||
|
||||
Rewriter.prototype.addImplicitIndentation = function() {
|
||||
var action, condition, indent, outdent, starter;
|
||||
starter = indent = outdent = null;
|
||||
|
||||
Reference in New Issue
Block a user