From acf0e65090d29d4f5343775158a53a18fb8d24b6 Mon Sep 17 00:00:00 2001 From: James Henry Date: Sat, 26 Aug 2017 16:38:11 +0100 Subject: [PATCH] Apply location data fix to decorators plugin (#699) --- src/parser/statement.js | 8 ++------ .../decorators/class-decorator-call-expr/expected.json | 4 ++-- .../experimental/decorators/class-decorator/expected.json | 4 ++-- .../decorators/computed-member-expr-on-prop/expected.json | 4 ++-- .../decorators/computed-member-expression/expected.json | 4 ++-- .../decorators/export-decorators-on-class/expected.json | 6 +++--- .../export-default-with-nested-class/expected.json | 6 +++--- .../decorators/no-constructor-decorators/options.json | 2 +- test/fixtures/experimental/uncategorised/33/expected.json | 4 ++-- test/fixtures/experimental/uncategorised/34/expected.json | 4 ++-- test/fixtures/experimental/uncategorised/35/expected.json | 4 ++-- test/fixtures/experimental/uncategorised/36/expected.json | 4 ++-- test/fixtures/experimental/uncategorised/37/expected.json | 4 ++-- test/fixtures/experimental/uncategorised/38/expected.json | 4 ++-- test/fixtures/experimental/uncategorised/39/expected.json | 4 ++-- test/fixtures/experimental/uncategorised/40/expected.json | 8 ++++---- test/fixtures/experimental/uncategorised/47/expected.json | 4 ++-- test/fixtures/experimental/uncategorised/48/expected.json | 4 ++-- test/fixtures/experimental/uncategorised/62/expected.json | 4 ++-- 19 files changed, 41 insertions(+), 45 deletions(-) diff --git a/src/parser/statement.js b/src/parser/statement.js index 43cc1a00fe..d2bce9dce9 100644 --- a/src/parser/statement.js +++ b/src/parser/statement.js @@ -199,9 +199,7 @@ export default class StatementParser extends ExpressionParser { ]; if (decorators.length) { 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] = []; } } @@ -891,9 +889,7 @@ export default class StatementParser extends ExpressionParser { // steal the decorators if there are any if (decorators.length) { member.decorators = decorators; - if (this.hasPlugin("decorators2")) { - this.resetStartLocationFromNode(member, decorators[0]); - } + this.resetStartLocationFromNode(member, decorators[0]); decorators = []; } diff --git a/test/fixtures/experimental/decorators/class-decorator-call-expr/expected.json b/test/fixtures/experimental/decorators/class-decorator-call-expr/expected.json index 291ef173cc..26d8fca5be 100644 --- a/test/fixtures/experimental/decorators/class-decorator-call-expr/expected.json +++ b/test/fixtures/experimental/decorators/class-decorator-call-expr/expected.json @@ -30,11 +30,11 @@ "body": [ { "type": "ClassDeclaration", - "start": 12, + "start": 0, "end": 24, "loc": { "start": { - "line": 2, + "line": 1, "column": 0 }, "end": { diff --git a/test/fixtures/experimental/decorators/class-decorator/expected.json b/test/fixtures/experimental/decorators/class-decorator/expected.json index 8299bdd639..b0570136eb 100644 --- a/test/fixtures/experimental/decorators/class-decorator/expected.json +++ b/test/fixtures/experimental/decorators/class-decorator/expected.json @@ -30,11 +30,11 @@ "body": [ { "type": "ClassDeclaration", - "start": 5, + "start": 0, "end": 19, "loc": { "start": { - "line": 2, + "line": 1, "column": 0 }, "end": { diff --git a/test/fixtures/experimental/decorators/computed-member-expr-on-prop/expected.json b/test/fixtures/experimental/decorators/computed-member-expr-on-prop/expected.json index 16385a68fc..89b5631e82 100644 --- a/test/fixtures/experimental/decorators/computed-member-expr-on-prop/expected.json +++ b/test/fixtures/experimental/decorators/computed-member-expr-on-prop/expected.json @@ -77,12 +77,12 @@ "body": [ { "type": "ClassProperty", - "start": 24, + "start": 14, "end": 30, "loc": { "start": { "line": 2, - "column": 12 + "column": 2 }, "end": { "line": 2, diff --git a/test/fixtures/experimental/decorators/computed-member-expression/expected.json b/test/fixtures/experimental/decorators/computed-member-expression/expected.json index 71b00fd8a1..babebd47ef 100644 --- a/test/fixtures/experimental/decorators/computed-member-expression/expected.json +++ b/test/fixtures/experimental/decorators/computed-member-expression/expected.json @@ -77,11 +77,11 @@ "body": [ { "type": "ClassMethod", - "start": 27, + "start": 14, "end": 39, "loc": { "start": { - "line": 3, + "line": 2, "column": 2 }, "end": { diff --git a/test/fixtures/experimental/decorators/export-decorators-on-class/expected.json b/test/fixtures/experimental/decorators/export-decorators-on-class/expected.json index 6933de60e7..3fcaa85ea6 100644 --- a/test/fixtures/experimental/decorators/export-decorators-on-class/expected.json +++ b/test/fixtures/experimental/decorators/export-decorators-on-class/expected.json @@ -44,12 +44,12 @@ }, "declaration": { "type": "ClassDeclaration", - "start": 20, + "start": 0, "end": 28, "loc": { "start": { - "line": 2, - "column": 15 + "line": 1, + "column": 0 }, "end": { "line": 2, diff --git a/test/fixtures/experimental/decorators/export-default-with-nested-class/expected.json b/test/fixtures/experimental/decorators/export-default-with-nested-class/expected.json index 2c797decfc..51940d688d 100644 --- a/test/fixtures/experimental/decorators/export-default-with-nested-class/expected.json +++ b/test/fixtures/experimental/decorators/export-default-with-nested-class/expected.json @@ -44,12 +44,12 @@ }, "declaration": { "type": "ClassDeclaration", - "start": 32, + "start": 0, "end": 109, "loc": { "start": { - "line": 2, - "column": 15 + "line": 1, + "column": 0 }, "end": { "line": 7, diff --git a/test/fixtures/experimental/decorators/no-constructor-decorators/options.json b/test/fixtures/experimental/decorators/no-constructor-decorators/options.json index c0baef5996..a26ed7cacb 100644 --- a/test/fixtures/experimental/decorators/no-constructor-decorators/options.json +++ b/test/fixtures/experimental/decorators/no-constructor-decorators/options.json @@ -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)" } diff --git a/test/fixtures/experimental/uncategorised/33/expected.json b/test/fixtures/experimental/uncategorised/33/expected.json index 027ed9cf62..45e2e59ed7 100644 --- a/test/fixtures/experimental/uncategorised/33/expected.json +++ b/test/fixtures/experimental/uncategorised/33/expected.json @@ -30,12 +30,12 @@ "body": [ { "type": "ClassDeclaration", - "start": 5, + "start": 0, "end": 17, "loc": { "start": { "line": 1, - "column": 5 + "column": 0 }, "end": { "line": 1, diff --git a/test/fixtures/experimental/uncategorised/34/expected.json b/test/fixtures/experimental/uncategorised/34/expected.json index 923fccd749..56d24af64a 100644 --- a/test/fixtures/experimental/uncategorised/34/expected.json +++ b/test/fixtures/experimental/uncategorised/34/expected.json @@ -76,12 +76,12 @@ }, "init": { "type": "ClassExpression", - "start": 15, + "start": 10, "end": 27, "loc": { "start": { "line": 1, - "column": 15 + "column": 10 }, "end": { "line": 1, diff --git a/test/fixtures/experimental/uncategorised/35/expected.json b/test/fixtures/experimental/uncategorised/35/expected.json index 99edaedb74..0f924d4cca 100644 --- a/test/fixtures/experimental/uncategorised/35/expected.json +++ b/test/fixtures/experimental/uncategorised/35/expected.json @@ -77,12 +77,12 @@ "body": [ { "type": "ClassMethod", - "start": 17, + "start": 12, "end": 25, "loc": { "start": { "line": 1, - "column": 17 + "column": 12 }, "end": { "line": 1, diff --git a/test/fixtures/experimental/uncategorised/36/expected.json b/test/fixtures/experimental/uncategorised/36/expected.json index 74f8fb569a..54943162d1 100644 --- a/test/fixtures/experimental/uncategorised/36/expected.json +++ b/test/fixtures/experimental/uncategorised/36/expected.json @@ -77,12 +77,12 @@ "body": [ { "type": "ClassMethod", - "start": 17, + "start": 12, "end": 30, "loc": { "start": { "line": 1, - "column": 17 + "column": 12 }, "end": { "line": 1, diff --git a/test/fixtures/experimental/uncategorised/37/expected.json b/test/fixtures/experimental/uncategorised/37/expected.json index cc23bfd6b2..f8c9ea1a41 100644 --- a/test/fixtures/experimental/uncategorised/37/expected.json +++ b/test/fixtures/experimental/uncategorised/37/expected.json @@ -77,12 +77,12 @@ "body": [ { "type": "ClassMethod", - "start": 17, + "start": 12, "end": 29, "loc": { "start": { "line": 1, - "column": 17 + "column": 12 }, "end": { "line": 1, diff --git a/test/fixtures/experimental/uncategorised/38/expected.json b/test/fixtures/experimental/uncategorised/38/expected.json index 621411c8b8..2a5f2b5987 100644 --- a/test/fixtures/experimental/uncategorised/38/expected.json +++ b/test/fixtures/experimental/uncategorised/38/expected.json @@ -77,12 +77,12 @@ "body": [ { "type": "ClassMethod", - "start": 22, + "start": 12, "end": 30, "loc": { "start": { "line": 1, - "column": 22 + "column": 12 }, "end": { "line": 1, diff --git a/test/fixtures/experimental/uncategorised/39/expected.json b/test/fixtures/experimental/uncategorised/39/expected.json index 3988cde402..d0c0ff0180 100644 --- a/test/fixtures/experimental/uncategorised/39/expected.json +++ b/test/fixtures/experimental/uncategorised/39/expected.json @@ -30,12 +30,12 @@ "body": [ { "type": "ClassDeclaration", - "start": 31, + "start": 0, "end": 43, "loc": { "start": { "line": 1, - "column": 31 + "column": 0 }, "end": { "line": 1, diff --git a/test/fixtures/experimental/uncategorised/40/expected.json b/test/fixtures/experimental/uncategorised/40/expected.json index 1303f6d2b6..42ef576b83 100644 --- a/test/fixtures/experimental/uncategorised/40/expected.json +++ b/test/fixtures/experimental/uncategorised/40/expected.json @@ -30,12 +30,12 @@ "body": [ { "type": "ClassDeclaration", - "start": 5, + "start": 0, "end": 43, "loc": { "start": { "line": 1, - "column": 5 + "column": 0 }, "end": { "line": 1, @@ -95,12 +95,12 @@ }, "superClass": { "type": "ClassExpression", - "start": 28, + "start": 23, "end": 40, "loc": { "start": { "line": 1, - "column": 28 + "column": 23 }, "end": { "line": 1, diff --git a/test/fixtures/experimental/uncategorised/47/expected.json b/test/fixtures/experimental/uncategorised/47/expected.json index d638426ba2..63eed136a3 100644 --- a/test/fixtures/experimental/uncategorised/47/expected.json +++ b/test/fixtures/experimental/uncategorised/47/expected.json @@ -77,12 +77,12 @@ "body": [ { "type": "ClassProperty", - "start": 17, + "start": 12, "end": 29, "loc": { "start": { "line": 1, - "column": 17 + "column": 12 }, "end": { "line": 1, diff --git a/test/fixtures/experimental/uncategorised/48/expected.json b/test/fixtures/experimental/uncategorised/48/expected.json index 2dfeed15ab..126bbc97f9 100644 --- a/test/fixtures/experimental/uncategorised/48/expected.json +++ b/test/fixtures/experimental/uncategorised/48/expected.json @@ -77,12 +77,12 @@ "body": [ { "type": "ClassProperty", - "start": 17, + "start": 12, "end": 36, "loc": { "start": { "line": 1, - "column": 17 + "column": 12 }, "end": { "line": 1, diff --git a/test/fixtures/experimental/uncategorised/62/expected.json b/test/fixtures/experimental/uncategorised/62/expected.json index e8bfb35773..7ca7768fc9 100644 --- a/test/fixtures/experimental/uncategorised/62/expected.json +++ b/test/fixtures/experimental/uncategorised/62/expected.json @@ -30,11 +30,11 @@ "body": [ { "type": "ClassDeclaration", - "start": 25, + "start": 0, "end": 37, "loc": { "start": { - "line": 2, + "line": 1, "column": 0 }, "end": {