Update decorators parsing (#7719)
* Update decorators parsing
This commit introduces three changes:
1) Class properties can be decorated
2) Decorators can contain arbitrary expressions, using @(...)
3) The Decorator node type has a new property, "arguments". This
makes it possible do distinguish @dec() and @(dec()), which have
different behaviors because @(dec()) is equivalent to @(dec())().
* Rename Decorator#expression to Decorator#callee
* Add test for @dec()()
This commit is contained in:
@@ -265,33 +265,37 @@ export default class StatementParser extends ExpressionParser {
|
||||
this.next();
|
||||
|
||||
if (this.hasPlugin("decorators2")) {
|
||||
const startPos = this.state.start;
|
||||
const startLoc = this.state.startLoc;
|
||||
let expr = this.parseIdentifier(false);
|
||||
// Every time a decorator class expression is evaluated, a new empty array is pushed onto the stack
|
||||
// So that the decorators of any nested class expressions will be dealt with separately
|
||||
this.state.decoratorStack.push([]);
|
||||
|
||||
while (this.eat(tt.dot)) {
|
||||
const node = this.startNodeAt(startPos, startLoc);
|
||||
node.object = expr;
|
||||
node.property = this.parseIdentifier(true);
|
||||
node.computed = false;
|
||||
expr = this.finishNode(node, "MemberExpression");
|
||||
if (this.eat(tt.parenL)) {
|
||||
node.callee = this.parseExpression();
|
||||
this.expect(tt.parenR);
|
||||
} else {
|
||||
const startPos = this.state.start;
|
||||
const startLoc = this.state.startLoc;
|
||||
let expr = this.parseIdentifier(false);
|
||||
|
||||
while (this.eat(tt.dot)) {
|
||||
const node = this.startNodeAt(startPos, startLoc);
|
||||
node.object = expr;
|
||||
node.property = this.parseIdentifier(true);
|
||||
node.computed = false;
|
||||
expr = this.finishNode(node, "MemberExpression");
|
||||
}
|
||||
|
||||
node.callee = expr;
|
||||
}
|
||||
|
||||
if (this.eat(tt.parenL)) {
|
||||
const node = this.startNodeAt(startPos, startLoc);
|
||||
node.callee = expr;
|
||||
// Every time a decorator class expression is evaluated, a new empty array is pushed onto the stack
|
||||
// So that the decorators of any nested class expressions will be dealt with separately
|
||||
this.state.decoratorStack.push([]);
|
||||
node.arguments = this.parseCallExpressionArguments(tt.parenR, false);
|
||||
this.state.decoratorStack.pop();
|
||||
expr = this.finishNode(node, "CallExpression");
|
||||
this.toReferencedList(expr.arguments);
|
||||
this.toReferencedList(node.arguments);
|
||||
}
|
||||
|
||||
node.expression = expr;
|
||||
this.state.decoratorStack.pop();
|
||||
} else {
|
||||
node.expression = this.parseMaybeAssign();
|
||||
node.callee = this.parseMaybeAssign();
|
||||
}
|
||||
return this.finishNode(node, "Decorator");
|
||||
}
|
||||
@@ -959,14 +963,13 @@ export default class StatementParser extends ExpressionParser {
|
||||
this.parseClassMember(classBody, member, state);
|
||||
|
||||
if (
|
||||
this.hasPlugin("decorators2") &&
|
||||
["method", "get", "set"].indexOf(member.kind) === -1 &&
|
||||
member.kind === "constructor" &&
|
||||
member.decorators &&
|
||||
member.decorators.length > 0
|
||||
) {
|
||||
this.raise(
|
||||
member.start,
|
||||
"Stage 2 decorators may only be used with a class or a class method",
|
||||
"Decorators can't be used with a constructor. Did you mean '@dec class { ... }'?",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -336,6 +336,7 @@ export type VariableDeclarator = NodeBase & {
|
||||
export type Decorator = NodeBase & {
|
||||
type: "Decorator",
|
||||
expression: Expression,
|
||||
arguments?: Array<Expression | SpreadElement>,
|
||||
};
|
||||
|
||||
export type Directive = NodeBase & {
|
||||
|
||||
@@ -57,10 +57,10 @@
|
||||
"column": 11
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"type": "CallExpression",
|
||||
"callee": {
|
||||
"type": "Identifier",
|
||||
"start": 1,
|
||||
"end": 11,
|
||||
"end": 4,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
@@ -68,49 +68,34 @@
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 11
|
||||
}
|
||||
"column": 4
|
||||
},
|
||||
"identifierName": "foo"
|
||||
},
|
||||
"callee": {
|
||||
"type": "Identifier",
|
||||
"start": 1,
|
||||
"end": 4,
|
||||
"name": "foo"
|
||||
},
|
||||
"arguments": [
|
||||
{
|
||||
"type": "StringLiteral",
|
||||
"start": 5,
|
||||
"end": 10,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 1
|
||||
"column": 5
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 4
|
||||
},
|
||||
"identifierName": "foo"
|
||||
"column": 10
|
||||
}
|
||||
},
|
||||
"name": "foo"
|
||||
},
|
||||
"arguments": [
|
||||
{
|
||||
"type": "StringLiteral",
|
||||
"start": 5,
|
||||
"end": 10,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 5
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 10
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"rawValue": "bar",
|
||||
"raw": "'bar'"
|
||||
},
|
||||
"value": "bar"
|
||||
}
|
||||
]
|
||||
}
|
||||
"extra": {
|
||||
"rawValue": "bar",
|
||||
"raw": "'bar'"
|
||||
},
|
||||
"value": "bar"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"id": {
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
"column": 4
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"callee": {
|
||||
"type": "Identifier",
|
||||
"start": 1,
|
||||
"end": 4,
|
||||
|
||||
@@ -103,7 +103,7 @@
|
||||
"column": 14
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"callee": {
|
||||
"type": "Identifier",
|
||||
"start": 11,
|
||||
"end": 14,
|
||||
@@ -184,7 +184,7 @@
|
||||
"column": 6
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"callee": {
|
||||
"type": "Identifier",
|
||||
"start": 30,
|
||||
"end": 33,
|
||||
|
||||
@@ -104,7 +104,7 @@
|
||||
"column": 6
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"callee": {
|
||||
"type": "Identifier",
|
||||
"start": 13,
|
||||
"end": 16,
|
||||
|
||||
3
packages/babylon/test/fixtures/experimental/decorators-2/class-property/options.json
vendored
Normal file
3
packages/babylon/test/fixtures/experimental/decorators-2/class-property/options.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"plugins": ["classProperties", "classPrivateProperties", "decorators2"]
|
||||
}
|
||||
172
packages/babylon/test/fixtures/experimental/decorators-2/class-property/output.json
vendored
Normal file
172
packages/babylon/test/fixtures/experimental/decorators-2/class-property/output.json
vendored
Normal file
@@ -0,0 +1,172 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start": 0,
|
||||
"end": 27,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start": 0,
|
||||
"end": 27,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"sourceType": "script",
|
||||
"body": [
|
||||
{
|
||||
"type": "ClassDeclaration",
|
||||
"start": 0,
|
||||
"end": 27,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start": 6,
|
||||
"end": 7,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 6
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 7
|
||||
},
|
||||
"identifierName": "A"
|
||||
},
|
||||
"name": "A"
|
||||
},
|
||||
"superClass": null,
|
||||
"body": {
|
||||
"type": "ClassBody",
|
||||
"start": 8,
|
||||
"end": 27,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 8
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"body": [
|
||||
{
|
||||
"type": "ClassProperty",
|
||||
"start": 12,
|
||||
"end": 25,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 2
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 15
|
||||
}
|
||||
},
|
||||
"decorators": [
|
||||
{
|
||||
"type": "Decorator",
|
||||
"start": 12,
|
||||
"end": 16,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 2
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 6
|
||||
}
|
||||
},
|
||||
"callee": {
|
||||
"type": "Identifier",
|
||||
"start": 13,
|
||||
"end": 16,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 3
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 6
|
||||
},
|
||||
"identifierName": "dec"
|
||||
},
|
||||
"name": "dec"
|
||||
}
|
||||
}
|
||||
],
|
||||
"static": false,
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start": 17,
|
||||
"end": 21,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 7
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 11
|
||||
},
|
||||
"identifierName": "name"
|
||||
},
|
||||
"name": "name"
|
||||
},
|
||||
"computed": false,
|
||||
"value": {
|
||||
"type": "NumericLiteral",
|
||||
"start": 24,
|
||||
"end": 25,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 14
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 15
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"rawValue": 0,
|
||||
"raw": "0"
|
||||
},
|
||||
"value": 0
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
@@ -104,10 +104,10 @@
|
||||
"column": 16
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"type": "CallExpression",
|
||||
"callee": {
|
||||
"type": "MemberExpression",
|
||||
"start": 13,
|
||||
"end": 26,
|
||||
"end": 20,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
@@ -115,13 +115,13 @@
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 16
|
||||
"column": 10
|
||||
}
|
||||
},
|
||||
"callee": {
|
||||
"object": {
|
||||
"type": "MemberExpression",
|
||||
"start": 13,
|
||||
"end": 20,
|
||||
"end": 18,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
@@ -129,13 +129,13 @@
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 10
|
||||
"column": 8
|
||||
}
|
||||
},
|
||||
"object": {
|
||||
"type": "MemberExpression",
|
||||
"start": 13,
|
||||
"end": 18,
|
||||
"end": 16,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
@@ -143,13 +143,13 @@
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 8
|
||||
"column": 6
|
||||
}
|
||||
},
|
||||
"object": {
|
||||
"type": "MemberExpression",
|
||||
"type": "Identifier",
|
||||
"start": 13,
|
||||
"end": 16,
|
||||
"end": 14,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
@@ -157,120 +157,105 @@
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 6
|
||||
}
|
||||
},
|
||||
"object": {
|
||||
"type": "Identifier",
|
||||
"start": 13,
|
||||
"end": 14,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 3
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 4
|
||||
},
|
||||
"identifierName": "a"
|
||||
"column": 4
|
||||
},
|
||||
"name": "a"
|
||||
"identifierName": "a"
|
||||
},
|
||||
"property": {
|
||||
"type": "Identifier",
|
||||
"start": 15,
|
||||
"end": 16,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 5
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 6
|
||||
},
|
||||
"identifierName": "b"
|
||||
},
|
||||
"name": "b"
|
||||
},
|
||||
"computed": false
|
||||
"name": "a"
|
||||
},
|
||||
"property": {
|
||||
"type": "Identifier",
|
||||
"start": 17,
|
||||
"end": 18,
|
||||
"start": 15,
|
||||
"end": 16,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 7
|
||||
"column": 5
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 8
|
||||
"column": 6
|
||||
},
|
||||
"identifierName": "c"
|
||||
"identifierName": "b"
|
||||
},
|
||||
"name": "c"
|
||||
"name": "b"
|
||||
},
|
||||
"computed": false
|
||||
},
|
||||
"property": {
|
||||
"type": "Identifier",
|
||||
"start": 19,
|
||||
"end": 20,
|
||||
"start": 17,
|
||||
"end": 18,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 9
|
||||
"column": 7
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 10
|
||||
"column": 8
|
||||
},
|
||||
"identifierName": "d"
|
||||
"identifierName": "c"
|
||||
},
|
||||
"name": "d"
|
||||
"name": "c"
|
||||
},
|
||||
"computed": false
|
||||
},
|
||||
"arguments": [
|
||||
{
|
||||
"type": "Identifier",
|
||||
"start": 21,
|
||||
"end": 22,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 11
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 12
|
||||
},
|
||||
"identifierName": "e"
|
||||
"property": {
|
||||
"type": "Identifier",
|
||||
"start": 19,
|
||||
"end": 20,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 9
|
||||
},
|
||||
"name": "e"
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 10
|
||||
},
|
||||
"identifierName": "d"
|
||||
},
|
||||
{
|
||||
"type": "Identifier",
|
||||
"start": 24,
|
||||
"end": 25,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 14
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 15
|
||||
},
|
||||
"identifierName": "f"
|
||||
"name": "d"
|
||||
},
|
||||
"computed": false
|
||||
},
|
||||
"arguments": [
|
||||
{
|
||||
"type": "Identifier",
|
||||
"start": 21,
|
||||
"end": 22,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 11
|
||||
},
|
||||
"name": "f"
|
||||
}
|
||||
]
|
||||
}
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 12
|
||||
},
|
||||
"identifierName": "e"
|
||||
},
|
||||
"name": "e"
|
||||
},
|
||||
{
|
||||
"type": "Identifier",
|
||||
"start": 24,
|
||||
"end": 25,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 14
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 15
|
||||
},
|
||||
"identifierName": "f"
|
||||
},
|
||||
"name": "f"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"static": false,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class Foo {
|
||||
@bar[bizz]
|
||||
@bar [bizz]
|
||||
abc() {
|
||||
|
||||
}
|
||||
3
packages/babylon/test/fixtures/experimental/decorators-2/compued-property/options.json
vendored
Normal file
3
packages/babylon/test/fixtures/experimental/decorators-2/compued-property/options.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"plugins": ["decorators2", "classProperties"]
|
||||
}
|
||||
209
packages/babylon/test/fixtures/experimental/decorators-2/compued-property/output.json
vendored
Normal file
209
packages/babylon/test/fixtures/experimental/decorators-2/compued-property/output.json
vendored
Normal file
@@ -0,0 +1,209 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start": 0,
|
||||
"end": 42,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 6,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start": 0,
|
||||
"end": 42,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 6,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"sourceType": "script",
|
||||
"body": [
|
||||
{
|
||||
"type": "ClassDeclaration",
|
||||
"start": 0,
|
||||
"end": 42,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 6,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start": 6,
|
||||
"end": 9,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 6
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 9
|
||||
},
|
||||
"identifierName": "Foo"
|
||||
},
|
||||
"name": "Foo"
|
||||
},
|
||||
"superClass": null,
|
||||
"body": {
|
||||
"type": "ClassBody",
|
||||
"start": 10,
|
||||
"end": 42,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 10
|
||||
},
|
||||
"end": {
|
||||
"line": 6,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"body": [
|
||||
{
|
||||
"type": "ClassProperty",
|
||||
"start": 14,
|
||||
"end": 25,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 2
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 13
|
||||
}
|
||||
},
|
||||
"decorators": [
|
||||
{
|
||||
"type": "Decorator",
|
||||
"start": 14,
|
||||
"end": 18,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 2
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 6
|
||||
}
|
||||
},
|
||||
"callee": {
|
||||
"type": "Identifier",
|
||||
"start": 15,
|
||||
"end": 18,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 3
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 6
|
||||
},
|
||||
"identifierName": "bar"
|
||||
},
|
||||
"name": "bar"
|
||||
}
|
||||
}
|
||||
],
|
||||
"static": false,
|
||||
"computed": true,
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start": 20,
|
||||
"end": 24,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 8
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 12
|
||||
},
|
||||
"identifierName": "bizz"
|
||||
},
|
||||
"name": "bizz"
|
||||
},
|
||||
"value": null
|
||||
},
|
||||
{
|
||||
"type": "ClassMethod",
|
||||
"start": 28,
|
||||
"end": 40,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 2
|
||||
},
|
||||
"end": {
|
||||
"line": 5,
|
||||
"column": 3
|
||||
}
|
||||
},
|
||||
"static": false,
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start": 28,
|
||||
"end": 31,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 2
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 5
|
||||
},
|
||||
"identifierName": "abc"
|
||||
},
|
||||
"name": "abc"
|
||||
},
|
||||
"computed": false,
|
||||
"kind": "method",
|
||||
"id": null,
|
||||
"generator": false,
|
||||
"async": false,
|
||||
"params": [],
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start": 34,
|
||||
"end": 40,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 8
|
||||
},
|
||||
"end": {
|
||||
"line": 5,
|
||||
"column": 3
|
||||
}
|
||||
},
|
||||
"body": [],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
@@ -73,7 +73,7 @@
|
||||
"column": 11
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"callee": {
|
||||
"type": "Identifier",
|
||||
"start": 8,
|
||||
"end": 11,
|
||||
|
||||
@@ -71,7 +71,7 @@
|
||||
"column": 4
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"callee": {
|
||||
"type": "Identifier",
|
||||
"start": 17,
|
||||
"end": 20,
|
||||
@@ -129,4 +129,4 @@
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -104,7 +104,7 @@
|
||||
"column": 6
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"callee": {
|
||||
"type": "Identifier",
|
||||
"start": 13,
|
||||
"end": 16,
|
||||
|
||||
@@ -57,175 +57,160 @@
|
||||
"column": 2
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"type": "CallExpression",
|
||||
"callee": {
|
||||
"type": "Identifier",
|
||||
"start": 1,
|
||||
"end": 40,
|
||||
"end": 6,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 1
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 2
|
||||
}
|
||||
"line": 1,
|
||||
"column": 6
|
||||
},
|
||||
"identifierName": "outer"
|
||||
},
|
||||
"callee": {
|
||||
"type": "Identifier",
|
||||
"start": 1,
|
||||
"end": 6,
|
||||
"name": "outer"
|
||||
},
|
||||
"arguments": [
|
||||
{
|
||||
"type": "ObjectExpression",
|
||||
"start": 7,
|
||||
"end": 39,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 1
|
||||
"column": 7
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 6
|
||||
},
|
||||
"identifierName": "outer"
|
||||
"line": 3,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"name": "outer"
|
||||
},
|
||||
"arguments": [
|
||||
{
|
||||
"type": "ObjectExpression",
|
||||
"start": 7,
|
||||
"end": 39,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 7
|
||||
"properties": [
|
||||
{
|
||||
"type": "ObjectProperty",
|
||||
"start": 11,
|
||||
"end": 37,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 2
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 28
|
||||
}
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"properties": [
|
||||
{
|
||||
"type": "ObjectProperty",
|
||||
"method": false,
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start": 11,
|
||||
"end": 37,
|
||||
"end": 16,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 2
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 7
|
||||
},
|
||||
"identifierName": "store"
|
||||
},
|
||||
"name": "store"
|
||||
},
|
||||
"computed": false,
|
||||
"shorthand": false,
|
||||
"value": {
|
||||
"type": "ClassExpression",
|
||||
"start": 18,
|
||||
"end": 37,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 9
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 28
|
||||
}
|
||||
},
|
||||
"method": false,
|
||||
"key": {
|
||||
"decorators": [
|
||||
{
|
||||
"type": "Decorator",
|
||||
"start": 18,
|
||||
"end": 24,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 9
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 15
|
||||
}
|
||||
},
|
||||
"callee": {
|
||||
"type": "Identifier",
|
||||
"start": 19,
|
||||
"end": 24,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 10
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 15
|
||||
},
|
||||
"identifierName": "inner"
|
||||
},
|
||||
"name": "inner"
|
||||
}
|
||||
}
|
||||
],
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start": 11,
|
||||
"end": 16,
|
||||
"start": 31,
|
||||
"end": 34,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 2
|
||||
"column": 22
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 7
|
||||
"column": 25
|
||||
},
|
||||
"identifierName": "store"
|
||||
"identifierName": "Foo"
|
||||
},
|
||||
"name": "store"
|
||||
"name": "Foo"
|
||||
},
|
||||
"computed": false,
|
||||
"shorthand": false,
|
||||
"value": {
|
||||
"type": "ClassExpression",
|
||||
"start": 18,
|
||||
"superClass": null,
|
||||
"body": {
|
||||
"type": "ClassBody",
|
||||
"start": 35,
|
||||
"end": 37,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 9
|
||||
"column": 26
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 28
|
||||
}
|
||||
},
|
||||
"decorators": [
|
||||
{
|
||||
"type": "Decorator",
|
||||
"start": 18,
|
||||
"end": 24,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 9
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 15
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"type": "Identifier",
|
||||
"start": 19,
|
||||
"end": 24,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 10
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 15
|
||||
},
|
||||
"identifierName": "inner"
|
||||
},
|
||||
"name": "inner"
|
||||
}
|
||||
}
|
||||
],
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start": 31,
|
||||
"end": 34,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 22
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 25
|
||||
},
|
||||
"identifierName": "Foo"
|
||||
},
|
||||
"name": "Foo"
|
||||
},
|
||||
"superClass": null,
|
||||
"body": {
|
||||
"type": "ClassBody",
|
||||
"start": 35,
|
||||
"end": 37,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 26
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 28
|
||||
}
|
||||
},
|
||||
"body": []
|
||||
}
|
||||
"body": []
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"id": {
|
||||
6
packages/babylon/test/fixtures/experimental/decorators-2/nested-class-decorator/input.js
vendored
Normal file
6
packages/babylon/test/fixtures/experimental/decorators-2/nested-class-decorator/input.js
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
@({
|
||||
store: @inner class Foo {}
|
||||
})
|
||||
class Bar {
|
||||
|
||||
}
|
||||
235
packages/babylon/test/fixtures/experimental/decorators-2/nested-class-decorator/output.json
vendored
Normal file
235
packages/babylon/test/fixtures/experimental/decorators-2/nested-class-decorator/output.json
vendored
Normal file
@@ -0,0 +1,235 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start": 0,
|
||||
"end": 52,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 6,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start": 0,
|
||||
"end": 52,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 6,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"sourceType": "script",
|
||||
"body": [
|
||||
{
|
||||
"type": "ClassDeclaration",
|
||||
"start": 0,
|
||||
"end": 52,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 6,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"decorators": [
|
||||
{
|
||||
"type": "Decorator",
|
||||
"start": 0,
|
||||
"end": 35,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 2
|
||||
}
|
||||
},
|
||||
"callee": {
|
||||
"type": "ObjectExpression",
|
||||
"start": 2,
|
||||
"end": 34,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 2
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"properties": [
|
||||
{
|
||||
"type": "ObjectProperty",
|
||||
"start": 6,
|
||||
"end": 32,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 2
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 28
|
||||
}
|
||||
},
|
||||
"method": false,
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start": 6,
|
||||
"end": 11,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 2
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 7
|
||||
},
|
||||
"identifierName": "store"
|
||||
},
|
||||
"name": "store"
|
||||
},
|
||||
"computed": false,
|
||||
"shorthand": false,
|
||||
"value": {
|
||||
"type": "ClassExpression",
|
||||
"start": 13,
|
||||
"end": 32,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 9
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 28
|
||||
}
|
||||
},
|
||||
"decorators": [
|
||||
{
|
||||
"type": "Decorator",
|
||||
"start": 13,
|
||||
"end": 19,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 9
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 15
|
||||
}
|
||||
},
|
||||
"callee": {
|
||||
"type": "Identifier",
|
||||
"start": 14,
|
||||
"end": 19,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 10
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 15
|
||||
},
|
||||
"identifierName": "inner"
|
||||
},
|
||||
"name": "inner"
|
||||
}
|
||||
}
|
||||
],
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start": 26,
|
||||
"end": 29,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 22
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 25
|
||||
},
|
||||
"identifierName": "Foo"
|
||||
},
|
||||
"name": "Foo"
|
||||
},
|
||||
"superClass": null,
|
||||
"body": {
|
||||
"type": "ClassBody",
|
||||
"start": 30,
|
||||
"end": 32,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 26
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 28
|
||||
}
|
||||
},
|
||||
"body": []
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start": 42,
|
||||
"end": 45,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 4,
|
||||
"column": 6
|
||||
},
|
||||
"end": {
|
||||
"line": 4,
|
||||
"column": 9
|
||||
},
|
||||
"identifierName": "Bar"
|
||||
},
|
||||
"name": "Bar"
|
||||
},
|
||||
"superClass": null,
|
||||
"body": {
|
||||
"type": "ClassBody",
|
||||
"start": 46,
|
||||
"end": 52,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 4,
|
||||
"column": 10
|
||||
},
|
||||
"end": {
|
||||
"line": 6,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"body": []
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
@@ -104,198 +104,183 @@
|
||||
"column": 3
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"type": "CallExpression",
|
||||
"callee": {
|
||||
"type": "Identifier",
|
||||
"start": 14,
|
||||
"end": 91,
|
||||
"end": 19,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 3
|
||||
},
|
||||
"end": {
|
||||
"line": 7,
|
||||
"column": 3
|
||||
}
|
||||
"line": 2,
|
||||
"column": 8
|
||||
},
|
||||
"identifierName": "outer"
|
||||
},
|
||||
"callee": {
|
||||
"type": "Identifier",
|
||||
"start": 14,
|
||||
"end": 19,
|
||||
"name": "outer"
|
||||
},
|
||||
"arguments": [
|
||||
{
|
||||
"type": "ClassExpression",
|
||||
"start": 25,
|
||||
"end": 87,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 3
|
||||
"line": 3,
|
||||
"column": 4
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 8
|
||||
},
|
||||
"identifierName": "outer"
|
||||
"line": 6,
|
||||
"column": 5
|
||||
}
|
||||
},
|
||||
"name": "outer"
|
||||
},
|
||||
"arguments": [
|
||||
{
|
||||
"type": "ClassExpression",
|
||||
"start": 25,
|
||||
"decorators": [
|
||||
{
|
||||
"type": "Decorator",
|
||||
"start": 25,
|
||||
"end": 34,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 4
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 13
|
||||
}
|
||||
},
|
||||
"callee": {
|
||||
"type": "Identifier",
|
||||
"start": 26,
|
||||
"end": 34,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 5
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 13
|
||||
},
|
||||
"identifierName": "classDec"
|
||||
},
|
||||
"name": "classDec"
|
||||
}
|
||||
}
|
||||
],
|
||||
"id": null,
|
||||
"superClass": null,
|
||||
"body": {
|
||||
"type": "ClassBody",
|
||||
"start": 41,
|
||||
"end": 87,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 4
|
||||
"column": 20
|
||||
},
|
||||
"end": {
|
||||
"line": 6,
|
||||
"column": 5
|
||||
}
|
||||
},
|
||||
"decorators": [
|
||||
"body": [
|
||||
{
|
||||
"type": "Decorator",
|
||||
"start": 25,
|
||||
"end": 34,
|
||||
"type": "ClassMethod",
|
||||
"start": 50,
|
||||
"end": 80,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 4
|
||||
"line": 4,
|
||||
"column": 6
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 13
|
||||
"line": 5,
|
||||
"column": 22
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"decorators": [
|
||||
{
|
||||
"type": "Decorator",
|
||||
"start": 50,
|
||||
"end": 56,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 4,
|
||||
"column": 6
|
||||
},
|
||||
"end": {
|
||||
"line": 4,
|
||||
"column": 12
|
||||
}
|
||||
},
|
||||
"callee": {
|
||||
"type": "Identifier",
|
||||
"start": 51,
|
||||
"end": 56,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 4,
|
||||
"column": 7
|
||||
},
|
||||
"end": {
|
||||
"line": 4,
|
||||
"column": 12
|
||||
},
|
||||
"identifierName": "inner"
|
||||
},
|
||||
"name": "inner"
|
||||
}
|
||||
}
|
||||
],
|
||||
"static": false,
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start": 26,
|
||||
"end": 34,
|
||||
"start": 64,
|
||||
"end": 75,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 5
|
||||
"line": 5,
|
||||
"column": 6
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 13
|
||||
"line": 5,
|
||||
"column": 17
|
||||
},
|
||||
"identifierName": "classDec"
|
||||
"identifierName": "innerMethod"
|
||||
},
|
||||
"name": "classDec"
|
||||
}
|
||||
}
|
||||
],
|
||||
"id": null,
|
||||
"superClass": null,
|
||||
"body": {
|
||||
"type": "ClassBody",
|
||||
"start": 41,
|
||||
"end": 87,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 20
|
||||
"name": "innerMethod"
|
||||
},
|
||||
"end": {
|
||||
"line": 6,
|
||||
"column": 5
|
||||
}
|
||||
},
|
||||
"body": [
|
||||
{
|
||||
"type": "ClassMethod",
|
||||
"start": 50,
|
||||
"computed": false,
|
||||
"kind": "method",
|
||||
"id": null,
|
||||
"generator": false,
|
||||
"async": false,
|
||||
"params": [],
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start": 78,
|
||||
"end": 80,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 4,
|
||||
"column": 6
|
||||
"line": 5,
|
||||
"column": 20
|
||||
},
|
||||
"end": {
|
||||
"line": 5,
|
||||
"column": 22
|
||||
}
|
||||
},
|
||||
"decorators": [
|
||||
{
|
||||
"type": "Decorator",
|
||||
"start": 50,
|
||||
"end": 56,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 4,
|
||||
"column": 6
|
||||
},
|
||||
"end": {
|
||||
"line": 4,
|
||||
"column": 12
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"type": "Identifier",
|
||||
"start": 51,
|
||||
"end": 56,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 4,
|
||||
"column": 7
|
||||
},
|
||||
"end": {
|
||||
"line": 4,
|
||||
"column": 12
|
||||
},
|
||||
"identifierName": "inner"
|
||||
},
|
||||
"name": "inner"
|
||||
}
|
||||
}
|
||||
],
|
||||
"static": false,
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start": 64,
|
||||
"end": 75,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 5,
|
||||
"column": 6
|
||||
},
|
||||
"end": {
|
||||
"line": 5,
|
||||
"column": 17
|
||||
},
|
||||
"identifierName": "innerMethod"
|
||||
},
|
||||
"name": "innerMethod"
|
||||
},
|
||||
"computed": false,
|
||||
"kind": "method",
|
||||
"id": null,
|
||||
"generator": false,
|
||||
"async": false,
|
||||
"params": [],
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start": 78,
|
||||
"end": 80,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 5,
|
||||
"column": 20
|
||||
},
|
||||
"end": {
|
||||
"line": 5,
|
||||
"column": 22
|
||||
}
|
||||
},
|
||||
"body": [],
|
||||
"directives": []
|
||||
}
|
||||
"body": [],
|
||||
"directives": []
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"static": false,
|
||||
9
packages/babylon/test/fixtures/experimental/decorators-2/nested-method-decorator/input.js
vendored
Normal file
9
packages/babylon/test/fixtures/experimental/decorators-2/nested-method-decorator/input.js
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
class Bar{
|
||||
@(
|
||||
@classDec class {
|
||||
@inner
|
||||
innerMethod() {}
|
||||
}
|
||||
)
|
||||
outerMethod() {}
|
||||
}
|
||||
315
packages/babylon/test/fixtures/experimental/decorators-2/nested-method-decorator/output.json
vendored
Normal file
315
packages/babylon/test/fixtures/experimental/decorators-2/nested-method-decorator/output.json
vendored
Normal file
@@ -0,0 +1,315 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start": 0,
|
||||
"end": 107,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 9,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start": 0,
|
||||
"end": 107,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 9,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"sourceType": "script",
|
||||
"body": [
|
||||
{
|
||||
"type": "ClassDeclaration",
|
||||
"start": 0,
|
||||
"end": 107,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 9,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start": 6,
|
||||
"end": 9,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 6
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 9
|
||||
},
|
||||
"identifierName": "Bar"
|
||||
},
|
||||
"name": "Bar"
|
||||
},
|
||||
"superClass": null,
|
||||
"body": {
|
||||
"type": "ClassBody",
|
||||
"start": 9,
|
||||
"end": 107,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 9
|
||||
},
|
||||
"end": {
|
||||
"line": 9,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"body": [
|
||||
{
|
||||
"type": "ClassMethod",
|
||||
"start": 13,
|
||||
"end": 105,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 2
|
||||
},
|
||||
"end": {
|
||||
"line": 8,
|
||||
"column": 18
|
||||
}
|
||||
},
|
||||
"decorators": [
|
||||
{
|
||||
"type": "Decorator",
|
||||
"start": 13,
|
||||
"end": 86,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 2
|
||||
},
|
||||
"end": {
|
||||
"line": 7,
|
||||
"column": 3
|
||||
}
|
||||
},
|
||||
"callee": {
|
||||
"type": "ClassExpression",
|
||||
"start": 20,
|
||||
"end": 82,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 4
|
||||
},
|
||||
"end": {
|
||||
"line": 6,
|
||||
"column": 5
|
||||
}
|
||||
},
|
||||
"decorators": [
|
||||
{
|
||||
"type": "Decorator",
|
||||
"start": 20,
|
||||
"end": 29,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 4
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 13
|
||||
}
|
||||
},
|
||||
"callee": {
|
||||
"type": "Identifier",
|
||||
"start": 21,
|
||||
"end": 29,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 5
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 13
|
||||
},
|
||||
"identifierName": "classDec"
|
||||
},
|
||||
"name": "classDec"
|
||||
}
|
||||
}
|
||||
],
|
||||
"id": null,
|
||||
"superClass": null,
|
||||
"body": {
|
||||
"type": "ClassBody",
|
||||
"start": 36,
|
||||
"end": 82,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 20
|
||||
},
|
||||
"end": {
|
||||
"line": 6,
|
||||
"column": 5
|
||||
}
|
||||
},
|
||||
"body": [
|
||||
{
|
||||
"type": "ClassMethod",
|
||||
"start": 45,
|
||||
"end": 75,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 4,
|
||||
"column": 6
|
||||
},
|
||||
"end": {
|
||||
"line": 5,
|
||||
"column": 22
|
||||
}
|
||||
},
|
||||
"decorators": [
|
||||
{
|
||||
"type": "Decorator",
|
||||
"start": 45,
|
||||
"end": 51,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 4,
|
||||
"column": 6
|
||||
},
|
||||
"end": {
|
||||
"line": 4,
|
||||
"column": 12
|
||||
}
|
||||
},
|
||||
"callee": {
|
||||
"type": "Identifier",
|
||||
"start": 46,
|
||||
"end": 51,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 4,
|
||||
"column": 7
|
||||
},
|
||||
"end": {
|
||||
"line": 4,
|
||||
"column": 12
|
||||
},
|
||||
"identifierName": "inner"
|
||||
},
|
||||
"name": "inner"
|
||||
}
|
||||
}
|
||||
],
|
||||
"static": false,
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start": 59,
|
||||
"end": 70,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 5,
|
||||
"column": 6
|
||||
},
|
||||
"end": {
|
||||
"line": 5,
|
||||
"column": 17
|
||||
},
|
||||
"identifierName": "innerMethod"
|
||||
},
|
||||
"name": "innerMethod"
|
||||
},
|
||||
"computed": false,
|
||||
"kind": "method",
|
||||
"id": null,
|
||||
"generator": false,
|
||||
"async": false,
|
||||
"params": [],
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start": 73,
|
||||
"end": 75,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 5,
|
||||
"column": 20
|
||||
},
|
||||
"end": {
|
||||
"line": 5,
|
||||
"column": 22
|
||||
}
|
||||
},
|
||||
"body": [],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"static": false,
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start": 89,
|
||||
"end": 100,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 8,
|
||||
"column": 2
|
||||
},
|
||||
"end": {
|
||||
"line": 8,
|
||||
"column": 13
|
||||
},
|
||||
"identifierName": "outerMethod"
|
||||
},
|
||||
"name": "outerMethod"
|
||||
},
|
||||
"computed": false,
|
||||
"kind": "method",
|
||||
"id": null,
|
||||
"generator": false,
|
||||
"async": false,
|
||||
"params": [],
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start": 103,
|
||||
"end": 105,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 8,
|
||||
"column": 16
|
||||
},
|
||||
"end": {
|
||||
"line": 8,
|
||||
"column": 18
|
||||
}
|
||||
},
|
||||
"body": [],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
{
|
||||
"plugins": ["classProperties", "decorators2"],
|
||||
"throws": "Stage 2 decorators may only be used with a class or a class method (2:2)"
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
{
|
||||
"plugins": ["decorators2", "classProperties"],
|
||||
"throws": "Stage 2 decorators may only be used with a class or a class method (2:2)"
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
{
|
||||
"plugins": ["classProperties", "classPrivateProperties", "decorators2"],
|
||||
"throws": "Stage 2 decorators may only be used with a class or a class method (2:2)"
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
{
|
||||
"plugins": ["classProperties", "decorators2"],
|
||||
"throws": "Stage 2 decorators may only be used with a class or a class method (2:2)"
|
||||
}
|
||||
@@ -104,7 +104,7 @@
|
||||
"column": 6
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"callee": {
|
||||
"type": "Identifier",
|
||||
"start": 13,
|
||||
"end": 16,
|
||||
|
||||
6
packages/babylon/test/fixtures/experimental/decorators-2/parenthesized/input.js
vendored
Normal file
6
packages/babylon/test/fixtures/experimental/decorators-2/parenthesized/input.js
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
@(foo().bar)
|
||||
class Foo {
|
||||
@(member[expression]) method() {}
|
||||
|
||||
@(foo + bar) method2() {}
|
||||
}
|
||||
413
packages/babylon/test/fixtures/experimental/decorators-2/parenthesized/output.json
vendored
Normal file
413
packages/babylon/test/fixtures/experimental/decorators-2/parenthesized/output.json
vendored
Normal file
@@ -0,0 +1,413 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start": 0,
|
||||
"end": 91,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 6,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start": 0,
|
||||
"end": 91,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 6,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"sourceType": "script",
|
||||
"body": [
|
||||
{
|
||||
"type": "ClassDeclaration",
|
||||
"start": 0,
|
||||
"end": 91,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 6,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"decorators": [
|
||||
{
|
||||
"type": "Decorator",
|
||||
"start": 0,
|
||||
"end": 12,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 12
|
||||
}
|
||||
},
|
||||
"callee": {
|
||||
"type": "MemberExpression",
|
||||
"start": 2,
|
||||
"end": 11,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 2
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 11
|
||||
}
|
||||
},
|
||||
"object": {
|
||||
"type": "CallExpression",
|
||||
"start": 2,
|
||||
"end": 7,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 2
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 7
|
||||
}
|
||||
},
|
||||
"callee": {
|
||||
"type": "Identifier",
|
||||
"start": 2,
|
||||
"end": 5,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 2
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 5
|
||||
},
|
||||
"identifierName": "foo"
|
||||
},
|
||||
"name": "foo"
|
||||
},
|
||||
"arguments": []
|
||||
},
|
||||
"property": {
|
||||
"type": "Identifier",
|
||||
"start": 8,
|
||||
"end": 11,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 8
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 11
|
||||
},
|
||||
"identifierName": "bar"
|
||||
},
|
||||
"name": "bar"
|
||||
},
|
||||
"computed": false
|
||||
}
|
||||
}
|
||||
],
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start": 19,
|
||||
"end": 22,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 6
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 9
|
||||
},
|
||||
"identifierName": "Foo"
|
||||
},
|
||||
"name": "Foo"
|
||||
},
|
||||
"superClass": null,
|
||||
"body": {
|
||||
"type": "ClassBody",
|
||||
"start": 23,
|
||||
"end": 91,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 10
|
||||
},
|
||||
"end": {
|
||||
"line": 6,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"body": [
|
||||
{
|
||||
"type": "ClassMethod",
|
||||
"start": 27,
|
||||
"end": 60,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 2
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 35
|
||||
}
|
||||
},
|
||||
"decorators": [
|
||||
{
|
||||
"type": "Decorator",
|
||||
"start": 27,
|
||||
"end": 48,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 2
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 23
|
||||
}
|
||||
},
|
||||
"callee": {
|
||||
"type": "MemberExpression",
|
||||
"start": 29,
|
||||
"end": 47,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 4
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 22
|
||||
}
|
||||
},
|
||||
"object": {
|
||||
"type": "Identifier",
|
||||
"start": 29,
|
||||
"end": 35,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 4
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 10
|
||||
},
|
||||
"identifierName": "member"
|
||||
},
|
||||
"name": "member"
|
||||
},
|
||||
"property": {
|
||||
"type": "Identifier",
|
||||
"start": 36,
|
||||
"end": 46,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 11
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 21
|
||||
},
|
||||
"identifierName": "expression"
|
||||
},
|
||||
"name": "expression"
|
||||
},
|
||||
"computed": true
|
||||
}
|
||||
}
|
||||
],
|
||||
"static": false,
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start": 49,
|
||||
"end": 55,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 24
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 30
|
||||
},
|
||||
"identifierName": "method"
|
||||
},
|
||||
"name": "method"
|
||||
},
|
||||
"computed": false,
|
||||
"kind": "method",
|
||||
"id": null,
|
||||
"generator": false,
|
||||
"async": false,
|
||||
"params": [],
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start": 58,
|
||||
"end": 60,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"column": 33
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 35
|
||||
}
|
||||
},
|
||||
"body": [],
|
||||
"directives": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "ClassMethod",
|
||||
"start": 64,
|
||||
"end": 89,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 5,
|
||||
"column": 2
|
||||
},
|
||||
"end": {
|
||||
"line": 5,
|
||||
"column": 27
|
||||
}
|
||||
},
|
||||
"decorators": [
|
||||
{
|
||||
"type": "Decorator",
|
||||
"start": 64,
|
||||
"end": 76,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 5,
|
||||
"column": 2
|
||||
},
|
||||
"end": {
|
||||
"line": 5,
|
||||
"column": 14
|
||||
}
|
||||
},
|
||||
"callee": {
|
||||
"type": "BinaryExpression",
|
||||
"start": 66,
|
||||
"end": 75,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 5,
|
||||
"column": 4
|
||||
},
|
||||
"end": {
|
||||
"line": 5,
|
||||
"column": 13
|
||||
}
|
||||
},
|
||||
"left": {
|
||||
"type": "Identifier",
|
||||
"start": 66,
|
||||
"end": 69,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 5,
|
||||
"column": 4
|
||||
},
|
||||
"end": {
|
||||
"line": 5,
|
||||
"column": 7
|
||||
},
|
||||
"identifierName": "foo"
|
||||
},
|
||||
"name": "foo"
|
||||
},
|
||||
"operator": "+",
|
||||
"right": {
|
||||
"type": "Identifier",
|
||||
"start": 72,
|
||||
"end": 75,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 5,
|
||||
"column": 10
|
||||
},
|
||||
"end": {
|
||||
"line": 5,
|
||||
"column": 13
|
||||
},
|
||||
"identifierName": "bar"
|
||||
},
|
||||
"name": "bar"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"static": false,
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start": 77,
|
||||
"end": 84,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 5,
|
||||
"column": 15
|
||||
},
|
||||
"end": {
|
||||
"line": 5,
|
||||
"column": 22
|
||||
},
|
||||
"identifierName": "method2"
|
||||
},
|
||||
"name": "method2"
|
||||
},
|
||||
"computed": false,
|
||||
"kind": "method",
|
||||
"id": null,
|
||||
"generator": false,
|
||||
"async": false,
|
||||
"params": [],
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start": 87,
|
||||
"end": 89,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 5,
|
||||
"column": 25
|
||||
},
|
||||
"end": {
|
||||
"line": 5,
|
||||
"column": 27
|
||||
}
|
||||
},
|
||||
"body": [],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
3
packages/babylon/test/fixtures/experimental/decorators-2/private-property/options.json
vendored
Normal file
3
packages/babylon/test/fixtures/experimental/decorators-2/private-property/options.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"plugins": ["classProperties", "classPrivateProperties", "decorators2"]
|
||||
}
|
||||
186
packages/babylon/test/fixtures/experimental/decorators-2/private-property/output.json
vendored
Normal file
186
packages/babylon/test/fixtures/experimental/decorators-2/private-property/output.json
vendored
Normal file
@@ -0,0 +1,186 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start": 0,
|
||||
"end": 28,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start": 0,
|
||||
"end": 28,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"sourceType": "script",
|
||||
"body": [
|
||||
{
|
||||
"type": "ClassDeclaration",
|
||||
"start": 0,
|
||||
"end": 28,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start": 6,
|
||||
"end": 7,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 6
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 7
|
||||
},
|
||||
"identifierName": "A"
|
||||
},
|
||||
"name": "A"
|
||||
},
|
||||
"superClass": null,
|
||||
"body": {
|
||||
"type": "ClassBody",
|
||||
"start": 8,
|
||||
"end": 28,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 8
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"body": [
|
||||
{
|
||||
"type": "ClassPrivateProperty",
|
||||
"start": 12,
|
||||
"end": 26,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 2
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 16
|
||||
}
|
||||
},
|
||||
"decorators": [
|
||||
{
|
||||
"type": "Decorator",
|
||||
"start": 12,
|
||||
"end": 16,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 2
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 6
|
||||
}
|
||||
},
|
||||
"callee": {
|
||||
"type": "Identifier",
|
||||
"start": 13,
|
||||
"end": 16,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 3
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 6
|
||||
},
|
||||
"identifierName": "dec"
|
||||
},
|
||||
"name": "dec"
|
||||
}
|
||||
}
|
||||
],
|
||||
"static": false,
|
||||
"key": {
|
||||
"type": "PrivateName",
|
||||
"start": 17,
|
||||
"end": 22,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 7
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 12
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start": 18,
|
||||
"end": 22,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 8
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 12
|
||||
},
|
||||
"identifierName": "name"
|
||||
},
|
||||
"name": "name"
|
||||
}
|
||||
},
|
||||
"value": {
|
||||
"type": "NumericLiteral",
|
||||
"start": 25,
|
||||
"end": 26,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 15
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 16
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"rawValue": 0,
|
||||
"raw": "0"
|
||||
},
|
||||
"value": 0
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
@@ -1,2 +1,2 @@
|
||||
@(bar.baz)
|
||||
class Foo {}
|
||||
@foo().bar
|
||||
class Baz {}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Unexpected token (1:1)"
|
||||
"throws": "Leading decorators must be attached to a class declaration (1:6)"
|
||||
}
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
@foo().bar
|
||||
@foo()()
|
||||
class Baz {}
|
||||
|
||||
@@ -104,7 +104,7 @@
|
||||
"column": 6
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"callee": {
|
||||
"type": "Identifier",
|
||||
"start": 13,
|
||||
"end": 16,
|
||||
|
||||
@@ -104,7 +104,7 @@
|
||||
"column": 6
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"callee": {
|
||||
"type": "Identifier",
|
||||
"start": 15,
|
||||
"end": 18,
|
||||
|
||||
3
packages/babylon/test/fixtures/experimental/decorators-2/static-property/options.json
vendored
Normal file
3
packages/babylon/test/fixtures/experimental/decorators-2/static-property/options.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"plugins": ["classProperties", "decorators2"]
|
||||
}
|
||||
172
packages/babylon/test/fixtures/experimental/decorators-2/static-property/output.json
vendored
Normal file
172
packages/babylon/test/fixtures/experimental/decorators-2/static-property/output.json
vendored
Normal file
@@ -0,0 +1,172 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start": 0,
|
||||
"end": 34,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start": 0,
|
||||
"end": 34,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"sourceType": "script",
|
||||
"body": [
|
||||
{
|
||||
"type": "ClassDeclaration",
|
||||
"start": 0,
|
||||
"end": 34,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start": 6,
|
||||
"end": 7,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 6
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 7
|
||||
},
|
||||
"identifierName": "A"
|
||||
},
|
||||
"name": "A"
|
||||
},
|
||||
"superClass": null,
|
||||
"body": {
|
||||
"type": "ClassBody",
|
||||
"start": 8,
|
||||
"end": 34,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 8
|
||||
},
|
||||
"end": {
|
||||
"line": 3,
|
||||
"column": 1
|
||||
}
|
||||
},
|
||||
"body": [
|
||||
{
|
||||
"type": "ClassProperty",
|
||||
"start": 12,
|
||||
"end": 32,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 2
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 22
|
||||
}
|
||||
},
|
||||
"decorators": [
|
||||
{
|
||||
"type": "Decorator",
|
||||
"start": 12,
|
||||
"end": 16,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 2
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 6
|
||||
}
|
||||
},
|
||||
"callee": {
|
||||
"type": "Identifier",
|
||||
"start": 13,
|
||||
"end": 16,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 3
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 6
|
||||
},
|
||||
"identifierName": "dec"
|
||||
},
|
||||
"name": "dec"
|
||||
}
|
||||
}
|
||||
],
|
||||
"static": true,
|
||||
"key": {
|
||||
"type": "Identifier",
|
||||
"start": 24,
|
||||
"end": 28,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 14
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 18
|
||||
},
|
||||
"identifierName": "name"
|
||||
},
|
||||
"name": "name"
|
||||
},
|
||||
"computed": false,
|
||||
"value": {
|
||||
"type": "NumericLiteral",
|
||||
"start": 31,
|
||||
"end": 32,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 21
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 22
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"rawValue": 0,
|
||||
"raw": "0"
|
||||
},
|
||||
"value": 0
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
@@ -103,7 +103,7 @@
|
||||
"column": 14
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"callee": {
|
||||
"type": "Identifier",
|
||||
"start": 11,
|
||||
"end": 14,
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
"column": 11
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"callee": {
|
||||
"type": "CallExpression",
|
||||
"start": 1,
|
||||
"end": 11,
|
||||
|
||||
@@ -104,7 +104,7 @@
|
||||
"column": 16
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"callee": {
|
||||
"type": "Identifier",
|
||||
"start": 13,
|
||||
"end": 16,
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
"column": 4
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"callee": {
|
||||
"type": "Identifier",
|
||||
"start": 1,
|
||||
"end": 4,
|
||||
|
||||
@@ -104,7 +104,7 @@
|
||||
"column": 16
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"callee": {
|
||||
"type": "Identifier",
|
||||
"start": 13,
|
||||
"end": 16,
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
"column": 4
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"callee": {
|
||||
"type": "Identifier",
|
||||
"start": 1,
|
||||
"end": 4,
|
||||
|
||||
@@ -104,7 +104,7 @@
|
||||
"column": 16
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"callee": {
|
||||
"type": "Identifier",
|
||||
"start": 13,
|
||||
"end": 16,
|
||||
@@ -136,7 +136,7 @@
|
||||
"column": 21
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"callee": {
|
||||
"type": "Identifier",
|
||||
"start": 18,
|
||||
"end": 21,
|
||||
|
||||
@@ -144,7 +144,7 @@
|
||||
"column": 20
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"callee": {
|
||||
"type": "CallExpression",
|
||||
"start": 27,
|
||||
"end": 32,
|
||||
@@ -211,7 +211,7 @@
|
||||
"column": 40
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"callee": {
|
||||
"type": "CallExpression",
|
||||
"start": 37,
|
||||
"end": 52,
|
||||
@@ -332,7 +332,7 @@
|
||||
"column": 47
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"callee": {
|
||||
"type": "CallExpression",
|
||||
"start": 54,
|
||||
"end": 59,
|
||||
|
||||
@@ -104,7 +104,7 @@
|
||||
"column": 11
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"callee": {
|
||||
"type": "MemberExpression",
|
||||
"start": 15,
|
||||
"end": 23,
|
||||
|
||||
@@ -104,7 +104,7 @@
|
||||
"column": 12
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"callee": {
|
||||
"type": "MemberExpression",
|
||||
"start": 15,
|
||||
"end": 24,
|
||||
|
||||
@@ -73,7 +73,7 @@
|
||||
"column": 4
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"callee": {
|
||||
"type": "Identifier",
|
||||
"start": 1,
|
||||
"end": 4,
|
||||
|
||||
@@ -107,7 +107,7 @@
|
||||
"column": 35
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"callee": {
|
||||
"type": "CallExpression",
|
||||
"start": 30,
|
||||
"end": 35,
|
||||
@@ -174,7 +174,7 @@
|
||||
"column": 55
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"callee": {
|
||||
"type": "CallExpression",
|
||||
"start": 40,
|
||||
"end": 55,
|
||||
@@ -295,7 +295,7 @@
|
||||
"column": 62
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"callee": {
|
||||
"type": "CallExpression",
|
||||
"start": 57,
|
||||
"end": 62,
|
||||
|
||||
@@ -71,7 +71,7 @@
|
||||
"column": 4
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"callee": {
|
||||
"type": "Identifier",
|
||||
"start": 1,
|
||||
"end": 4,
|
||||
|
||||
@@ -71,7 +71,7 @@
|
||||
"column": 16
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"callee": {
|
||||
"type": "Identifier",
|
||||
"start": 1,
|
||||
"end": 16,
|
||||
|
||||
@@ -93,7 +93,7 @@
|
||||
"column": 20
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"callee": {
|
||||
"type": "CallExpression",
|
||||
"start": 15,
|
||||
"end": 20,
|
||||
@@ -160,7 +160,7 @@
|
||||
"column": 40
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"callee": {
|
||||
"type": "CallExpression",
|
||||
"start": 25,
|
||||
"end": 40,
|
||||
@@ -281,7 +281,7 @@
|
||||
"column": 47
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"callee": {
|
||||
"type": "CallExpression",
|
||||
"start": 42,
|
||||
"end": 47,
|
||||
|
||||
@@ -123,7 +123,7 @@
|
||||
"column": 29
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"callee": {
|
||||
"type": "CallExpression",
|
||||
"start": 24,
|
||||
"end": 29,
|
||||
@@ -190,7 +190,7 @@
|
||||
"column": 49
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"callee": {
|
||||
"type": "CallExpression",
|
||||
"start": 34,
|
||||
"end": 49,
|
||||
@@ -311,7 +311,7 @@
|
||||
"column": 56
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"callee": {
|
||||
"type": "CallExpression",
|
||||
"start": 51,
|
||||
"end": 56,
|
||||
|
||||
@@ -104,7 +104,7 @@
|
||||
"column": 16
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"callee": {
|
||||
"type": "Identifier",
|
||||
"start": 13,
|
||||
"end": 16,
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
"column": 25
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"callee": {
|
||||
"type": "CallExpression",
|
||||
"start": 1,
|
||||
"end": 25,
|
||||
@@ -133,7 +133,7 @@
|
||||
"column": 11
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"callee": {
|
||||
"type": "Identifier",
|
||||
"start": 8,
|
||||
"end": 11,
|
||||
@@ -212,7 +212,7 @@
|
||||
"column": 30
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"callee": {
|
||||
"type": "Identifier",
|
||||
"start": 27,
|
||||
"end": 30,
|
||||
|
||||
@@ -158,7 +158,7 @@
|
||||
"column": 15
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"callee": {
|
||||
"type": "CallExpression",
|
||||
"start": 22,
|
||||
"end": 27,
|
||||
@@ -225,7 +225,7 @@
|
||||
"column": 35
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"callee": {
|
||||
"type": "CallExpression",
|
||||
"start": 32,
|
||||
"end": 47,
|
||||
@@ -346,7 +346,7 @@
|
||||
"column": 42
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"callee": {
|
||||
"type": "CallExpression",
|
||||
"start": 49,
|
||||
"end": 54,
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
"column": 4
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"callee": {
|
||||
"type": "Identifier",
|
||||
"start": 1,
|
||||
"end": 4,
|
||||
@@ -122,7 +122,7 @@
|
||||
"column": 27
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"callee": {
|
||||
"type": "Identifier",
|
||||
"start": 24,
|
||||
"end": 27,
|
||||
|
||||
@@ -104,7 +104,7 @@
|
||||
"column": 16
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"callee": {
|
||||
"type": "Identifier",
|
||||
"start": 13,
|
||||
"end": 16,
|
||||
|
||||
@@ -104,7 +104,7 @@
|
||||
"column": 16
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"callee": {
|
||||
"type": "Identifier",
|
||||
"start": 13,
|
||||
"end": 16,
|
||||
|
||||
@@ -118,7 +118,7 @@
|
||||
"column": 16
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"callee": {
|
||||
"type": "Identifier",
|
||||
"start": 13,
|
||||
"end": 16,
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
"column": 24
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"callee": {
|
||||
"type": "CallExpression",
|
||||
"start": 1,
|
||||
"end": 24,
|
||||
|
||||
@@ -142,7 +142,7 @@
|
||||
"column": 20
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"callee": {
|
||||
"type": "Identifier",
|
||||
"start": 27,
|
||||
"end": 30,
|
||||
|
||||
Reference in New Issue
Block a user