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 @@
var obj = {
method(@foo() x, @bar({ a: 123 }) @baz() y) {}
};

View File

@@ -0,0 +1,406 @@
{
"type": "File",
"start": 0,
"end": 63,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 2
}
},
"program": {
"type": "Program",
"start": 0,
"end": 63,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 2
}
},
"sourceType": "script",
"body": [
{
"type": "VariableDeclaration",
"start": 0,
"end": 63,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 2
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 4,
"end": 62,
"loc": {
"start": {
"line": 1,
"column": 4
},
"end": {
"line": 3,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 4,
"end": 7,
"loc": {
"start": {
"line": 1,
"column": 4
},
"end": {
"line": 1,
"column": 7
}
},
"name": "obj"
},
"init": {
"type": "ObjectExpression",
"start": 10,
"end": 62,
"loc": {
"start": {
"line": 1,
"column": 10
},
"end": {
"line": 3,
"column": 1
}
},
"properties": [
{
"type": "ObjectMethod",
"start": 14,
"end": 60,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 48
}
},
"method": true,
"shorthand": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 14,
"end": 20,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 8
}
},
"name": "method"
},
"kind": "method",
"id": null,
"generator": false,
"expression": false,
"params": [
{
"type": "Identifier",
"start": 28,
"end": 29,
"loc": {
"start": {
"line": 2,
"column": 16
},
"end": {
"line": 2,
"column": 17
}
},
"name": "x",
"decorators": [
{
"type": "Decorator",
"start": 21,
"end": 27,
"loc": {
"start": {
"line": 2,
"column": 9
},
"end": {
"line": 2,
"column": 15
}
},
"expression": {
"type": "CallExpression",
"start": 22,
"end": 27,
"loc": {
"start": {
"line": 2,
"column": 10
},
"end": {
"line": 2,
"column": 15
}
},
"callee": {
"type": "Identifier",
"start": 22,
"end": 25,
"loc": {
"start": {
"line": 2,
"column": 10
},
"end": {
"line": 2,
"column": 13
}
},
"name": "foo"
},
"arguments": []
}
}
]
},
{
"type": "Identifier",
"start": 55,
"end": 56,
"loc": {
"start": {
"line": 2,
"column": 43
},
"end": {
"line": 2,
"column": 44
}
},
"name": "y",
"decorators": [
{
"type": "Decorator",
"start": 31,
"end": 47,
"loc": {
"start": {
"line": 2,
"column": 19
},
"end": {
"line": 2,
"column": 35
}
},
"expression": {
"type": "CallExpression",
"start": 32,
"end": 47,
"loc": {
"start": {
"line": 2,
"column": 20
},
"end": {
"line": 2,
"column": 35
}
},
"callee": {
"type": "Identifier",
"start": 32,
"end": 35,
"loc": {
"start": {
"line": 2,
"column": 20
},
"end": {
"line": 2,
"column": 23
}
},
"name": "bar"
},
"arguments": [
{
"type": "ObjectExpression",
"start": 36,
"end": 46,
"loc": {
"start": {
"line": 2,
"column": 24
},
"end": {
"line": 2,
"column": 34
}
},
"properties": [
{
"type": "ObjectProperty",
"start": 38,
"end": 44,
"loc": {
"start": {
"line": 2,
"column": 26
},
"end": {
"line": 2,
"column": 32
}
},
"method": false,
"shorthand": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 38,
"end": 39,
"loc": {
"start": {
"line": 2,
"column": 26
},
"end": {
"line": 2,
"column": 27
}
},
"name": "a"
},
"value": {
"type": "NumericLiteral",
"start": 41,
"end": 44,
"loc": {
"start": {
"line": 2,
"column": 29
},
"end": {
"line": 2,
"column": 32
}
},
"extra": {
"rawValue": 123,
"raw": "123"
},
"value": 123
}
}
]
}
]
}
},
{
"type": "Decorator",
"start": 48,
"end": 54,
"loc": {
"start": {
"line": 2,
"column": 36
},
"end": {
"line": 2,
"column": 42
}
},
"expression": {
"type": "CallExpression",
"start": 49,
"end": 54,
"loc": {
"start": {
"line": 2,
"column": 37
},
"end": {
"line": 2,
"column": 42
}
},
"callee": {
"type": "Identifier",
"start": 49,
"end": 52,
"loc": {
"start": {
"line": 2,
"column": 37
},
"end": {
"line": 2,
"column": 40
}
},
"name": "baz"
},
"arguments": []
}
}
]
}
],
"body": {
"type": "BlockStatement",
"start": 58,
"end": 60,
"loc": {
"start": {
"line": 2,
"column": 46
},
"end": {
"line": 2,
"column": 48
}
},
"body": [],
"directives": []
}
}
]
}
}
],
"kind": "var"
}
],
"directives": []
}
}