-
-
Notifications
You must be signed in to change notification settings - Fork 74
Open
Labels
Description
Input
Parse the following code:
// leading
a // trailingwith turned on Comment = true option in ParserOptions:
var program = parser.ParseProgram(source, new ParserOptions(source) { Comment = true; });After that, serialize the result AST with JsonConvert.
Expected
Leading and trailing should be attached to AST nodes. Check it on Esprima.org.
{
"type": "Program",
"body": [
{
"type": "ExpressionStatement",
"expression": {
"type": "Identifier",
"name": "a",
"trailingComments": [
{
"type": "Line",
"value": " trailing",
"range": [
13,
24
]
}
]
},
"leadingComments": [
{
"type": "Line",
"value": " leading",
"range": [
0,
10
]
}
]
}
],
"sourceType": "script"
}Actual
Comments are completely skipped.
{
"Type": "Program",
"Body": [
{
"Type": "ExpressionStatement",
"Expression": {
"Type": "Identifier",
"Name": "a",
"Loc": {}
},
"Loc": {}
}
],
"SourceType": "script",
"Loc": {}
}