Apply location data fix to decorators plugin (#699)

This commit is contained in:
James Henry 2017-08-26 16:38:11 +01:00 committed by Justin Ridgewell
parent 8f2f250144
commit acf0e65090
19 changed files with 41 additions and 45 deletions

View File

@ -199,9 +199,7 @@ export default class StatementParser extends ExpressionParser {
]; ];
if (decorators.length) { if (decorators.length) {
node.decorators = decorators; node.decorators = decorators;
if (this.hasPlugin("decorators2")) { this.resetStartLocationFromNode(node, decorators[0]);
this.resetStartLocationFromNode(node, decorators[0]);
}
this.state.decoratorStack[this.state.decoratorStack.length - 1] = []; this.state.decoratorStack[this.state.decoratorStack.length - 1] = [];
} }
} }
@ -891,9 +889,7 @@ export default class StatementParser extends ExpressionParser {
// steal the decorators if there are any // steal the decorators if there are any
if (decorators.length) { if (decorators.length) {
member.decorators = decorators; member.decorators = decorators;
if (this.hasPlugin("decorators2")) { this.resetStartLocationFromNode(member, decorators[0]);
this.resetStartLocationFromNode(member, decorators[0]);
}
decorators = []; decorators = [];
} }

View File

@ -30,11 +30,11 @@
"body": [ "body": [
{ {
"type": "ClassDeclaration", "type": "ClassDeclaration",
"start": 12, "start": 0,
"end": 24, "end": 24,
"loc": { "loc": {
"start": { "start": {
"line": 2, "line": 1,
"column": 0 "column": 0
}, },
"end": { "end": {

View File

@ -30,11 +30,11 @@
"body": [ "body": [
{ {
"type": "ClassDeclaration", "type": "ClassDeclaration",
"start": 5, "start": 0,
"end": 19, "end": 19,
"loc": { "loc": {
"start": { "start": {
"line": 2, "line": 1,
"column": 0 "column": 0
}, },
"end": { "end": {

View File

@ -77,12 +77,12 @@
"body": [ "body": [
{ {
"type": "ClassProperty", "type": "ClassProperty",
"start": 24, "start": 14,
"end": 30, "end": 30,
"loc": { "loc": {
"start": { "start": {
"line": 2, "line": 2,
"column": 12 "column": 2
}, },
"end": { "end": {
"line": 2, "line": 2,

View File

@ -77,11 +77,11 @@
"body": [ "body": [
{ {
"type": "ClassMethod", "type": "ClassMethod",
"start": 27, "start": 14,
"end": 39, "end": 39,
"loc": { "loc": {
"start": { "start": {
"line": 3, "line": 2,
"column": 2 "column": 2
}, },
"end": { "end": {

View File

@ -44,12 +44,12 @@
}, },
"declaration": { "declaration": {
"type": "ClassDeclaration", "type": "ClassDeclaration",
"start": 20, "start": 0,
"end": 28, "end": 28,
"loc": { "loc": {
"start": { "start": {
"line": 2, "line": 1,
"column": 15 "column": 0
}, },
"end": { "end": {
"line": 2, "line": 2,

View File

@ -44,12 +44,12 @@
}, },
"declaration": { "declaration": {
"type": "ClassDeclaration", "type": "ClassDeclaration",
"start": 32, "start": 0,
"end": 109, "end": 109,
"loc": { "loc": {
"start": { "start": {
"line": 2, "line": 1,
"column": 15 "column": 0
}, },
"end": { "end": {
"line": 7, "line": 7,

View File

@ -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)"
} }

View File

@ -30,12 +30,12 @@
"body": [ "body": [
{ {
"type": "ClassDeclaration", "type": "ClassDeclaration",
"start": 5, "start": 0,
"end": 17, "end": 17,
"loc": { "loc": {
"start": { "start": {
"line": 1, "line": 1,
"column": 5 "column": 0
}, },
"end": { "end": {
"line": 1, "line": 1,

View File

@ -76,12 +76,12 @@
}, },
"init": { "init": {
"type": "ClassExpression", "type": "ClassExpression",
"start": 15, "start": 10,
"end": 27, "end": 27,
"loc": { "loc": {
"start": { "start": {
"line": 1, "line": 1,
"column": 15 "column": 10
}, },
"end": { "end": {
"line": 1, "line": 1,

View File

@ -77,12 +77,12 @@
"body": [ "body": [
{ {
"type": "ClassMethod", "type": "ClassMethod",
"start": 17, "start": 12,
"end": 25, "end": 25,
"loc": { "loc": {
"start": { "start": {
"line": 1, "line": 1,
"column": 17 "column": 12
}, },
"end": { "end": {
"line": 1, "line": 1,

View File

@ -77,12 +77,12 @@
"body": [ "body": [
{ {
"type": "ClassMethod", "type": "ClassMethod",
"start": 17, "start": 12,
"end": 30, "end": 30,
"loc": { "loc": {
"start": { "start": {
"line": 1, "line": 1,
"column": 17 "column": 12
}, },
"end": { "end": {
"line": 1, "line": 1,

View File

@ -77,12 +77,12 @@
"body": [ "body": [
{ {
"type": "ClassMethod", "type": "ClassMethod",
"start": 17, "start": 12,
"end": 29, "end": 29,
"loc": { "loc": {
"start": { "start": {
"line": 1, "line": 1,
"column": 17 "column": 12
}, },
"end": { "end": {
"line": 1, "line": 1,

View File

@ -77,12 +77,12 @@
"body": [ "body": [
{ {
"type": "ClassMethod", "type": "ClassMethod",
"start": 22, "start": 12,
"end": 30, "end": 30,
"loc": { "loc": {
"start": { "start": {
"line": 1, "line": 1,
"column": 22 "column": 12
}, },
"end": { "end": {
"line": 1, "line": 1,

View File

@ -30,12 +30,12 @@
"body": [ "body": [
{ {
"type": "ClassDeclaration", "type": "ClassDeclaration",
"start": 31, "start": 0,
"end": 43, "end": 43,
"loc": { "loc": {
"start": { "start": {
"line": 1, "line": 1,
"column": 31 "column": 0
}, },
"end": { "end": {
"line": 1, "line": 1,

View File

@ -30,12 +30,12 @@
"body": [ "body": [
{ {
"type": "ClassDeclaration", "type": "ClassDeclaration",
"start": 5, "start": 0,
"end": 43, "end": 43,
"loc": { "loc": {
"start": { "start": {
"line": 1, "line": 1,
"column": 5 "column": 0
}, },
"end": { "end": {
"line": 1, "line": 1,
@ -95,12 +95,12 @@
}, },
"superClass": { "superClass": {
"type": "ClassExpression", "type": "ClassExpression",
"start": 28, "start": 23,
"end": 40, "end": 40,
"loc": { "loc": {
"start": { "start": {
"line": 1, "line": 1,
"column": 28 "column": 23
}, },
"end": { "end": {
"line": 1, "line": 1,

View File

@ -77,12 +77,12 @@
"body": [ "body": [
{ {
"type": "ClassProperty", "type": "ClassProperty",
"start": 17, "start": 12,
"end": 29, "end": 29,
"loc": { "loc": {
"start": { "start": {
"line": 1, "line": 1,
"column": 17 "column": 12
}, },
"end": { "end": {
"line": 1, "line": 1,

View File

@ -77,12 +77,12 @@
"body": [ "body": [
{ {
"type": "ClassProperty", "type": "ClassProperty",
"start": 17, "start": 12,
"end": 36, "end": 36,
"loc": { "loc": {
"start": { "start": {
"line": 1, "line": 1,
"column": 17 "column": 12
}, },
"end": { "end": {
"line": 1, "line": 1,

View File

@ -30,11 +30,11 @@
"body": [ "body": [
{ {
"type": "ClassDeclaration", "type": "ClassDeclaration",
"start": 25, "start": 0,
"end": 37, "end": 37,
"loc": { "loc": {
"start": { "start": {
"line": 2, "line": 1,
"column": 0 "column": 0
}, },
"end": { "end": {