Skip to content

Commit 44be72a

Browse files
helixbassGeoffreyBooth
authored andcommitted
AST: object colon location data (#5253)
* astNode() * no override ast() * add suggested comments * astInitialize() * astAddReturns() * separate step * recognize quoted constructor * add params to scope * object colon location data
1 parent 9cfcf86 commit 44be72a

File tree

4 files changed

+16
-4
lines changed

4 files changed

+16
-4
lines changed

lib/coffeescript/lexer.js

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/lexer.coffee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ exports.Lexer = class Lexer
246246
[poppedToken[2].first_line, poppedToken[2].first_column, poppedToken[2].range[0]]
247247
if colon
248248
colonOffset = input.lastIndexOf if inJSXTag then '=' else ':'
249-
colonToken = @token ':', ':', offset: colonOffset, length: colon.length
249+
colonToken = @token ':', ':', offset: colonOffset
250250
colonToken.jsxColon = yes if inJSXTag # used by rewriter
251251
if inJSXTag and tag is 'IDENTIFIER' and prev[0] isnt ':'
252252
@token ',', ',', length: 0, origin: tagToken

src/nodes.coffee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1894,7 +1894,7 @@ exports.JSXElement = class JSXElement extends Base
18941894
openingBrace: '{'
18951895
closingBrace: '}'
18961896
}
1897-
1897+
18981898
new JSXExpressionContainer emptyExpression, locationData: element.locationData
18991899
else
19001900
unwrapped = expression.unwrapAll()

test/location.coffee

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -803,3 +803,16 @@ test "Verify carriage returns are accounted for in location data", ->
803803
eq minusToken[2].last_column_exclusive, 4
804804
eq minusToken[2].range[0], 7
805805
eq minusToken[2].range[1], 8
806+
807+
test "Verify object colon location data", ->
808+
source = '''
809+
a : b
810+
'''
811+
[implicitBraceToken, aToken, colonToken] = CoffeeScript.tokens source
812+
eq colonToken[2].first_line, 0
813+
eq colonToken[2].first_column, 2
814+
eq colonToken[2].last_line, 0
815+
eq colonToken[2].last_column, 2
816+
eq colonToken[2].last_column_exclusive, 3
817+
eq colonToken[2].range[0], 2
818+
eq colonToken[2].range[1], 3

0 commit comments

Comments
 (0)