Decorated classes/methods start where the decorator starts
This commit is contained in:
parent
04b40868f9
commit
e1972baff5
@ -152,6 +152,9 @@ export default class StatementParser extends ExpressionParser {
|
||||
takeDecorators(node: N.HasDecorators): void {
|
||||
if (this.state.decorators.length) {
|
||||
node.decorators = this.state.decorators;
|
||||
if (this.hasPlugin("decoratorsStage2")) {
|
||||
this.resetStartLocationFromNode(node, this.state.decorators[0]);
|
||||
}
|
||||
this.state.decorators = [];
|
||||
}
|
||||
}
|
||||
@ -709,6 +712,9 @@ export default class StatementParser extends ExpressionParser {
|
||||
// steal the decorators if there are any
|
||||
if (decorators.length) {
|
||||
member.decorators = decorators;
|
||||
if (this.hasPlugin("decoratorsStage2")) {
|
||||
this.resetStartLocationFromNode(member, decorators[0]);
|
||||
}
|
||||
decorators = [];
|
||||
}
|
||||
|
||||
|
||||
@ -30,11 +30,11 @@
|
||||
"body": [
|
||||
{
|
||||
"type": "ClassDeclaration",
|
||||
"start": 12,
|
||||
"start": 0,
|
||||
"end": 24,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
|
||||
@ -30,11 +30,11 @@
|
||||
"body": [
|
||||
{
|
||||
"type": "ClassDeclaration",
|
||||
"start": 5,
|
||||
"start": 0,
|
||||
"end": 19,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
|
||||
@ -76,12 +76,12 @@
|
||||
},
|
||||
"init": {
|
||||
"type": "ClassExpression",
|
||||
"start": 15,
|
||||
"start": 10,
|
||||
"end": 58,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 15
|
||||
"column": 10
|
||||
},
|
||||
"end": {
|
||||
"line": 6,
|
||||
@ -157,11 +157,11 @@
|
||||
"body": [
|
||||
{
|
||||
"type": "ClassMethod",
|
||||
"start": 36,
|
||||
"start": 29,
|
||||
"end": 56,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"line": 2,
|
||||
"column": 2
|
||||
},
|
||||
"end": {
|
||||
|
||||
@ -77,12 +77,12 @@
|
||||
"body": [
|
||||
{
|
||||
"type": "ClassMethod",
|
||||
"start": 17,
|
||||
"start": 12,
|
||||
"end": 23,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 7
|
||||
"column": 2
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
|
||||
@ -77,11 +77,11 @@
|
||||
"body": [
|
||||
{
|
||||
"type": "ClassMethod",
|
||||
"start": 29,
|
||||
"start": 12,
|
||||
"end": 34,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"line": 2,
|
||||
"column": 2
|
||||
},
|
||||
"end": {
|
||||
|
||||
@ -44,12 +44,12 @@
|
||||
},
|
||||
"declaration": {
|
||||
"type": "ClassExpression",
|
||||
"start": 21,
|
||||
"start": 16,
|
||||
"end": 34,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 5
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
{
|
||||
"plugins": ["classProperties", "decoratorsStage2"],
|
||||
"throws": "Stage 2 decorators may only be used with a class or a class method (2:7)"
|
||||
"throws": "Stage 2 decorators may only be used with a class or a class method (2:2)"
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
{
|
||||
"plugins": ["decoratorsStage2", "classProperties"],
|
||||
"throws": "Stage 2 decorators may only be used with a class or a class method (2:6)"
|
||||
"throws": "Stage 2 decorators may only be used with a class or a class method (2:2)"
|
||||
}
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "You can't attach decorators to a class constructor (3:2)"
|
||||
"throws": "You can't attach decorators to a class constructor (2:2)"
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
{
|
||||
"plugins": ["classProperties", "classPrivateProperties", "decoratorsStage2"],
|
||||
"throws": "Stage 2 decorators may only be used with a class or a class method (2:7)"
|
||||
"throws": "Stage 2 decorators may only be used with a class or a class method (2:2)"
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
{
|
||||
"plugins": ["classProperties", "decoratorsStage2"],
|
||||
"throws": "Stage 2 decorators may only be used with a class or a class method (2:7)"
|
||||
"throws": "Stage 2 decorators may only be used with a class or a class method (2:2)"
|
||||
}
|
||||
|
||||
@ -77,11 +77,11 @@
|
||||
"body": [
|
||||
{
|
||||
"type": "ClassMethod",
|
||||
"start": 19,
|
||||
"start": 12,
|
||||
"end": 31,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 3,
|
||||
"line": 2,
|
||||
"column": 2
|
||||
},
|
||||
"end": {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user