* 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
259 lines
8.6 KiB
JSON
259 lines
8.6 KiB
JSON
{
|
|
"type": "File",
|
|
"start":0,"end":153,"loc":{"start":{"line":1,"column":0},"end":{"line":4,"column":41}},
|
|
"program": {
|
|
"type": "Program",
|
|
"start":0,"end":153,"loc":{"start":{"line":1,"column":0},"end":{"line":4,"column":41}},
|
|
"sourceType": "script",
|
|
"interpreter": null,
|
|
"body": [
|
|
{
|
|
"type": "TryStatement",
|
|
"start":6,"end":146,"loc":{"start":{"line":1,"column":6},"end":{"line":4,"column":34}},
|
|
"leadingComments": [
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": "1",
|
|
"start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5}}
|
|
}
|
|
],
|
|
"trailingComments": [
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": "16",
|
|
"start":147,"end":153,"loc":{"start":{"line":4,"column":35},"end":{"line":4,"column":41}}
|
|
}
|
|
],
|
|
"block": {
|
|
"type": "BlockStatement",
|
|
"start":16,"end":58,"loc":{"start":{"line":1,"column":16},"end":{"line":3,"column":6}},
|
|
"leadingComments": [
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": "2",
|
|
"start":10,"end":15,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":15}}
|
|
}
|
|
],
|
|
"trailingComments": [
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": "7",
|
|
"start":59,"end":64,"loc":{"start":{"line":3,"column":7},"end":{"line":3,"column":12}}
|
|
}
|
|
],
|
|
"body": [
|
|
{
|
|
"type": "ThrowStatement",
|
|
"start":28,"end":51,"loc":{"start":{"line":2,"column":10},"end":{"line":2,"column":33}},
|
|
"leadingComments": [
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": "3",
|
|
"start":22,"end":27,"loc":{"start":{"line":2,"column":4},"end":{"line":2,"column":9}}
|
|
}
|
|
],
|
|
"trailingComments": [
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": "6",
|
|
"start":52,"end":57,"loc":{"start":{"line":3,"column":0},"end":{"line":3,"column":5}}
|
|
}
|
|
],
|
|
"argument": {
|
|
"type": "StringLiteral",
|
|
"start":40,"end":44,"loc":{"start":{"line":2,"column":22},"end":{"line":2,"column":26}},
|
|
"leadingComments": [
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": "4",
|
|
"start":34,"end":39,"loc":{"start":{"line":2,"column":16},"end":{"line":2,"column":21}}
|
|
}
|
|
],
|
|
"trailingComments": [
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": "5",
|
|
"start":45,"end":50,"loc":{"start":{"line":2,"column":27},"end":{"line":2,"column":32}}
|
|
}
|
|
],
|
|
"extra": {
|
|
"rawValue": "no",
|
|
"raw": "\"no\""
|
|
},
|
|
"value": "no"
|
|
}
|
|
}
|
|
],
|
|
"directives": []
|
|
},
|
|
"handler": {
|
|
"type": "CatchClause",
|
|
"start":65,"end":113,"loc":{"start":{"line":3,"column":13},"end":{"line":4,"column":1}},
|
|
"leadingComments": [
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": "7",
|
|
"start":59,"end":64,"loc":{"start":{"line":3,"column":7},"end":{"line":3,"column":12}}
|
|
}
|
|
],
|
|
"trailingComments": [
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": "13",
|
|
"start":114,"end":120,"loc":{"start":{"line":4,"column":2},"end":{"line":4,"column":8}}
|
|
}
|
|
],
|
|
"innerComments": [
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": "8",
|
|
"start":71,"end":76,"loc":{"start":{"line":3,"column":19},"end":{"line":3,"column":24}}
|
|
}
|
|
],
|
|
"param": {
|
|
"type": "Identifier",
|
|
"start":85,"end":86,"loc":{"start":{"line":3,"column":33},"end":{"line":3,"column":34},"identifierName":"e"},
|
|
"leadingComments": [
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": "9",
|
|
"start":79,"end":84,"loc":{"start":{"line":3,"column":27},"end":{"line":3,"column":32}}
|
|
}
|
|
],
|
|
"trailingComments": [
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": "10",
|
|
"start":87,"end":93,"loc":{"start":{"line":3,"column":35},"end":{"line":3,"column":41}}
|
|
}
|
|
],
|
|
"name": "e"
|
|
},
|
|
"body": {
|
|
"type": "BlockStatement",
|
|
"start":103,"end":113,"loc":{"start":{"line":3,"column":51},"end":{"line":4,"column":1}},
|
|
"leadingComments": [
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": "11",
|
|
"start":96,"end":102,"loc":{"start":{"line":3,"column":44},"end":{"line":3,"column":50}}
|
|
}
|
|
],
|
|
"innerComments": [
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": "12",
|
|
"start":105,"end":111,"loc":{"start":{"line":3,"column":53},"end":{"line":3,"column":59}}
|
|
}
|
|
],
|
|
"body": [],
|
|
"directives": []
|
|
}
|
|
},
|
|
"finalizer": {
|
|
"type": "BlockStatement",
|
|
"start":136,"end":146,"loc":{"start":{"line":4,"column":24},"end":{"line":4,"column":34}},
|
|
"leadingComments": [
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": "14",
|
|
"start":129,"end":135,"loc":{"start":{"line":4,"column":17},"end":{"line":4,"column":23}}
|
|
}
|
|
],
|
|
"innerComments": [
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": "15",
|
|
"start":138,"end":144,"loc":{"start":{"line":4,"column":26},"end":{"line":4,"column":32}}
|
|
}
|
|
],
|
|
"body": [],
|
|
"directives": []
|
|
}
|
|
}
|
|
],
|
|
"directives": []
|
|
},
|
|
"comments": [
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": "1",
|
|
"start":0,"end":5,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":5}}
|
|
},
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": "2",
|
|
"start":10,"end":15,"loc":{"start":{"line":1,"column":10},"end":{"line":1,"column":15}}
|
|
},
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": "3",
|
|
"start":22,"end":27,"loc":{"start":{"line":2,"column":4},"end":{"line":2,"column":9}}
|
|
},
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": "4",
|
|
"start":34,"end":39,"loc":{"start":{"line":2,"column":16},"end":{"line":2,"column":21}}
|
|
},
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": "5",
|
|
"start":45,"end":50,"loc":{"start":{"line":2,"column":27},"end":{"line":2,"column":32}}
|
|
},
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": "6",
|
|
"start":52,"end":57,"loc":{"start":{"line":3,"column":0},"end":{"line":3,"column":5}}
|
|
},
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": "7",
|
|
"start":59,"end":64,"loc":{"start":{"line":3,"column":7},"end":{"line":3,"column":12}}
|
|
},
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": "8",
|
|
"start":71,"end":76,"loc":{"start":{"line":3,"column":19},"end":{"line":3,"column":24}}
|
|
},
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": "9",
|
|
"start":79,"end":84,"loc":{"start":{"line":3,"column":27},"end":{"line":3,"column":32}}
|
|
},
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": "10",
|
|
"start":87,"end":93,"loc":{"start":{"line":3,"column":35},"end":{"line":3,"column":41}}
|
|
},
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": "11",
|
|
"start":96,"end":102,"loc":{"start":{"line":3,"column":44},"end":{"line":3,"column":50}}
|
|
},
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": "12",
|
|
"start":105,"end":111,"loc":{"start":{"line":3,"column":53},"end":{"line":3,"column":59}}
|
|
},
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": "13",
|
|
"start":114,"end":120,"loc":{"start":{"line":4,"column":2},"end":{"line":4,"column":8}}
|
|
},
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": "14",
|
|
"start":129,"end":135,"loc":{"start":{"line":4,"column":17},"end":{"line":4,"column":23}}
|
|
},
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": "15",
|
|
"start":138,"end":144,"loc":{"start":{"line":4,"column":26},"end":{"line":4,"column":32}}
|
|
},
|
|
{
|
|
"type": "CommentBlock",
|
|
"value": "16",
|
|
"start":147,"end":153,"loc":{"start":{"line":4,"column":35},"end":{"line":4,"column":41}}
|
|
}
|
|
]
|
|
} |