Skip to content
This repository has been archived by the owner on May 19, 2018. It is now read-only.

Commit

Permalink
Apply location data fix to decorators plugin (#699)
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesHenry authored and jridgewell committed Aug 26, 2017
1 parent 8f2f250 commit acf0e65
Show file tree
Hide file tree
Showing 19 changed files with 41 additions and 45 deletions.
8 changes: 2 additions & 6 deletions src/parser/statement.js
Original file line number Diff line number Diff line change
Expand Up @@ -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] = [];
}
}
Expand Down Expand Up @@ -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 = [];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@
"body": [
{
"type": "ClassDeclaration",
"start": 12,
"start": 0,
"end": 24,
"loc": {
"start": {
"line": 2,
"line": 1,
"column": 0
},
"end": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@
"body": [
{
"type": "ClassDeclaration",
"start": 5,
"start": 0,
"end": 19,
"loc": {
"start": {
"line": 2,
"line": 1,
"column": 0
},
"end": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@
"body": [
{
"type": "ClassProperty",
"start": 24,
"start": 14,
"end": 30,
"loc": {
"start": {
"line": 2,
"column": 12
"column": 2
},
"end": {
"line": 2,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@
"body": [
{
"type": "ClassMethod",
"start": 27,
"start": 14,
"end": 39,
"loc": {
"start": {
"line": 3,
"line": 2,
"column": 2
},
"end": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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)"
}
4 changes: 2 additions & 2 deletions test/fixtures/experimental/uncategorised/33/expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@
"body": [
{
"type": "ClassDeclaration",
"start": 5,
"start": 0,
"end": 17,
"loc": {
"start": {
"line": 1,
"column": 5
"column": 0
},
"end": {
"line": 1,
Expand Down
4 changes: 2 additions & 2 deletions test/fixtures/experimental/uncategorised/34/expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@
},
"init": {
"type": "ClassExpression",
"start": 15,
"start": 10,
"end": 27,
"loc": {
"start": {
"line": 1,
"column": 15
"column": 10
},
"end": {
"line": 1,
Expand Down
4 changes: 2 additions & 2 deletions test/fixtures/experimental/uncategorised/35/expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@
"body": [
{
"type": "ClassMethod",
"start": 17,
"start": 12,
"end": 25,
"loc": {
"start": {
"line": 1,
"column": 17
"column": 12
},
"end": {
"line": 1,
Expand Down
4 changes: 2 additions & 2 deletions test/fixtures/experimental/uncategorised/36/expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@
"body": [
{
"type": "ClassMethod",
"start": 17,
"start": 12,
"end": 30,
"loc": {
"start": {
"line": 1,
"column": 17
"column": 12
},
"end": {
"line": 1,
Expand Down
4 changes: 2 additions & 2 deletions test/fixtures/experimental/uncategorised/37/expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@
"body": [
{
"type": "ClassMethod",
"start": 17,
"start": 12,
"end": 29,
"loc": {
"start": {
"line": 1,
"column": 17
"column": 12
},
"end": {
"line": 1,
Expand Down
4 changes: 2 additions & 2 deletions test/fixtures/experimental/uncategorised/38/expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@
"body": [
{
"type": "ClassMethod",
"start": 22,
"start": 12,
"end": 30,
"loc": {
"start": {
"line": 1,
"column": 22
"column": 12
},
"end": {
"line": 1,
Expand Down
4 changes: 2 additions & 2 deletions test/fixtures/experimental/uncategorised/39/expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@
"body": [
{
"type": "ClassDeclaration",
"start": 31,
"start": 0,
"end": 43,
"loc": {
"start": {
"line": 1,
"column": 31
"column": 0
},
"end": {
"line": 1,
Expand Down
8 changes: 4 additions & 4 deletions test/fixtures/experimental/uncategorised/40/expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@
"body": [
{
"type": "ClassDeclaration",
"start": 5,
"start": 0,
"end": 43,
"loc": {
"start": {
"line": 1,
"column": 5
"column": 0
},
"end": {
"line": 1,
Expand Down Expand Up @@ -95,12 +95,12 @@
},
"superClass": {
"type": "ClassExpression",
"start": 28,
"start": 23,
"end": 40,
"loc": {
"start": {
"line": 1,
"column": 28
"column": 23
},
"end": {
"line": 1,
Expand Down
4 changes: 2 additions & 2 deletions test/fixtures/experimental/uncategorised/47/expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@
"body": [
{
"type": "ClassProperty",
"start": 17,
"start": 12,
"end": 29,
"loc": {
"start": {
"line": 1,
"column": 17
"column": 12
},
"end": {
"line": 1,
Expand Down
4 changes: 2 additions & 2 deletions test/fixtures/experimental/uncategorised/48/expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@
"body": [
{
"type": "ClassProperty",
"start": 17,
"start": 12,
"end": 36,
"loc": {
"start": {
"line": 1,
"column": 17
"column": 12
},
"end": {
"line": 1,
Expand Down
4 changes: 2 additions & 2 deletions test/fixtures/experimental/uncategorised/62/expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@
"body": [
{
"type": "ClassDeclaration",
"start": 25,
"start": 0,
"end": 37,
"loc": {
"start": {
"line": 2,
"line": 1,
"column": 0
},
"end": {
Expand Down

0 comments on commit acf0e65

Please sign in to comment.