mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-05-03 03:00:14 -04:00
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
This commit is contained in:
committed by
Geoffrey Booth
parent
9cfcf8623c
commit
44be72a4d9
@@ -277,8 +277,7 @@
|
||||
if (colon) {
|
||||
colonOffset = input.lastIndexOf(inJSXTag ? '=' : ':');
|
||||
colonToken = this.token(':', ':', {
|
||||
offset: colonOffset,
|
||||
length: colon.length
|
||||
offset: colonOffset
|
||||
});
|
||||
if (inJSXTag) { // used by rewriter
|
||||
colonToken.jsxColon = true;
|
||||
|
||||
@@ -246,7 +246,7 @@ exports.Lexer = class Lexer
|
||||
[poppedToken[2].first_line, poppedToken[2].first_column, poppedToken[2].range[0]]
|
||||
if colon
|
||||
colonOffset = input.lastIndexOf if inJSXTag then '=' else ':'
|
||||
colonToken = @token ':', ':', offset: colonOffset, length: colon.length
|
||||
colonToken = @token ':', ':', offset: colonOffset
|
||||
colonToken.jsxColon = yes if inJSXTag # used by rewriter
|
||||
if inJSXTag and tag is 'IDENTIFIER' and prev[0] isnt ':'
|
||||
@token ',', ',', length: 0, origin: tagToken
|
||||
|
||||
@@ -1894,7 +1894,7 @@ exports.JSXElement = class JSXElement extends Base
|
||||
openingBrace: '{'
|
||||
closingBrace: '}'
|
||||
}
|
||||
|
||||
|
||||
new JSXExpressionContainer emptyExpression, locationData: element.locationData
|
||||
else
|
||||
unwrapped = expression.unwrapAll()
|
||||
|
||||
@@ -803,3 +803,16 @@ test "Verify carriage returns are accounted for in location data", ->
|
||||
eq minusToken[2].last_column_exclusive, 4
|
||||
eq minusToken[2].range[0], 7
|
||||
eq minusToken[2].range[1], 8
|
||||
|
||||
test "Verify object colon location data", ->
|
||||
source = '''
|
||||
a : b
|
||||
'''
|
||||
[implicitBraceToken, aToken, colonToken] = CoffeeScript.tokens source
|
||||
eq colonToken[2].first_line, 0
|
||||
eq colonToken[2].first_column, 2
|
||||
eq colonToken[2].last_line, 0
|
||||
eq colonToken[2].last_column, 2
|
||||
eq colonToken[2].last_column_exclusive, 3
|
||||
eq colonToken[2].range[0], 2
|
||||
eq colonToken[2].range[1], 3
|
||||
|
||||
Reference in New Issue
Block a user