Use .explicit when deciding whether or not to add location data.

This commit is contained in:
Jason Walton 2013-01-14 13:38:31 -05:00
parent cee4f4ab6e
commit a9aa52dc6a
2 changed files with 3 additions and 10 deletions

View File

@ -224,10 +224,9 @@
Rewriter.prototype.addLocationDataToGeneratedTokens = function() {
return this.scanTokens(function(token, i, tokens) {
var generated, prevToken, tag;
var prevToken, tag;
tag = token[0];
generated = token.generated || (token.explicit && (tag === 'INDENT' || tag === 'OUTDENT'));
if (generated && !token.locationData) {
if ((token.generated || token.explicit) && !token.locationData) {
if (i > 0) {
prevToken = tokens[i - 1];
token.locationData = {

View File

@ -195,12 +195,7 @@ class exports.Rewriter
addLocationDataToGeneratedTokens: ->
@scanTokens (token, i, tokens) ->
tag = token[0]
# Some generated indentation isn't '.generated'. We want to treet these and generated
# anyways, since everything needs a location data. We don't want to just blindly add
# location data, though, since we want to find bugs. :)
generated = token.generated or (token.explicit and (tag is 'INDENT' or tag is 'OUTDENT'))
if generated and not token.locationData
if (token.generated or token.explicit) and not token.locationData
if i > 0
prevToken = tokens[i-1]
token.locationData =
@ -221,7 +216,6 @@ class exports.Rewriter
# blocks, so it doesn't need to. ')' can close a single-line block,
# but we need to make sure it's balanced.
addImplicitIndentation: ->
starter = indent = outdent = null
condition = (token, i) ->