Skip to content
This repository was archived by the owner on Jan 19, 2019. It is now read-only.

Commit 7364cb9

Browse files
JamesHenrynzakas
authored andcommitted
New: Add method decorators to AST (fixes #65) (#64)
1 parent b8ab833 commit 7364cb9

26 files changed

+1758
-1
lines changed

lib/ast-converter.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -993,7 +993,10 @@ module.exports = function(ast, extra) {
993993
value: method,
994994
computed: methodNameIsComputed,
995995
static: Boolean(node.flags & ts.NodeFlags.Static),
996-
kind: "method"
996+
kind: "method",
997+
decorators: (node.decorators) ? node.decorators.map(function(d) {
998+
return convertChild(d.expression);
999+
}) : []
9971000
});
9981001
}
9991002

tests/fixtures/attach-comments/export-default-anonymous-class.result.js

+1
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ module.exports = {
7272
},
7373
"kind": "method",
7474
"computed": false,
75+
"decorators": [],
7576
"range": [
7677
103,
7778
119

tests/fixtures/ecma-features/classes/class-accessor-properties.result.js

+2
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ module.exports = {
8585
18
8686
],
8787
"computed": false,
88+
"decorators": [],
8889
"key": {
8990
"type": "Identifier",
9091
"loc": {
@@ -162,6 +163,7 @@ module.exports = {
162163
29
163164
],
164165
"computed": false,
166+
"decorators": [],
165167
"key": {
166168
"type": "Identifier",
167169
"loc": {

tests/fixtures/ecma-features/classes/class-computed-static-method.result.js

+1
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ module.exports = {
8585
23
8686
],
8787
"computed": true,
88+
"decorators": [],
8889
"key": {
8990
"type": "Identifier",
9091
"loc": {

tests/fixtures/ecma-features/classes/class-method-named-prototype.result.js

+1
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ module.exports = {
8585
22
8686
],
8787
"computed": false,
88+
"decorators": [],
8889
"key": {
8990
"type": "Identifier",
9091
"loc": {

tests/fixtures/ecma-features/classes/class-method-named-static.result.js

+1
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ module.exports = {
8585
19
8686
],
8787
"computed": false,
88+
"decorators": [],
8889
"key": {
8990
"type": "Identifier",
9091
"loc": {

tests/fixtures/ecma-features/classes/class-one-method-super.result.js

+1
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ module.exports = {
8585
41
8686
],
8787
"computed": false,
88+
"decorators": [],
8889
"key": {
8990
"type": "Identifier",
9091
"loc": {

tests/fixtures/ecma-features/classes/class-one-method.result.js

+1
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ module.exports = {
8585
19
8686
],
8787
"computed": false,
88+
"decorators": [],
8889
"key": {
8990
"type": "Identifier",
9091
"loc": {

tests/fixtures/ecma-features/classes/class-static-method-named-prototype.result.js

+1
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ module.exports = {
8585
33
8686
],
8787
"computed": true,
88+
"decorators": [],
8889
"key": {
8990
"type": "Literal",
9091
"loc": {

tests/fixtures/ecma-features/classes/class-static-method-named-static.result.js

+1
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ module.exports = {
8585
26
8686
],
8787
"computed": false,
88+
"decorators": [],
8889
"key": {
8990
"type": "Identifier",
9091
"loc": {

tests/fixtures/ecma-features/classes/class-static-method.result.js

+1
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ module.exports = {
8585
21
8686
],
8787
"computed": false,
88+
"decorators": [],
8889
"key": {
8990
"type": "Identifier",
9091
"loc": {

tests/fixtures/ecma-features/classes/class-static-methods-and-accessor-properties.result.js

+3
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ module.exports = {
8585
21
8686
],
8787
"computed": false,
88+
"decorators": [],
8889
"key": {
8990
"type": "Identifier",
9091
"loc": {
@@ -162,6 +163,7 @@ module.exports = {
162163
38
163164
],
164165
"computed": false,
166+
"decorators": [],
165167
"key": {
166168
"type": "Identifier",
167169
"loc": {
@@ -239,6 +241,7 @@ module.exports = {
239241
56
240242
],
241243
"computed": false,
244+
"decorators": [],
242245
"key": {
243246
"type": "Identifier",
244247
"loc": {

tests/fixtures/ecma-features/classes/class-two-computed-static-methods.result.js

+2
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ module.exports = {
8585
22
8686
],
8787
"computed": true,
88+
"decorators": [],
8889
"key": {
8990
"type": "Identifier",
9091
"loc": {
@@ -162,6 +163,7 @@ module.exports = {
162163
37
163164
],
164165
"computed": true,
166+
"decorators": [],
165167
"key": {
166168
"type": "Identifier",
167169
"loc": {

tests/fixtures/ecma-features/classes/class-two-methods-computed-constructor.result.js

+2
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ module.exports = {
8585
26
8686
],
8787
"computed": false,
88+
"decorators": [],
8889
"key": {
8990
"type": "Literal",
9091
"loc": {
@@ -163,6 +164,7 @@ module.exports = {
163164
46
164165
],
165166
"computed": true,
167+
"decorators": [],
166168
"key": {
167169
"type": "Literal",
168170
"loc": {

tests/fixtures/ecma-features/classes/class-two-methods-semi.result.js

+2
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ module.exports = {
8585
14
8686
],
8787
"computed": false,
88+
"decorators": [],
8889
"key": {
8990
"type": "Identifier",
9091
"loc": {
@@ -162,6 +163,7 @@ module.exports = {
162163
20
163164
],
164165
"computed": false,
166+
"decorators": [],
165167
"key": {
166168
"type": "Identifier",
167169
"loc": {

tests/fixtures/ecma-features/classes/class-two-methods-three-semi.result.js

+2
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ module.exports = {
8585
15
8686
],
8787
"computed": false,
88+
"decorators": [],
8889
"key": {
8990
"type": "Identifier",
9091
"loc": {
@@ -162,6 +163,7 @@ module.exports = {
162163
21
163164
],
164165
"computed": false,
166+
"decorators": [],
165167
"key": {
166168
"type": "Identifier",
167169
"loc": {

tests/fixtures/ecma-features/classes/class-two-methods-two-semi.result.js

+2
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ module.exports = {
8585
14
8686
],
8787
"computed": false,
88+
"decorators": [],
8889
"key": {
8990
"type": "Identifier",
9091
"loc": {
@@ -162,6 +163,7 @@ module.exports = {
162163
20
163164
],
164165
"computed": false,
166+
"decorators": [],
165167
"key": {
166168
"type": "Identifier",
167169
"loc": {

tests/fixtures/ecma-features/classes/class-two-methods.result.js

+2
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ module.exports = {
8585
14
8686
],
8787
"computed": false,
88+
"decorators": [],
8889
"key": {
8990
"type": "Identifier",
9091
"loc": {
@@ -162,6 +163,7 @@ module.exports = {
162163
19
163164
],
164165
"computed": false,
166+
"decorators": [],
165167
"key": {
166168
"type": "Identifier",
167169
"loc": {

0 commit comments

Comments
 (0)