Skip to content
This repository has been archived by the owner on May 19, 2018. It is now read-only.

Add identifier name to node loc field #90

Merged
merged 1 commit into from
Aug 16, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/parser/expression.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
foo(bar);
100 changes: 100 additions & 0 deletions test/fixtures/core/categorized/identifier-name-loc/expected.json
Original file line number Diff line number Diff line change
@@ -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": []
}
}