Fix comment attachment for call expressions (#575)
This commit is contained in:
committed by
Daniel Tschinder
parent
e1e2c32bf3
commit
ac936e315a
7
test/fixtures/comments/basic/switch-function-call-no-semicolon/actual.js
vendored
Normal file
7
test/fixtures/comments/basic/switch-function-call-no-semicolon/actual.js
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
switch(x) {
|
||||
case 1:
|
||||
console.log('1')
|
||||
// comment
|
||||
default:
|
||||
break;
|
||||
}
|
||||
298
test/fixtures/comments/basic/switch-function-call-no-semicolon/expected.json
vendored
Normal file
298
test/fixtures/comments/basic/switch-function-call-no-semicolon/expected.json
vendored
Normal file
@@ -0,0 +1,298 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start": 0,
|
||||
"end": 81,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 7,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start": 0,
|
||||
"end": 81,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 7,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"sourceType": "script",
|
||||
"body": [
|
||||
{
|
||||
"type": "SwitchStatement",
|
||||
"start": 0,
|
||||
"end": 81,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 7,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"discriminant": {
|
||||
"type": "Identifier",
|
||||
"start": 7,
|
||||
"end": 8,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 7
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 8
|
||||
},
|
||||
"identifierName": "x"
|
||||
},
|
||||
"name": "x"
|
||||
},
|
||||
"cases": [
|
||||
{
|
||||
"type": "SwitchCase",
|
||||
"start": 14,
|
||||
"end": 42,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 2
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 20
|
||||
}
|
||||
},
|
||||
"consequent": [
|
||||
{
|
||||
"type": "ExpressionStatement",
|
||||
"start": 26,
|
||||
"end": 42,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 4
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 20
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"type": "CallExpression",
|
||||
"start": 26,
|
||||
"end": 42,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 4
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 20
|
||||
}
|
||||
},
|
||||
"callee": {
|
||||
"type": "MemberExpression",
|
||||
"start": 26,
|
||||
"end": 37,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 4
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 15
|
||||
}
|
||||
},
|
||||
"object": {
|
||||
"type": "Identifier",
|
||||
"start": 26,
|
||||
"end": 33,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 4
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 11
|
||||
},
|
||||
"identifierName": "console"
|
||||
},
|
||||
"name": "console"
|
||||
},
|
||||
"property": {
|
||||
"type": "Identifier",
|
||||
"start": 34,
|
||||
"end": 37,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 12
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 15
|
||||
},
|
||||
"identifierName": "log"
|
||||
},
|
||||
"name": "log"
|
||||
},
|
||||
"computed": false
|
||||
},
|
||||
"arguments": [
|
||||
{
|
||||
"type": "StringLiteral",
|
||||
"start": 38,
|
||||
"end": 41,
|
||||
"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": 19,
|
||||
"end": 20,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 7
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 8
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"rawValue": 1,
|
||||
"raw": "1"
|
||||
},
|
||||
"value": 1
|
||||
},
|
||||
"trailingComments": [
|
||||
{
|
||||
"type": "CommentLine",
|
||||
"value": " comment",
|
||||
"start": 47,
|
||||
"end": 57,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 4,
|
||||
"column": 4
|
||||
},
|
||||
"end": {
|
||||
"line": 4,
|
||||
"column": 14
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "SwitchCase",
|
||||
"start": 60,
|
||||
"end": 79,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 5,
|
||||
"column": 2
|
||||
},
|
||||
"end": {
|
||||
"line": 6,
|
||||
"column": 10
|
||||
}
|
||||
},
|
||||
"consequent": [
|
||||
{
|
||||
"type": "BreakStatement",
|
||||
"start": 73,
|
||||
"end": 79,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 6,
|
||||
"column": 4
|
||||
},
|
||||
"end": {
|
||||
"line": 6,
|
||||
"column": 10
|
||||
}
|
||||
},
|
||||
"label": null,
|
||||
"leadingComments": null
|
||||
}
|
||||
],
|
||||
"test": null,
|
||||
"leadingComments": [
|
||||
{
|
||||
"type": "CommentLine",
|
||||
"value": " comment",
|
||||
"start": 47,
|
||||
"end": 57,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 4,
|
||||
"column": 4
|
||||
},
|
||||
"end": {
|
||||
"line": 4,
|
||||
"column": 14
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
},
|
||||
"comments": [
|
||||
{
|
||||
"type": "CommentLine",
|
||||
"value": " comment",
|
||||
"start": 47,
|
||||
"end": 57,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 4,
|
||||
"column": 4
|
||||
},
|
||||
"end": {
|
||||
"line": 4,
|
||||
"column": 14
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user