This repository has been archived by the owner on Aug 31, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 656
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(rome_js_parser): EcmaScript @decorators #4252
- Loading branch information
1 parent
8dc54b6
commit fdb0375
Showing
7 changed files
with
378 additions
and
361 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -258,14 +258,105 @@ JsModule { | |
], | ||
r_curly_token: [email protected] "}" [Newline("\n")] [], | ||
}, | ||
TsDeclareStatement { | ||
declare_token: [email protected] "declare" [Newline("\n")] [Whitespace(" ")], | ||
declaration: JsClassDeclaration { | ||
decorators: JsDecoratorList [], | ||
abstract_token: missing (optional), | ||
class_token: [email protected] "class" [] [Whitespace(" ")], | ||
id: JsIdentifierBinding { | ||
name_token: [email protected] "Baz" [] [Whitespace(" ")], | ||
}, | ||
type_parameters: missing (optional), | ||
extends_clause: missing (optional), | ||
implements_clause: missing (optional), | ||
l_curly_token: [email protected] "{" [] [], | ||
members: JsClassMemberList [ | ||
JsBogusMember { | ||
items: [ | ||
TsMethodSignatureModifierList [ | ||
JsDecorator { | ||
at_token: [email protected] "@" [Newline("\n"), Whitespace(" ")] [], | ||
expression: JsIdentifierExpression { | ||
name: JsReferenceIdentifier { | ||
value_token: [email protected] "dec" [] [Whitespace(" ")], | ||
}, | ||
}, | ||
}, | ||
], | ||
JsLiteralMemberName { | ||
value: [email protected] "method" [] [], | ||
}, | ||
JsParameters { | ||
l_paren_token: [email protected] "(" [] [], | ||
items: JsParameterList [], | ||
r_paren_token: [email protected] ")" [] [], | ||
}, | ||
[email protected] ";" [] [], | ||
], | ||
}, | ||
JsBogusMember { | ||
items: [ | ||
TsMethodSignatureModifierList [ | ||
JsDecorator { | ||
at_token: [email protected] "@" [Newline("\n"), Whitespace(" ")] [], | ||
expression: JsIdentifierExpression { | ||
name: JsReferenceIdentifier { | ||
value_token: [email protected] "dec" [] [Whitespace(" ")], | ||
}, | ||
}, | ||
}, | ||
], | ||
[email protected] "get" [] [Whitespace(" ")], | ||
JsLiteralMemberName { | ||
value: [email protected] "foo" [] [], | ||
}, | ||
[email protected] "(" [] [], | ||
[email protected] ")" [] [], | ||
[email protected] ";" [] [], | ||
], | ||
}, | ||
JsBogusMember { | ||
items: [ | ||
TsMethodSignatureModifierList [ | ||
JsDecorator { | ||
at_token: [email protected] "@" [Newline("\n"), Whitespace(" ")] [], | ||
expression: JsIdentifierExpression { | ||
name: JsReferenceIdentifier { | ||
value_token: [email protected] "dec" [] [Whitespace(" ")], | ||
}, | ||
}, | ||
}, | ||
], | ||
[email protected] "set" [] [Whitespace(" ")], | ||
JsLiteralMemberName { | ||
value: [email protected] "foo" [] [], | ||
}, | ||
[email protected] "(" [] [], | ||
JsFormalParameter { | ||
binding: JsIdentifierBinding { | ||
name_token: [email protected] "a" [] [], | ||
}, | ||
question_mark_token: missing (optional), | ||
type_annotation: missing (optional), | ||
initializer: missing (optional), | ||
}, | ||
[email protected] ")" [] [], | ||
[email protected] ";" [] [], | ||
], | ||
}, | ||
], | ||
r_curly_token: [email protected] "}" [Newline("\n")] [], | ||
}, | ||
}, | ||
], | ||
eof_token: EOF@236..237 "" [Newline("\n")] [], | ||
eof_token: EOF@312..313 "" [Newline("\n")] [], | ||
} | ||
|
||
0: JS_MODULE@0..237 | ||
0: JS_MODULE@0..313 | ||
0: (empty) | ||
1: [email protected] | ||
2: JS_MODULE_ITEM_LIST@0..236 | ||
2: JS_MODULE_ITEM_LIST@0..312 | ||
0: [email protected] | ||
0: [email protected] | ||
1: (empty) | ||
|
@@ -435,7 +526,67 @@ JsModule { | |
2: [email protected] | ||
3: [email protected] "}" [] [] | ||
9: [email protected] "}" [Newline("\n")] [] | ||
3: [email protected] "" [Newline("\n")] [] | ||
3: [email protected] | ||
0: [email protected] "declare" [Newline("\n")] [Whitespace(" ")] | ||
1: [email protected] | ||
0: [email protected] | ||
1: (empty) | ||
2: [email protected] "class" [] [Whitespace(" ")] | ||
3: [email protected] | ||
0: [email protected] "Baz" [] [Whitespace(" ")] | ||
4: (empty) | ||
5: (empty) | ||
6: (empty) | ||
7: [email protected] "{" [] [] | ||
8: [email protected] | ||
0: [email protected] | ||
0: [email protected] | ||
0: [email protected] | ||
0: [email protected] "@" [Newline("\n"), Whitespace(" ")] [] | ||
1: [email protected] | ||
0: [email protected] | ||
0: [email protected] "dec" [] [Whitespace(" ")] | ||
1: [email protected] | ||
0: [email protected] "method" [] [] | ||
2: [email protected] | ||
0: [email protected] "(" [] [] | ||
1: [email protected] | ||
2: [email protected] ")" [] [] | ||
3: [email protected] ";" [] [] | ||
1: [email protected] | ||
0: [email protected] | ||
0: [email protected] | ||
0: [email protected] "@" [Newline("\n"), Whitespace(" ")] [] | ||
1: [email protected] | ||
0: [email protected] | ||
0: [email protected] "dec" [] [Whitespace(" ")] | ||
1: [email protected] "get" [] [Whitespace(" ")] | ||
2: [email protected] | ||
0: [email protected] "foo" [] [] | ||
3: [email protected] "(" [] [] | ||
4: [email protected] ")" [] [] | ||
5: [email protected] ";" [] [] | ||
2: [email protected] | ||
0: [email protected] | ||
0: [email protected] | ||
0: [email protected] "@" [Newline("\n"), Whitespace(" ")] [] | ||
1: [email protected] | ||
0: [email protected] | ||
0: [email protected] "dec" [] [Whitespace(" ")] | ||
1: [email protected] "set" [] [Whitespace(" ")] | ||
2: [email protected] | ||
0: [email protected] "foo" [] [] | ||
3: [email protected] "(" [] [] | ||
4: [email protected] | ||
0: [email protected] | ||
0: [email protected] "a" [] [] | ||
1: (empty) | ||
2: (empty) | ||
3: (empty) | ||
5: [email protected] ")" [] [] | ||
6: [email protected] ";" [] [] | ||
9: [email protected] "}" [Newline("\n")] [] | ||
3: [email protected] "" [Newline("\n")] [] | ||
-- | ||
decorator_class_member.ts:2:4 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ | ||
|
||
|
@@ -491,6 +642,48 @@ decorator_class_member.ts:9:4 parse ━━━━━━━━━━━━━━ | |
|
||
i Decorators are only valid on class declarations, class expressions, and class methods. | ||
|
||
-- | ||
decorator_class_member.ts:15:3 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ | ||
|
||
× Decorators are not valid here. | ||
|
||
13 │ } | ||
14 │ declare class Baz { | ||
> 15 │ @dec method(); | ||
│ ^^^^ | ||
16 │ @dec get foo(); | ||
17 │ @dec set foo(a); | ||
|
||
i Decorators are only valid on class declarations, class expressions, and class methods. | ||
|
||
-- | ||
decorator_class_member.ts:16:3 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ | ||
|
||
× Decorators are not valid here. | ||
|
||
14 │ declare class Baz { | ||
15 │ @dec method(); | ||
> 16 │ @dec get foo(); | ||
│ ^^^^ | ||
17 │ @dec set foo(a); | ||
18 │ } | ||
|
||
i Decorators are only valid on class declarations, class expressions, and class methods. | ||
|
||
-- | ||
decorator_class_member.ts:17:3 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ | ||
|
||
× Decorators are not valid here. | ||
|
||
15 │ @dec method(); | ||
16 │ @dec get foo(); | ||
> 17 │ @dec set foo(a); | ||
│ ^^^^ | ||
18 │ } | ||
19 │ | ||
|
||
i Decorators are only valid on class declarations, class expressions, and class methods. | ||
|
||
-- | ||
class Foo { | ||
@dec constructor() {} | ||
|
@@ -505,3 +698,8 @@ class Bar extends Foo { | |
constructor(a: String) | ||
constructor(a?: String) {} | ||
} | ||
declare class Baz { | ||
@dec method(); | ||
@dec get foo(); | ||
@dec set foo(a); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.