Diego Ferreiro Val 01da62283c Modify grammar to support Private Fields proposal: (#260)
* Modify grammar to support Private Fields proposal:
- Adding optional plugin `classPrivateProperties`
- Adding PrivateName type identifier
- Adding ClassPrivateProperty to ClassBody
- Allow PrivateName in MemberExpression
- Allow PrivateName as a reference
- Adding tests

* Remove unnecesary liberal parameter

* Guarding for plugin dependecy for future versioning

* update spec.md [skip ci]

* move comment [skip ci]

* remove unused param [skip ci]

* Refactor PrivateName to contain Identifier in name property
2017-05-22 11:33:48 -04:00

1627 lines
51 KiB
JSON

{
"type": "File",
"start": 0,
"end": 329,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 19,
"column": 1
}
},
"program": {
"type": "Program",
"start": 0,
"end": 329,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 19,
"column": 1
}
},
"sourceType": "script",
"body": [
{
"type": "ClassDeclaration",
"start": 0,
"end": 329,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 19,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 6,
"end": 11,
"loc": {
"start": {
"line": 1,
"column": 6
},
"end": {
"line": 1,
"column": 11
},
"identifierName": "Point"
},
"name": "Point"
},
"superClass": null,
"body": {
"type": "ClassBody",
"start": 12,
"end": 329,
"loc": {
"start": {
"line": 1,
"column": 12
},
"end": {
"line": 19,
"column": 1
}
},
"body": [
{
"type": "ClassPrivateProperty",
"start": 18,
"end": 21,
"loc": {
"start": {
"line": 2,
"column": 4
},
"end": {
"line": 2,
"column": 7
}
},
"computed": false,
"key": {
"type": "Identifier",
"start": 19,
"end": 20,
"loc": {
"start": {
"line": 2,
"column": 5
},
"end": {
"line": 2,
"column": 6
},
"identifierName": "x"
},
"name": "x"
},
"value": null
},
{
"type": "ClassPrivateProperty",
"start": 26,
"end": 29,
"loc": {
"start": {
"line": 3,
"column": 4
},
"end": {
"line": 3,
"column": 7
}
},
"computed": false,
"key": {
"type": "Identifier",
"start": 27,
"end": 28,
"loc": {
"start": {
"line": 3,
"column": 5
},
"end": {
"line": 3,
"column": 6
},
"identifierName": "y"
},
"name": "y"
},
"value": null
},
{
"type": "ClassMethod",
"start": 35,
"end": 102,
"loc": {
"start": {
"line": 5,
"column": 4
},
"end": {
"line": 8,
"column": 5
}
},
"static": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 35,
"end": 46,
"loc": {
"start": {
"line": 5,
"column": 4
},
"end": {
"line": 5,
"column": 15
},
"identifierName": "constructor"
},
"name": "constructor"
},
"kind": "constructor",
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [
{
"type": "AssignmentPattern",
"start": 47,
"end": 52,
"loc": {
"start": {
"line": 5,
"column": 16
},
"end": {
"line": 5,
"column": 21
}
},
"left": {
"type": "Identifier",
"start": 47,
"end": 48,
"loc": {
"start": {
"line": 5,
"column": 16
},
"end": {
"line": 5,
"column": 17
},
"identifierName": "x"
},
"name": "x"
},
"right": {
"type": "NumericLiteral",
"start": 51,
"end": 52,
"loc": {
"start": {
"line": 5,
"column": 20
},
"end": {
"line": 5,
"column": 21
}
},
"extra": {
"rawValue": 0,
"raw": "0"
},
"value": 0
}
},
{
"type": "AssignmentPattern",
"start": 54,
"end": 59,
"loc": {
"start": {
"line": 5,
"column": 23
},
"end": {
"line": 5,
"column": 28
}
},
"left": {
"type": "Identifier",
"start": 54,
"end": 55,
"loc": {
"start": {
"line": 5,
"column": 23
},
"end": {
"line": 5,
"column": 24
},
"identifierName": "y"
},
"name": "y"
},
"right": {
"type": "NumericLiteral",
"start": 58,
"end": 59,
"loc": {
"start": {
"line": 5,
"column": 27
},
"end": {
"line": 5,
"column": 28
}
},
"extra": {
"rawValue": 0,
"raw": "0"
},
"value": 0
}
}
],
"body": {
"type": "BlockStatement",
"start": 61,
"end": 102,
"loc": {
"start": {
"line": 5,
"column": 30
},
"end": {
"line": 8,
"column": 5
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 71,
"end": 79,
"loc": {
"start": {
"line": 6,
"column": 8
},
"end": {
"line": 6,
"column": 16
}
},
"expression": {
"type": "AssignmentExpression",
"start": 71,
"end": 78,
"loc": {
"start": {
"line": 6,
"column": 8
},
"end": {
"line": 6,
"column": 15
}
},
"operator": "=",
"left": {
"type": "PrivateName",
"start": 72,
"end": 73,
"loc": {
"start": {
"line": 6,
"column": 9
},
"end": {
"line": 6,
"column": 10
}
},
"name": {
"type": "Identifier",
"start": 72,
"end": 73,
"loc": {
"start": {
"line": 6,
"column": 9
},
"end": {
"line": 6,
"column": 10
},
"identifierName": "x"
},
"name": "x"
}
},
"right": {
"type": "UnaryExpression",
"start": 76,
"end": 78,
"loc": {
"start": {
"line": 6,
"column": 13
},
"end": {
"line": 6,
"column": 15
}
},
"operator": "+",
"prefix": true,
"argument": {
"type": "Identifier",
"start": 77,
"end": 78,
"loc": {
"start": {
"line": 6,
"column": 14
},
"end": {
"line": 6,
"column": 15
},
"identifierName": "x"
},
"name": "x"
},
"extra": {
"parenthesizedArgument": false
}
}
}
},
{
"type": "ExpressionStatement",
"start": 88,
"end": 96,
"loc": {
"start": {
"line": 7,
"column": 8
},
"end": {
"line": 7,
"column": 16
}
},
"expression": {
"type": "AssignmentExpression",
"start": 88,
"end": 95,
"loc": {
"start": {
"line": 7,
"column": 8
},
"end": {
"line": 7,
"column": 15
}
},
"operator": "=",
"left": {
"type": "PrivateName",
"start": 89,
"end": 90,
"loc": {
"start": {
"line": 7,
"column": 9
},
"end": {
"line": 7,
"column": 10
}
},
"name": {
"type": "Identifier",
"start": 89,
"end": 90,
"loc": {
"start": {
"line": 7,
"column": 9
},
"end": {
"line": 7,
"column": 10
},
"identifierName": "y"
},
"name": "y"
}
},
"right": {
"type": "UnaryExpression",
"start": 93,
"end": 95,
"loc": {
"start": {
"line": 7,
"column": 13
},
"end": {
"line": 7,
"column": 15
}
},
"operator": "+",
"prefix": true,
"argument": {
"type": "Identifier",
"start": 94,
"end": 95,
"loc": {
"start": {
"line": 7,
"column": 14
},
"end": {
"line": 7,
"column": 15
},
"identifierName": "y"
},
"name": "y"
},
"extra": {
"parenthesizedArgument": false
}
}
}
}
],
"directives": []
}
},
{
"type": "ClassMethod",
"start": 108,
"end": 129,
"loc": {
"start": {
"line": 10,
"column": 4
},
"end": {
"line": 10,
"column": 25
}
},
"static": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 112,
"end": 113,
"loc": {
"start": {
"line": 10,
"column": 8
},
"end": {
"line": 10,
"column": 9
},
"identifierName": "x"
},
"name": "x"
},
"kind": "get",
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 116,
"end": 129,
"loc": {
"start": {
"line": 10,
"column": 12
},
"end": {
"line": 10,
"column": 25
}
},
"body": [
{
"type": "ReturnStatement",
"start": 118,
"end": 127,
"loc": {
"start": {
"line": 10,
"column": 14
},
"end": {
"line": 10,
"column": 23
}
},
"argument": {
"type": "PrivateName",
"start": 126,
"end": 127,
"loc": {
"start": {
"line": 10,
"column": 22
},
"end": {
"line": 10,
"column": 23
}
},
"name": {
"type": "Identifier",
"start": 126,
"end": 127,
"loc": {
"start": {
"line": 10,
"column": 22
},
"end": {
"line": 10,
"column": 23
},
"identifierName": "x"
},
"name": "x"
}
}
}
],
"directives": []
}
},
{
"type": "ClassMethod",
"start": 134,
"end": 162,
"loc": {
"start": {
"line": 11,
"column": 4
},
"end": {
"line": 11,
"column": 32
}
},
"static": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 138,
"end": 139,
"loc": {
"start": {
"line": 11,
"column": 8
},
"end": {
"line": 11,
"column": 9
},
"identifierName": "x"
},
"name": "x"
},
"kind": "set",
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 140,
"end": 145,
"loc": {
"start": {
"line": 11,
"column": 10
},
"end": {
"line": 11,
"column": 15
},
"identifierName": "value"
},
"name": "value"
}
],
"body": {
"type": "BlockStatement",
"start": 147,
"end": 162,
"loc": {
"start": {
"line": 11,
"column": 17
},
"end": {
"line": 11,
"column": 32
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 149,
"end": 160,
"loc": {
"start": {
"line": 11,
"column": 19
},
"end": {
"line": 11,
"column": 30
}
},
"expression": {
"type": "AssignmentExpression",
"start": 149,
"end": 160,
"loc": {
"start": {
"line": 11,
"column": 19
},
"end": {
"line": 11,
"column": 30
}
},
"operator": "=",
"left": {
"type": "PrivateName",
"start": 150,
"end": 151,
"loc": {
"start": {
"line": 11,
"column": 20
},
"end": {
"line": 11,
"column": 21
}
},
"name": {
"type": "Identifier",
"start": 150,
"end": 151,
"loc": {
"start": {
"line": 11,
"column": 20
},
"end": {
"line": 11,
"column": 21
},
"identifierName": "x"
},
"name": "x"
}
},
"right": {
"type": "UnaryExpression",
"start": 154,
"end": 160,
"loc": {
"start": {
"line": 11,
"column": 24
},
"end": {
"line": 11,
"column": 30
}
},
"operator": "+",
"prefix": true,
"argument": {
"type": "Identifier",
"start": 155,
"end": 160,
"loc": {
"start": {
"line": 11,
"column": 25
},
"end": {
"line": 11,
"column": 30
},
"identifierName": "value"
},
"name": "value"
},
"extra": {
"parenthesizedArgument": false
}
}
}
}
],
"directives": []
}
},
{
"type": "ClassMethod",
"start": 168,
"end": 189,
"loc": {
"start": {
"line": 13,
"column": 4
},
"end": {
"line": 13,
"column": 25
}
},
"static": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 172,
"end": 173,
"loc": {
"start": {
"line": 13,
"column": 8
},
"end": {
"line": 13,
"column": 9
},
"identifierName": "y"
},
"name": "y"
},
"kind": "get",
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 176,
"end": 189,
"loc": {
"start": {
"line": 13,
"column": 12
},
"end": {
"line": 13,
"column": 25
}
},
"body": [
{
"type": "ReturnStatement",
"start": 178,
"end": 187,
"loc": {
"start": {
"line": 13,
"column": 14
},
"end": {
"line": 13,
"column": 23
}
},
"argument": {
"type": "PrivateName",
"start": 186,
"end": 187,
"loc": {
"start": {
"line": 13,
"column": 22
},
"end": {
"line": 13,
"column": 23
}
},
"name": {
"type": "Identifier",
"start": 186,
"end": 187,
"loc": {
"start": {
"line": 13,
"column": 22
},
"end": {
"line": 13,
"column": 23
},
"identifierName": "y"
},
"name": "y"
}
}
}
],
"directives": []
}
},
{
"type": "ClassMethod",
"start": 194,
"end": 222,
"loc": {
"start": {
"line": 14,
"column": 4
},
"end": {
"line": 14,
"column": 32
}
},
"static": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 198,
"end": 199,
"loc": {
"start": {
"line": 14,
"column": 8
},
"end": {
"line": 14,
"column": 9
},
"identifierName": "y"
},
"name": "y"
},
"kind": "set",
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 200,
"end": 205,
"loc": {
"start": {
"line": 14,
"column": 10
},
"end": {
"line": 14,
"column": 15
},
"identifierName": "value"
},
"name": "value"
}
],
"body": {
"type": "BlockStatement",
"start": 207,
"end": 222,
"loc": {
"start": {
"line": 14,
"column": 17
},
"end": {
"line": 14,
"column": 32
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 209,
"end": 220,
"loc": {
"start": {
"line": 14,
"column": 19
},
"end": {
"line": 14,
"column": 30
}
},
"expression": {
"type": "AssignmentExpression",
"start": 209,
"end": 220,
"loc": {
"start": {
"line": 14,
"column": 19
},
"end": {
"line": 14,
"column": 30
}
},
"operator": "=",
"left": {
"type": "PrivateName",
"start": 210,
"end": 211,
"loc": {
"start": {
"line": 14,
"column": 20
},
"end": {
"line": 14,
"column": 21
}
},
"name": {
"type": "Identifier",
"start": 210,
"end": 211,
"loc": {
"start": {
"line": 14,
"column": 20
},
"end": {
"line": 14,
"column": 21
},
"identifierName": "y"
},
"name": "y"
}
},
"right": {
"type": "UnaryExpression",
"start": 214,
"end": 220,
"loc": {
"start": {
"line": 14,
"column": 24
},
"end": {
"line": 14,
"column": 30
}
},
"operator": "+",
"prefix": true,
"argument": {
"type": "Identifier",
"start": 215,
"end": 220,
"loc": {
"start": {
"line": 14,
"column": 25
},
"end": {
"line": 14,
"column": 30
},
"identifierName": "value"
},
"name": "value"
},
"extra": {
"parenthesizedArgument": false
}
}
}
}
],
"directives": []
}
},
{
"type": "ClassMethod",
"start": 228,
"end": 275,
"loc": {
"start": {
"line": 16,
"column": 4
},
"end": {
"line": 16,
"column": 51
}
},
"static": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 228,
"end": 234,
"loc": {
"start": {
"line": 16,
"column": 4
},
"end": {
"line": 16,
"column": 10
},
"identifierName": "equals"
},
"name": "equals"
},
"kind": "method",
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 235,
"end": 236,
"loc": {
"start": {
"line": 16,
"column": 11
},
"end": {
"line": 16,
"column": 12
},
"identifierName": "p"
},
"name": "p"
}
],
"body": {
"type": "BlockStatement",
"start": 238,
"end": 275,
"loc": {
"start": {
"line": 16,
"column": 14
},
"end": {
"line": 16,
"column": 51
}
},
"body": [
{
"type": "ReturnStatement",
"start": 240,
"end": 273,
"loc": {
"start": {
"line": 16,
"column": 16
},
"end": {
"line": 16,
"column": 49
}
},
"argument": {
"type": "LogicalExpression",
"start": 247,
"end": 273,
"loc": {
"start": {
"line": 16,
"column": 23
},
"end": {
"line": 16,
"column": 49
}
},
"left": {
"type": "BinaryExpression",
"start": 247,
"end": 258,
"loc": {
"start": {
"line": 16,
"column": 23
},
"end": {
"line": 16,
"column": 34
}
},
"left": {
"type": "PrivateName",
"start": 248,
"end": 249,
"loc": {
"start": {
"line": 16,
"column": 24
},
"end": {
"line": 16,
"column": 25
}
},
"name": {
"type": "Identifier",
"start": 248,
"end": 249,
"loc": {
"start": {
"line": 16,
"column": 24
},
"end": {
"line": 16,
"column": 25
},
"identifierName": "x"
},
"name": "x"
}
},
"operator": "===",
"right": {
"type": "MemberExpression",
"start": 254,
"end": 258,
"loc": {
"start": {
"line": 16,
"column": 30
},
"end": {
"line": 16,
"column": 34
}
},
"object": {
"type": "Identifier",
"start": 254,
"end": 255,
"loc": {
"start": {
"line": 16,
"column": 30
},
"end": {
"line": 16,
"column": 31
},
"identifierName": "p"
},
"name": "p"
},
"property": {
"type": "PrivateName",
"start": 257,
"end": 258,
"loc": {
"start": {
"line": 16,
"column": 33
},
"end": {
"line": 16,
"column": 34
}
},
"name": {
"type": "Identifier",
"start": 257,
"end": 258,
"loc": {
"start": {
"line": 16,
"column": 33
},
"end": {
"line": 16,
"column": 34
},
"identifierName": "x"
},
"name": "x"
}
},
"computed": false
}
},
"operator": "&&",
"right": {
"type": "BinaryExpression",
"start": 262,
"end": 273,
"loc": {
"start": {
"line": 16,
"column": 38
},
"end": {
"line": 16,
"column": 49
}
},
"left": {
"type": "PrivateName",
"start": 263,
"end": 264,
"loc": {
"start": {
"line": 16,
"column": 39
},
"end": {
"line": 16,
"column": 40
}
},
"name": {
"type": "Identifier",
"start": 263,
"end": 264,
"loc": {
"start": {
"line": 16,
"column": 39
},
"end": {
"line": 16,
"column": 40
},
"identifierName": "y"
},
"name": "y"
}
},
"operator": "===",
"right": {
"type": "MemberExpression",
"start": 269,
"end": 273,
"loc": {
"start": {
"line": 16,
"column": 45
},
"end": {
"line": 16,
"column": 49
}
},
"object": {
"type": "Identifier",
"start": 269,
"end": 270,
"loc": {
"start": {
"line": 16,
"column": 45
},
"end": {
"line": 16,
"column": 46
},
"identifierName": "p"
},
"name": "p"
},
"property": {
"type": "PrivateName",
"start": 272,
"end": 273,
"loc": {
"start": {
"line": 16,
"column": 48
},
"end": {
"line": 16,
"column": 49
}
},
"name": {
"type": "Identifier",
"start": 272,
"end": 273,
"loc": {
"start": {
"line": 16,
"column": 48
},
"end": {
"line": 16,
"column": 49
},
"identifierName": "y"
},
"name": "y"
}
},
"computed": false
}
}
}
}
],
"directives": []
}
},
{
"type": "ClassMethod",
"start": 281,
"end": 327,
"loc": {
"start": {
"line": 18,
"column": 4
},
"end": {
"line": 18,
"column": 50
}
},
"static": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 281,
"end": 289,
"loc": {
"start": {
"line": 18,
"column": 4
},
"end": {
"line": 18,
"column": 12
},
"identifierName": "toString"
},
"name": "toString"
},
"kind": "method",
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 292,
"end": 327,
"loc": {
"start": {
"line": 18,
"column": 15
},
"end": {
"line": 18,
"column": 50
}
},
"body": [
{
"type": "ReturnStatement",
"start": 294,
"end": 325,
"loc": {
"start": {
"line": 18,
"column": 17
},
"end": {
"line": 18,
"column": 48
}
},
"argument": {
"type": "TemplateLiteral",
"start": 301,
"end": 325,
"loc": {
"start": {
"line": 18,
"column": 24
},
"end": {
"line": 18,
"column": 48
}
},
"expressions": [
{
"type": "PrivateName",
"start": 312,
"end": 313,
"loc": {
"start": {
"line": 18,
"column": 35
},
"end": {
"line": 18,
"column": 36
}
},
"name": {
"type": "Identifier",
"start": 312,
"end": 313,
"loc": {
"start": {
"line": 18,
"column": 35
},
"end": {
"line": 18,
"column": 36
},
"identifierName": "x"
},
"name": "x"
}
},
{
"type": "PrivateName",
"start": 320,
"end": 321,
"loc": {
"start": {
"line": 18,
"column": 43
},
"end": {
"line": 18,
"column": 44
}
},
"name": {
"type": "Identifier",
"start": 320,
"end": 321,
"loc": {
"start": {
"line": 18,
"column": 43
},
"end": {
"line": 18,
"column": 44
},
"identifierName": "y"
},
"name": "y"
}
}
],
"quasis": [
{
"type": "TemplateElement",
"start": 302,
"end": 308,
"loc": {
"start": {
"line": 18,
"column": 25
},
"end": {
"line": 18,
"column": 31
}
},
"value": {
"raw": "Point<",
"cooked": "Point<"
},
"tail": false
},
{
"type": "TemplateElement",
"start": 315,
"end": 316,
"loc": {
"start": {
"line": 18,
"column": 38
},
"end": {
"line": 18,
"column": 39
}
},
"value": {
"raw": ",",
"cooked": ","
},
"tail": false
},
{
"type": "TemplateElement",
"start": 323,
"end": 324,
"loc": {
"start": {
"line": 18,
"column": 46
},
"end": {
"line": 18,
"column": 47
}
},
"value": {
"raw": ">",
"cooked": ">"
},
"tail": true
}
]
}
}
],
"directives": []
}
}
]
}
}
],
"directives": []
}
}