forked from lightscript/babylon-lightscript
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix comment attachment for call expressions (babel#575)
- Loading branch information
Showing
5 changed files
with
580 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
test/fixtures/comments/basic/switch-function-call-no-semicolon-no-default/actual.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
switch (x) { | ||
case 1: | ||
console.log('1') | ||
// comment | ||
} |
245 changes: 245 additions & 0 deletions
245
test/fixtures/comments/basic/switch-function-call-no-semicolon-no-default/expected.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,245 @@ | ||
{ | ||
"type": "File", | ||
"start": 0, | ||
"end": 60, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 0 | ||
}, | ||
"end": { | ||
"line": 5, | ||
"column": 1 | ||
} | ||
}, | ||
"program": { | ||
"type": "Program", | ||
"start": 0, | ||
"end": 60, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 0 | ||
}, | ||
"end": { | ||
"line": 5, | ||
"column": 1 | ||
} | ||
}, | ||
"sourceType": "script", | ||
"body": [ | ||
{ | ||
"type": "SwitchStatement", | ||
"start": 0, | ||
"end": 60, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 0 | ||
}, | ||
"end": { | ||
"line": 5, | ||
"column": 1 | ||
} | ||
}, | ||
"discriminant": { | ||
"type": "Identifier", | ||
"start": 8, | ||
"end": 9, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 8 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 9 | ||
}, | ||
"identifierName": "x" | ||
}, | ||
"name": "x" | ||
}, | ||
"cases": [ | ||
{ | ||
"type": "SwitchCase", | ||
"start": 15, | ||
"end": 43, | ||
"loc": { | ||
"start": { | ||
"line": 2, | ||
"column": 2 | ||
}, | ||
"end": { | ||
"line": 3, | ||
"column": 20 | ||
} | ||
}, | ||
"consequent": [ | ||
{ | ||
"type": "ExpressionStatement", | ||
"start": 27, | ||
"end": 43, | ||
"loc": { | ||
"start": { | ||
"line": 3, | ||
"column": 4 | ||
}, | ||
"end": { | ||
"line": 3, | ||
"column": 20 | ||
} | ||
}, | ||
"expression": { | ||
"type": "CallExpression", | ||
"start": 27, | ||
"end": 43, | ||
"loc": { | ||
"start": { | ||
"line": 3, | ||
"column": 4 | ||
}, | ||
"end": { | ||
"line": 3, | ||
"column": 20 | ||
} | ||
}, | ||
"callee": { | ||
"type": "MemberExpression", | ||
"start": 27, | ||
"end": 38, | ||
"loc": { | ||
"start": { | ||
"line": 3, | ||
"column": 4 | ||
}, | ||
"end": { | ||
"line": 3, | ||
"column": 15 | ||
} | ||
}, | ||
"object": { | ||
"type": "Identifier", | ||
"start": 27, | ||
"end": 34, | ||
"loc": { | ||
"start": { | ||
"line": 3, | ||
"column": 4 | ||
}, | ||
"end": { | ||
"line": 3, | ||
"column": 11 | ||
}, | ||
"identifierName": "console" | ||
}, | ||
"name": "console" | ||
}, | ||
"property": { | ||
"type": "Identifier", | ||
"start": 35, | ||
"end": 38, | ||
"loc": { | ||
"start": { | ||
"line": 3, | ||
"column": 12 | ||
}, | ||
"end": { | ||
"line": 3, | ||
"column": 15 | ||
}, | ||
"identifierName": "log" | ||
}, | ||
"name": "log" | ||
}, | ||
"computed": false | ||
}, | ||
"arguments": [ | ||
{ | ||
"type": "StringLiteral", | ||
"start": 39, | ||
"end": 42, | ||
"loc": { | ||
"start": { | ||
"line": 3, | ||
"column": 16 | ||
}, | ||
"end": { | ||
"line": 3, | ||
"column": 19 | ||
} | ||
}, | ||
"extra": { | ||
"rawValue": "1", | ||
"raw": "'1'" | ||
}, | ||
"value": "1" | ||
} | ||
], | ||
"trailingComments": null | ||
}, | ||
"trailingComments": null | ||
} | ||
], | ||
"test": { | ||
"type": "NumericLiteral", | ||
"start": 20, | ||
"end": 21, | ||
"loc": { | ||
"start": { | ||
"line": 2, | ||
"column": 7 | ||
}, | ||
"end": { | ||
"line": 2, | ||
"column": 8 | ||
} | ||
}, | ||
"extra": { | ||
"rawValue": 1, | ||
"raw": "1" | ||
}, | ||
"value": 1 | ||
}, | ||
"trailingComments": [ | ||
{ | ||
"type": "CommentLine", | ||
"value": " comment", | ||
"start": 48, | ||
"end": 58, | ||
"loc": { | ||
"start": { | ||
"line": 4, | ||
"column": 4 | ||
}, | ||
"end": { | ||
"line": 4, | ||
"column": 14 | ||
} | ||
} | ||
} | ||
] | ||
} | ||
] | ||
} | ||
], | ||
"directives": [] | ||
}, | ||
"comments": [ | ||
{ | ||
"type": "CommentLine", | ||
"value": " comment", | ||
"start": 48, | ||
"end": 58, | ||
"loc": { | ||
"start": { | ||
"line": 4, | ||
"column": 4 | ||
}, | ||
"end": { | ||
"line": 4, | ||
"column": 14 | ||
} | ||
} | ||
} | ||
] | ||
} |
7 changes: 7 additions & 0 deletions
7
test/fixtures/comments/basic/switch-function-call-no-semicolon/actual.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
switch(x) { | ||
case 1: | ||
console.log('1') | ||
// comment | ||
default: | ||
break; | ||
} |
Oops, something went wrong.