mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-05-03 03:00:14 -04:00
AST: splat param location data (#5266)
* handle assignment to nested nontrailing splat * splat param location data
This commit is contained in:
committed by
Geoffrey Booth
parent
a6d4bf1982
commit
a091bb82f9
@@ -6326,7 +6326,7 @@
|
||||
return new Splat(name, {
|
||||
lhs: true,
|
||||
postfix: splat.postfix
|
||||
}).withLocationDataFrom(name);
|
||||
}).withLocationDataFrom(param);
|
||||
} else if (value != null) {
|
||||
return new Assign(name, value, null, {
|
||||
param: true
|
||||
|
||||
@@ -4234,7 +4234,7 @@ exports.Code = class Code extends Base
|
||||
{name, value, splat} = param
|
||||
if splat
|
||||
new Splat name, lhs: yes, postfix: splat.postfix
|
||||
.withLocationDataFrom name
|
||||
.withLocationDataFrom param
|
||||
else if value?
|
||||
new Assign name, value, null, param: yes
|
||||
.withLocationDataFrom locationData: mergeLocationData name.locationData, value.locationData
|
||||
|
||||
@@ -4556,6 +4556,82 @@ test "AST location data as expected for Code node", ->
|
||||
line: 1
|
||||
column: 2
|
||||
|
||||
testAstLocationData '''
|
||||
(a...) ->
|
||||
''',
|
||||
type: 'FunctionExpression'
|
||||
params: [
|
||||
argument:
|
||||
start: 1
|
||||
end: 2
|
||||
range: [1, 2]
|
||||
loc:
|
||||
start:
|
||||
line: 1
|
||||
column: 1
|
||||
end:
|
||||
line: 1
|
||||
column: 2
|
||||
start: 1
|
||||
end: 5
|
||||
range: [1, 5]
|
||||
loc:
|
||||
start:
|
||||
line: 1
|
||||
column: 1
|
||||
end:
|
||||
line: 1
|
||||
column: 5
|
||||
]
|
||||
start: 0
|
||||
end: 9
|
||||
range: [0, 9]
|
||||
loc:
|
||||
start:
|
||||
line: 1
|
||||
column: 0
|
||||
end:
|
||||
line: 1
|
||||
column: 9
|
||||
|
||||
testAstLocationData '''
|
||||
(...a) ->
|
||||
''',
|
||||
type: 'FunctionExpression'
|
||||
params: [
|
||||
argument:
|
||||
start: 4
|
||||
end: 5
|
||||
range: [4, 5]
|
||||
loc:
|
||||
start:
|
||||
line: 1
|
||||
column: 4
|
||||
end:
|
||||
line: 1
|
||||
column: 5
|
||||
start: 1
|
||||
end: 5
|
||||
range: [1, 5]
|
||||
loc:
|
||||
start:
|
||||
line: 1
|
||||
column: 1
|
||||
end:
|
||||
line: 1
|
||||
column: 5
|
||||
]
|
||||
start: 0
|
||||
end: 9
|
||||
range: [0, 9]
|
||||
loc:
|
||||
start:
|
||||
line: 1
|
||||
column: 0
|
||||
end:
|
||||
line: 1
|
||||
column: 9
|
||||
|
||||
test "AST location data as expected for Return node", ->
|
||||
testAstLocationData 'return no',
|
||||
type: 'ReturnStatement'
|
||||
|
||||
Reference in New Issue
Block a user