parse parameter decorators

This commit is contained in:
Shuhei Kagawa
2016-03-24 10:01:58 +09:00
parent 6b14e4cb91
commit 29a6578658
13 changed files with 1870 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
class Foo {
constructor(@foo() x, @bar({ a: 123 }) @baz() y) {}
}

View File

@@ -0,0 +1,388 @@
{
"type": "File",
"start": 0,
"end": 67,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 1
}
},
"program": {
"type": "Program",
"start": 0,
"end": 67,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 1
}
},
"sourceType": "script",
"body": [
{
"type": "ClassDeclaration",
"start": 0,
"end": 67,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 6,
"end": 9,
"loc": {
"start": {
"line": 1,
"column": 6
},
"end": {
"line": 1,
"column": 9
}
},
"name": "Foo"
},
"superClass": null,
"body": {
"type": "ClassBody",
"start": 10,
"end": 67,
"loc": {
"start": {
"line": 1,
"column": 10
},
"end": {
"line": 3,
"column": 1
}
},
"body": [
{
"type": "ClassMethod",
"start": 14,
"end": 65,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 53
}
},
"computed": false,
"key": {
"type": "Identifier",
"start": 14,
"end": 25,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 13
}
},
"name": "constructor"
},
"static": false,
"kind": "constructor",
"id": null,
"generator": false,
"expression": false,
"params": [
{
"type": "Identifier",
"start": 33,
"end": 34,
"loc": {
"start": {
"line": 2,
"column": 21
},
"end": {
"line": 2,
"column": 22
}
},
"name": "x",
"decorators": [
{
"type": "Decorator",
"start": 26,
"end": 32,
"loc": {
"start": {
"line": 2,
"column": 14
},
"end": {
"line": 2,
"column": 20
}
},
"expression": {
"type": "CallExpression",
"start": 27,
"end": 32,
"loc": {
"start": {
"line": 2,
"column": 15
},
"end": {
"line": 2,
"column": 20
}
},
"callee": {
"type": "Identifier",
"start": 27,
"end": 30,
"loc": {
"start": {
"line": 2,
"column": 15
},
"end": {
"line": 2,
"column": 18
}
},
"name": "foo"
},
"arguments": []
}
}
]
},
{
"type": "Identifier",
"start": 60,
"end": 61,
"loc": {
"start": {
"line": 2,
"column": 48
},
"end": {
"line": 2,
"column": 49
}
},
"name": "y",
"decorators": [
{
"type": "Decorator",
"start": 36,
"end": 52,
"loc": {
"start": {
"line": 2,
"column": 24
},
"end": {
"line": 2,
"column": 40
}
},
"expression": {
"type": "CallExpression",
"start": 37,
"end": 52,
"loc": {
"start": {
"line": 2,
"column": 25
},
"end": {
"line": 2,
"column": 40
}
},
"callee": {
"type": "Identifier",
"start": 37,
"end": 40,
"loc": {
"start": {
"line": 2,
"column": 25
},
"end": {
"line": 2,
"column": 28
}
},
"name": "bar"
},
"arguments": [
{
"type": "ObjectExpression",
"start": 41,
"end": 51,
"loc": {
"start": {
"line": 2,
"column": 29
},
"end": {
"line": 2,
"column": 39
}
},
"properties": [
{
"type": "ObjectProperty",
"start": 43,
"end": 49,
"loc": {
"start": {
"line": 2,
"column": 31
},
"end": {
"line": 2,
"column": 37
}
},
"method": false,
"shorthand": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 43,
"end": 44,
"loc": {
"start": {
"line": 2,
"column": 31
},
"end": {
"line": 2,
"column": 32
}
},
"name": "a"
},
"value": {
"type": "NumericLiteral",
"start": 46,
"end": 49,
"loc": {
"start": {
"line": 2,
"column": 34
},
"end": {
"line": 2,
"column": 37
}
},
"extra": {
"rawValue": 123,
"raw": "123"
},
"value": 123
}
}
]
}
]
}
},
{
"type": "Decorator",
"start": 53,
"end": 59,
"loc": {
"start": {
"line": 2,
"column": 41
},
"end": {
"line": 2,
"column": 47
}
},
"expression": {
"type": "CallExpression",
"start": 54,
"end": 59,
"loc": {
"start": {
"line": 2,
"column": 42
},
"end": {
"line": 2,
"column": 47
}
},
"callee": {
"type": "Identifier",
"start": 54,
"end": 57,
"loc": {
"start": {
"line": 2,
"column": 42
},
"end": {
"line": 2,
"column": 45
}
},
"name": "baz"
},
"arguments": []
}
}
]
}
],
"body": {
"type": "BlockStatement",
"start": 63,
"end": 65,
"loc": {
"start": {
"line": 2,
"column": 51
},
"end": {
"line": 2,
"column": 53
}
},
"body": [],
"directives": []
}
}
]
}
}
],
"directives": []
}
}