* 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
325 lines
12 KiB
JSON
325 lines
12 KiB
JSON
{
|
|
"type": "File",
|
|
"start":0,"end":197,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":28}},
|
|
"program": {
|
|
"type": "Program",
|
|
"start":0,"end":197,"loc":{"start":{"line":1,"column":0},"end":{"line":3,"column":28}},
|
|
"sourceType": "script",
|
|
"interpreter": null,
|
|
"body": [
|
|
{
|
|
"type": "ExpressionStatement",
|
|
"start":0,"end":93,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":93}},
|
|
"expression": {
|
|
"type": "ObjectExpression",
|
|
"start":1,"end":91,"loc":{"start":{"line":1,"column":1},"end":{"line":1,"column":91}},
|
|
"extra": {
|
|
"parenthesized": true,
|
|
"parenStart": 0
|
|
},
|
|
"properties": [
|
|
{
|
|
"type": "ObjectMethod",
|
|
"start":11,"end":89,"loc":{"start":{"line":1,"column":11},"end":{"line":1,"column":89}},
|
|
"leadingComments": [
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": " 1 ",
|
|
"start":3,"end":10,"loc":{"start":{"line":1,"column":3},"end":{"line":1,"column":10}}
|
|
}
|
|
],
|
|
"innerComments": [
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": " 2 ",
|
|
"start":15,"end":22,"loc":{"start":{"line":1,"column":15},"end":{"line":1,"column":22}}
|
|
},
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": " 5 ",
|
|
"start":42,"end":49,"loc":{"start":{"line":1,"column":42},"end":{"line":1,"column":49}}
|
|
}
|
|
],
|
|
"method": false,
|
|
"key": {
|
|
"type": "Identifier",
|
|
"start":32,"end":33,"loc":{"start":{"line":1,"column":32},"end":{"line":1,"column":33},"identifierName":"f"},
|
|
"leadingComments": [
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": " 3 ",
|
|
"start":25,"end":32,"loc":{"start":{"line":1,"column":25},"end":{"line":1,"column":32}}
|
|
}
|
|
],
|
|
"trailingComments": [
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": " 4 ",
|
|
"start":33,"end":40,"loc":{"start":{"line":1,"column":33},"end":{"line":1,"column":40}}
|
|
}
|
|
],
|
|
"name": "f"
|
|
},
|
|
"computed": true,
|
|
"kind": "set",
|
|
"id": null,
|
|
"generator": false,
|
|
"async": false,
|
|
"params": [
|
|
{
|
|
"type": "Identifier",
|
|
"start":59,"end":60,"loc":{"start":{"line":1,"column":59},"end":{"line":1,"column":60},"identifierName":"a"},
|
|
"leadingComments": [
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": " 6 ",
|
|
"start":51,"end":58,"loc":{"start":{"line":1,"column":51},"end":{"line":1,"column":58}}
|
|
}
|
|
],
|
|
"trailingComments": [
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": " 7 ",
|
|
"start":61,"end":68,"loc":{"start":{"line":1,"column":61},"end":{"line":1,"column":68}}
|
|
},
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": " 8 ",
|
|
"start":70,"end":77,"loc":{"start":{"line":1,"column":70},"end":{"line":1,"column":77}}
|
|
}
|
|
],
|
|
"name": "a"
|
|
}
|
|
],
|
|
"body": {
|
|
"type": "BlockStatement",
|
|
"start":87,"end":89,"loc":{"start":{"line":1,"column":87},"end":{"line":1,"column":89}},
|
|
"leadingComments": [
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": " 9 ",
|
|
"start":79,"end":86,"loc":{"start":{"line":1,"column":79},"end":{"line":1,"column":86}}
|
|
}
|
|
],
|
|
"body": [],
|
|
"directives": []
|
|
}
|
|
}
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"type": "ExpressionStatement",
|
|
"start":94,"end":168,"loc":{"start":{"line":2,"column":0},"end":{"line":2,"column":74}},
|
|
"expression": {
|
|
"type": "ObjectExpression",
|
|
"start":95,"end":166,"loc":{"start":{"line":2,"column":1},"end":{"line":2,"column":72}},
|
|
"extra": {
|
|
"parenthesized": true,
|
|
"parenStart": 94
|
|
},
|
|
"properties": [
|
|
{
|
|
"type": "ObjectMethod",
|
|
"start":105,"end":164,"loc":{"start":{"line":2,"column":11},"end":{"line":2,"column":70}},
|
|
"leadingComments": [
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": " 1 ",
|
|
"start":97,"end":104,"loc":{"start":{"line":2,"column":3},"end":{"line":2,"column":10}}
|
|
}
|
|
],
|
|
"innerComments": [
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": " 2 ",
|
|
"start":109,"end":116,"loc":{"start":{"line":2,"column":15},"end":{"line":2,"column":22}}
|
|
},
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": " 5 ",
|
|
"start":136,"end":143,"loc":{"start":{"line":2,"column":42},"end":{"line":2,"column":49}}
|
|
},
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": " 6 ",
|
|
"start":145,"end":152,"loc":{"start":{"line":2,"column":51},"end":{"line":2,"column":58}}
|
|
}
|
|
],
|
|
"method": false,
|
|
"key": {
|
|
"type": "Identifier",
|
|
"start":126,"end":127,"loc":{"start":{"line":2,"column":32},"end":{"line":2,"column":33},"identifierName":"f"},
|
|
"leadingComments": [
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": " 3 ",
|
|
"start":119,"end":126,"loc":{"start":{"line":2,"column":25},"end":{"line":2,"column":32}}
|
|
}
|
|
],
|
|
"trailingComments": [
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": " 4 ",
|
|
"start":127,"end":134,"loc":{"start":{"line":2,"column":33},"end":{"line":2,"column":40}}
|
|
}
|
|
],
|
|
"name": "f"
|
|
},
|
|
"computed": true,
|
|
"kind": "get",
|
|
"id": null,
|
|
"generator": false,
|
|
"async": false,
|
|
"params": [],
|
|
"body": {
|
|
"type": "BlockStatement",
|
|
"start":162,"end":164,"loc":{"start":{"line":2,"column":68},"end":{"line":2,"column":70}},
|
|
"leadingComments": [
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": " 7 ",
|
|
"start":154,"end":161,"loc":{"start":{"line":2,"column":60},"end":{"line":2,"column":67}}
|
|
}
|
|
],
|
|
"body": [],
|
|
"directives": []
|
|
}
|
|
}
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"type": "ExpressionStatement",
|
|
"start":169,"end":197,"loc":{"start":{"line":3,"column":0},"end":{"line":3,"column":28}},
|
|
"expression": {
|
|
"type": "ObjectExpression",
|
|
"start":170,"end":195,"loc":{"start":{"line":3,"column":1},"end":{"line":3,"column":26}},
|
|
"extra": {
|
|
"parenthesized": true,
|
|
"parenStart": 169
|
|
},
|
|
"properties": [
|
|
{
|
|
"type": "ObjectMethod",
|
|
"start":172,"end":193,"loc":{"start":{"line":3,"column":3},"end":{"line":3,"column":24}},
|
|
"innerComments": [
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": " 1 ",
|
|
"start":176,"end":183,"loc":{"start":{"line":3,"column":7},"end":{"line":3,"column":14}}
|
|
}
|
|
],
|
|
"method": false,
|
|
"key": {
|
|
"type": "Identifier",
|
|
"start":185,"end":186,"loc":{"start":{"line":3,"column":16},"end":{"line":3,"column":17},"identifierName":"f"},
|
|
"name": "f"
|
|
},
|
|
"computed": true,
|
|
"kind": "get",
|
|
"id": null,
|
|
"generator": false,
|
|
"async": false,
|
|
"params": [],
|
|
"body": {
|
|
"type": "BlockStatement",
|
|
"start":191,"end":193,"loc":{"start":{"line":3,"column":22},"end":{"line":3,"column":24}},
|
|
"body": [],
|
|
"directives": []
|
|
}
|
|
}
|
|
]
|
|
}
|
|
}
|
|
],
|
|
"directives": []
|
|
},
|
|
"comments": [
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": " 1 ",
|
|
"start":3,"end":10,"loc":{"start":{"line":1,"column":3},"end":{"line":1,"column":10}}
|
|
},
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": " 2 ",
|
|
"start":15,"end":22,"loc":{"start":{"line":1,"column":15},"end":{"line":1,"column":22}}
|
|
},
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": " 3 ",
|
|
"start":25,"end":32,"loc":{"start":{"line":1,"column":25},"end":{"line":1,"column":32}}
|
|
},
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": " 4 ",
|
|
"start":33,"end":40,"loc":{"start":{"line":1,"column":33},"end":{"line":1,"column":40}}
|
|
},
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": " 5 ",
|
|
"start":42,"end":49,"loc":{"start":{"line":1,"column":42},"end":{"line":1,"column":49}}
|
|
},
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": " 6 ",
|
|
"start":51,"end":58,"loc":{"start":{"line":1,"column":51},"end":{"line":1,"column":58}}
|
|
},
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": " 7 ",
|
|
"start":61,"end":68,"loc":{"start":{"line":1,"column":61},"end":{"line":1,"column":68}}
|
|
},
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": " 8 ",
|
|
"start":70,"end":77,"loc":{"start":{"line":1,"column":70},"end":{"line":1,"column":77}}
|
|
},
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": " 9 ",
|
|
"start":79,"end":86,"loc":{"start":{"line":1,"column":79},"end":{"line":1,"column":86}}
|
|
},
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": " 1 ",
|
|
"start":97,"end":104,"loc":{"start":{"line":2,"column":3},"end":{"line":2,"column":10}}
|
|
},
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": " 2 ",
|
|
"start":109,"end":116,"loc":{"start":{"line":2,"column":15},"end":{"line":2,"column":22}}
|
|
},
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": " 3 ",
|
|
"start":119,"end":126,"loc":{"start":{"line":2,"column":25},"end":{"line":2,"column":32}}
|
|
},
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": " 4 ",
|
|
"start":127,"end":134,"loc":{"start":{"line":2,"column":33},"end":{"line":2,"column":40}}
|
|
},
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": " 5 ",
|
|
"start":136,"end":143,"loc":{"start":{"line":2,"column":42},"end":{"line":2,"column":49}}
|
|
},
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": " 6 ",
|
|
"start":145,"end":152,"loc":{"start":{"line":2,"column":51},"end":{"line":2,"column":58}}
|
|
},
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": " 7 ",
|
|
"start":154,"end":161,"loc":{"start":{"line":2,"column":60},"end":{"line":2,"column":67}}
|
|
},
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": " 1 ",
|
|
"start":176,"end":183,"loc":{"start":{"line":3,"column":7},"end":{"line":3,"column":14}}
|
|
}
|
|
]
|
|
} |