* refactor: inline pushComment * chore: add benchmark cases * perf: overhaul comment attachment * cleanup * update test fixtures They are all bugfixes. * fix: merge HTMLComment parsing to skipSpace * perf: remove unattachedCommentStack baseline 128 nested leading comments: 11_034 ops/sec ±50.64% (0.091ms) baseline 256 nested leading comments: 6_037 ops/sec ±11.46% (0.166ms) baseline 512 nested leading comments: 3_077 ops/sec ±2.31% (0.325ms) baseline 1024 nested leading comments: 1_374 ops/sec ±3.22% (0.728ms) current 128 nested leading comments: 11_027 ops/sec ±37.41% (0.091ms) current 256 nested leading comments: 6_736 ops/sec ±1.39% (0.148ms) current 512 nested leading comments: 3_306 ops/sec ±0.69% (0.302ms) current 1024 nested leading comments: 1_579 ops/sec ±2.09% (0.633ms) baseline 128 nested trailing comments: 10_073 ops/sec ±42.95% (0.099ms) baseline 256 nested trailing comments: 6_294 ops/sec ±2.19% (0.159ms) baseline 512 nested trailing comments: 3_041 ops/sec ±0.8% (0.329ms) baseline 1024 nested trailing comments: 1_530 ops/sec ±1.18% (0.654ms) current 128 nested trailing comments: 11_461 ops/sec ±44.89% (0.087ms) current 256 nested trailing comments: 7_212 ops/sec ±1.6% (0.139ms) current 512 nested trailing comments: 3_403 ops/sec ±1% (0.294ms) current 1024 nested trailing comments: 1_539 ops/sec ±1.49% (0.65ms) * fix: do not expose CommentWhitespace type * add comments on CommentWhitespace * add test case for #11576 * fix: mark containerNode be the innermost node containing commentWS * fix: adjust trailing comma comments for Record/Tuple/OptionalCall * fix: drain comment stacks in parseExpression * docs: update comments * add a new benchmark * chore: containerNode => containingNode * add more benchmark cases * fix: avoid finishNodeAt in stmtToDirective * finalize comment right after containerNode is set * add testcase about directive * fix: finish SequenceExpression at current pos and adjust later * chore: rename test cases * add new test case on switch statement * fix: adjust comments after trailing comma of function params * add comment attachment design doc * misc fix * fix: reset previous trailing comments when parsing async method/accessor * chore: add more comment testcases * fix flow errors * fix: handle comments when parsing async arrow * fix: handle comments when "static" is a class modifier * fix flow errors * fix: handle comments when parsing async function/do * refactor: simplify resetPreviousNodeTrailingComments * update test fixtures
343 lines
13 KiB
JSON
343 lines
13 KiB
JSON
{
|
|
"type": "File",
|
|
"start":0,"end":215,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":34}},
|
|
"program": {
|
|
"type": "Program",
|
|
"start":0,"end":215,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":34}},
|
|
"sourceType": "script",
|
|
"interpreter": null,
|
|
"body": [
|
|
{
|
|
"type": "ExpressionStatement",
|
|
"start":0,"end":99,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":99}},
|
|
"expression": {
|
|
"type": "ClassExpression",
|
|
"start":1,"end":97,"loc":{"start":{"line":1,"column":1},"end":{"line":1,"column":97}},
|
|
"extra": {
|
|
"parenthesized": true,
|
|
"parenStart": 0
|
|
},
|
|
"id": null,
|
|
"superClass": null,
|
|
"body": {
|
|
"type": "ClassBody",
|
|
"start":7,"end":97,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":97}},
|
|
"body": [
|
|
{
|
|
"type": "ClassMethod",
|
|
"start":17,"end":95,"loc":{"start":{"line":1,"column":17},"end":{"line":1,"column":95}},
|
|
"leadingComments": [
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": " 1 ",
|
|
"start":9,"end":16,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":16}}
|
|
}
|
|
],
|
|
"innerComments": [
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": " 2 ",
|
|
"start":21,"end":28,"loc":{"start":{"line":1,"column":21},"end":{"line":1,"column":28}}
|
|
},
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": " 5 ",
|
|
"start":48,"end":55,"loc":{"start":{"line":1,"column":48},"end":{"line":1,"column":55}}
|
|
}
|
|
],
|
|
"static": false,
|
|
"key": {
|
|
"type": "Identifier",
|
|
"start":38,"end":39,"loc":{"start":{"line":1,"column":38},"end":{"line":1,"column":39},"identifierName":"f"},
|
|
"leadingComments": [
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": " 3 ",
|
|
"start":31,"end":38,"loc":{"start":{"line":1,"column":31},"end":{"line":1,"column":38}}
|
|
}
|
|
],
|
|
"trailingComments": [
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": " 4 ",
|
|
"start":39,"end":46,"loc":{"start":{"line":1,"column":39},"end":{"line":1,"column":46}}
|
|
}
|
|
],
|
|
"name": "f"
|
|
},
|
|
"computed": true,
|
|
"kind": "set",
|
|
"id": null,
|
|
"generator": false,
|
|
"async": false,
|
|
"params": [
|
|
{
|
|
"type": "Identifier",
|
|
"start":65,"end":66,"loc":{"start":{"line":1,"column":65},"end":{"line":1,"column":66},"identifierName":"a"},
|
|
"leadingComments": [
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": " 6 ",
|
|
"start":57,"end":64,"loc":{"start":{"line":1,"column":57},"end":{"line":1,"column":64}}
|
|
}
|
|
],
|
|
"trailingComments": [
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": " 7 ",
|
|
"start":67,"end":74,"loc":{"start":{"line":1,"column":67},"end":{"line":1,"column":74}}
|
|
},
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": " 8 ",
|
|
"start":76,"end":83,"loc":{"start":{"line":1,"column":76},"end":{"line":1,"column":83}}
|
|
}
|
|
],
|
|
"name": "a"
|
|
}
|
|
],
|
|
"body": {
|
|
"type": "BlockStatement",
|
|
"start":93,"end":95,"loc":{"start":{"line":1,"column":93},"end":{"line":1,"column":95}},
|
|
"leadingComments": [
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": " 9 ",
|
|
"start":85,"end":92,"loc":{"start":{"line":1,"column":85},"end":{"line":1,"column":92}}
|
|
}
|
|
],
|
|
"body": [],
|
|
"directives": []
|
|
}
|
|
}
|
|
]
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"type": "ExpressionStatement",
|
|
"start":100,"end":180,"loc":{"start":{"line":2,"column":0},"end":{"line":2,"column":80}},
|
|
"expression": {
|
|
"type": "ClassExpression",
|
|
"start":101,"end":178,"loc":{"start":{"line":2,"column":1},"end":{"line":2,"column":78}},
|
|
"extra": {
|
|
"parenthesized": true,
|
|
"parenStart": 100
|
|
},
|
|
"id": null,
|
|
"superClass": null,
|
|
"body": {
|
|
"type": "ClassBody",
|
|
"start":107,"end":178,"loc":{"start":{"line":2,"column":7},"end":{"line":2,"column":78}},
|
|
"body": [
|
|
{
|
|
"type": "ClassMethod",
|
|
"start":117,"end":176,"loc":{"start":{"line":2,"column":17},"end":{"line":2,"column":76}},
|
|
"leadingComments": [
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": " 1 ",
|
|
"start":109,"end":116,"loc":{"start":{"line":2,"column":9},"end":{"line":2,"column":16}}
|
|
}
|
|
],
|
|
"innerComments": [
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": " 2 ",
|
|
"start":121,"end":128,"loc":{"start":{"line":2,"column":21},"end":{"line":2,"column":28}}
|
|
},
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": " 5 ",
|
|
"start":148,"end":155,"loc":{"start":{"line":2,"column":48},"end":{"line":2,"column":55}}
|
|
},
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": " 6 ",
|
|
"start":157,"end":164,"loc":{"start":{"line":2,"column":57},"end":{"line":2,"column":64}}
|
|
}
|
|
],
|
|
"static": false,
|
|
"key": {
|
|
"type": "Identifier",
|
|
"start":138,"end":139,"loc":{"start":{"line":2,"column":38},"end":{"line":2,"column":39},"identifierName":"f"},
|
|
"leadingComments": [
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": " 3 ",
|
|
"start":131,"end":138,"loc":{"start":{"line":2,"column":31},"end":{"line":2,"column":38}}
|
|
}
|
|
],
|
|
"trailingComments": [
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": " 4 ",
|
|
"start":139,"end":146,"loc":{"start":{"line":2,"column":39},"end":{"line":2,"column":46}}
|
|
}
|
|
],
|
|
"name": "f"
|
|
},
|
|
"computed": true,
|
|
"kind": "get",
|
|
"id": null,
|
|
"generator": false,
|
|
"async": false,
|
|
"params": [],
|
|
"body": {
|
|
"type": "BlockStatement",
|
|
"start":174,"end":176,"loc":{"start":{"line":2,"column":74},"end":{"line":2,"column":76}},
|
|
"leadingComments": [
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": " 7 ",
|
|
"start":166,"end":173,"loc":{"start":{"line":2,"column":66},"end":{"line":2,"column":73}}
|
|
}
|
|
],
|
|
"body": [],
|
|
"directives": []
|
|
}
|
|
}
|
|
]
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"type": "ExpressionStatement",
|
|
"start":181,"end":215,"loc":{"start":{"line":3,"column":0},"end":{"line":3,"column":34}},
|
|
"expression": {
|
|
"type": "ClassExpression",
|
|
"start":182,"end":213,"loc":{"start":{"line":3,"column":1},"end":{"line":3,"column":32}},
|
|
"extra": {
|
|
"parenthesized": true,
|
|
"parenStart": 181
|
|
},
|
|
"id": null,
|
|
"superClass": null,
|
|
"body": {
|
|
"type": "ClassBody",
|
|
"start":188,"end":213,"loc":{"start":{"line":3,"column":7},"end":{"line":3,"column":32}},
|
|
"body": [
|
|
{
|
|
"type": "ClassMethod",
|
|
"start":190,"end":211,"loc":{"start":{"line":3,"column":9},"end":{"line":3,"column":30}},
|
|
"innerComments": [
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": " 1 ",
|
|
"start":194,"end":201,"loc":{"start":{"line":3,"column":13},"end":{"line":3,"column":20}}
|
|
}
|
|
],
|
|
"static": false,
|
|
"key": {
|
|
"type": "Identifier",
|
|
"start":203,"end":204,"loc":{"start":{"line":3,"column":22},"end":{"line":3,"column":23},"identifierName":"f"},
|
|
"name": "f"
|
|
},
|
|
"computed": true,
|
|
"kind": "get",
|
|
"id": null,
|
|
"generator": false,
|
|
"async": false,
|
|
"params": [],
|
|
"body": {
|
|
"type": "BlockStatement",
|
|
"start":209,"end":211,"loc":{"start":{"line":3,"column":28},"end":{"line":3,"column":30}},
|
|
"body": [],
|
|
"directives": []
|
|
}
|
|
}
|
|
]
|
|
}
|
|
}
|
|
}
|
|
],
|
|
"directives": []
|
|
},
|
|
"comments": [
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": " 1 ",
|
|
"start":9,"end":16,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":16}}
|
|
},
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": " 2 ",
|
|
"start":21,"end":28,"loc":{"start":{"line":1,"column":21},"end":{"line":1,"column":28}}
|
|
},
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": " 3 ",
|
|
"start":31,"end":38,"loc":{"start":{"line":1,"column":31},"end":{"line":1,"column":38}}
|
|
},
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": " 4 ",
|
|
"start":39,"end":46,"loc":{"start":{"line":1,"column":39},"end":{"line":1,"column":46}}
|
|
},
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": " 5 ",
|
|
"start":48,"end":55,"loc":{"start":{"line":1,"column":48},"end":{"line":1,"column":55}}
|
|
},
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": " 6 ",
|
|
"start":57,"end":64,"loc":{"start":{"line":1,"column":57},"end":{"line":1,"column":64}}
|
|
},
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": " 7 ",
|
|
"start":67,"end":74,"loc":{"start":{"line":1,"column":67},"end":{"line":1,"column":74}}
|
|
},
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": " 8 ",
|
|
"start":76,"end":83,"loc":{"start":{"line":1,"column":76},"end":{"line":1,"column":83}}
|
|
},
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": " 9 ",
|
|
"start":85,"end":92,"loc":{"start":{"line":1,"column":85},"end":{"line":1,"column":92}}
|
|
},
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": " 1 ",
|
|
"start":109,"end":116,"loc":{"start":{"line":2,"column":9},"end":{"line":2,"column":16}}
|
|
},
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": " 2 ",
|
|
"start":121,"end":128,"loc":{"start":{"line":2,"column":21},"end":{"line":2,"column":28}}
|
|
},
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": " 3 ",
|
|
"start":131,"end":138,"loc":{"start":{"line":2,"column":31},"end":{"line":2,"column":38}}
|
|
},
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": " 4 ",
|
|
"start":139,"end":146,"loc":{"start":{"line":2,"column":39},"end":{"line":2,"column":46}}
|
|
},
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": " 5 ",
|
|
"start":148,"end":155,"loc":{"start":{"line":2,"column":48},"end":{"line":2,"column":55}}
|
|
},
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": " 6 ",
|
|
"start":157,"end":164,"loc":{"start":{"line":2,"column":57},"end":{"line":2,"column":64}}
|
|
},
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": " 7 ",
|
|
"start":166,"end":173,"loc":{"start":{"line":2,"column":66},"end":{"line":2,"column":73}}
|
|
},
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": " 1 ",
|
|
"start":194,"end":201,"loc":{"start":{"line":3,"column":13},"end":{"line":3,"column":20}}
|
|
}
|
|
]
|
|
} |