Add identifier name to node loc field (#90)

This commit is contained in:
Sebastian McKenzie 2016-08-16 14:41:10 +01:00 committed by Henry Zhu
parent 69e914baeb
commit 0b87d4c97c
3 changed files with 103 additions and 0 deletions

View File

@ -979,6 +979,8 @@ pp.parseIdentifier = function (liberal) {
this.raise(node.start, "invalid use of await inside of an async function");
}
node.loc.identifierName = node.name;
this.next();
return this.finishNode(node, "Identifier");
};

View File

@ -0,0 +1 @@
foo(bar);

View File

@ -0,0 +1,100 @@
{
"type": "File",
"start": 0,
"end": 9,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 9
}
},
"program": {
"type": "Program",
"start": 0,
"end": 9,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 9
}
},
"sourceType": "script",
"body": [
{
"type": "ExpressionStatement",
"start": 0,
"end": 9,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 9
}
},
"expression": {
"type": "CallExpression",
"start": 0,
"end": 8,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 8
}
},
"callee": {
"type": "Identifier",
"start": 0,
"end": 3,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 3
},
"identifierName": "foo"
},
"name": "foo"
},
"arguments": [
{
"type": "Identifier",
"start": 4,
"end": 7,
"loc": {
"start": {
"line": 1,
"column": 4
},
"end": {
"line": 1,
"column": 7
},
"identifierName": "bar"
},
"name": "bar"
}
]
}
}
],
"directives": []
}
}