diff --git a/crates/rome_js_factory/src/generated/node_factory.rs b/crates/rome_js_factory/src/generated/node_factory.rs index 503cf1aa5ae..5f96a771c05 100644 --- a/crates/rome_js_factory/src/generated/node_factory.rs +++ b/crates/rome_js_factory/src/generated/node_factory.rs @@ -398,6 +398,7 @@ impl JsCatchDeclarationBuilder { } } pub fn js_class_declaration( + decorators: JsDecoratorList, class_token: SyntaxToken, id: AnyJsBinding, l_curly_token: SyntaxToken, @@ -405,6 +406,7 @@ pub fn js_class_declaration( r_curly_token: SyntaxToken, ) -> JsClassDeclarationBuilder { JsClassDeclarationBuilder { + decorators, class_token, id, l_curly_token, @@ -417,6 +419,7 @@ pub fn js_class_declaration( } } pub struct JsClassDeclarationBuilder { + decorators: JsDecoratorList, class_token: SyntaxToken, id: AnyJsBinding, l_curly_token: SyntaxToken, @@ -448,6 +451,7 @@ impl JsClassDeclarationBuilder { JsClassDeclaration::unwrap_cast(SyntaxNode::new_detached( JsSyntaxKind::JS_CLASS_DECLARATION, [ + Some(SyntaxElement::Node(self.decorators.into_syntax())), self.abstract_token.map(|token| SyntaxElement::Token(token)), Some(SyntaxElement::Token(self.class_token)), Some(SyntaxElement::Node(self.id.into_syntax())), @@ -465,12 +469,14 @@ impl JsClassDeclarationBuilder { } } pub fn js_class_export_default_declaration( + decorators: JsDecoratorList, class_token: SyntaxToken, l_curly_token: SyntaxToken, members: JsClassMemberList, r_curly_token: SyntaxToken, ) -> JsClassExportDefaultDeclarationBuilder { JsClassExportDefaultDeclarationBuilder { + decorators, class_token, l_curly_token, members, @@ -483,6 +489,7 @@ pub fn js_class_export_default_declaration( } } pub struct JsClassExportDefaultDeclarationBuilder { + decorators: JsDecoratorList, class_token: SyntaxToken, l_curly_token: SyntaxToken, members: JsClassMemberList, @@ -518,6 +525,7 @@ impl JsClassExportDefaultDeclarationBuilder { JsClassExportDefaultDeclaration::unwrap_cast(SyntaxNode::new_detached( JsSyntaxKind::JS_CLASS_EXPORT_DEFAULT_DECLARATION, [ + Some(SyntaxElement::Node(self.decorators.into_syntax())), self.abstract_token.map(|token| SyntaxElement::Token(token)), Some(SyntaxElement::Token(self.class_token)), self.id @@ -536,12 +544,14 @@ impl JsClassExportDefaultDeclarationBuilder { } } pub fn js_class_expression( + decorators: JsDecoratorList, class_token: SyntaxToken, l_curly_token: SyntaxToken, members: JsClassMemberList, r_curly_token: SyntaxToken, ) -> JsClassExpressionBuilder { JsClassExpressionBuilder { + decorators, class_token, l_curly_token, members, @@ -553,6 +563,7 @@ pub fn js_class_expression( } } pub struct JsClassExpressionBuilder { + decorators: JsDecoratorList, class_token: SyntaxToken, l_curly_token: SyntaxToken, members: JsClassMemberList, @@ -583,6 +594,7 @@ impl JsClassExpressionBuilder { JsClassExpression::unwrap_cast(SyntaxNode::new_detached( JsSyntaxKind::JS_CLASS_EXPRESSION, [ + Some(SyntaxElement::Node(self.decorators.into_syntax())), Some(SyntaxElement::Token(self.class_token)), self.id .map(|token| SyntaxElement::Node(token.into_syntax())), @@ -776,6 +788,15 @@ impl JsDebuggerStatementBuilder { )) } } +pub fn js_decorator(at_token: SyntaxToken, expression: AnyJsDecorator) -> JsDecorator { + JsDecorator::unwrap_cast(SyntaxNode::new_detached( + JsSyntaxKind::JS_DECORATOR, + [ + Some(SyntaxElement::Token(at_token)), + Some(SyntaxElement::Node(expression.into_syntax())), + ], + )) +} pub fn js_default_clause( default_token: SyntaxToken, colon_token: SyntaxToken, @@ -6515,6 +6536,18 @@ where }), )) } +pub fn js_decorator_list(items: I) -> JsDecoratorList +where + I: IntoIterator, + I::IntoIter: ExactSizeIterator, +{ + JsDecoratorList::unwrap_cast(SyntaxNode::new_detached( + JsSyntaxKind::JS_DECORATOR_LIST, + items + .into_iter() + .map(|item| Some(item.into_syntax().into())), + )) +} pub fn js_directive_list(items: I) -> JsDirectiveList where I: IntoIterator, diff --git a/crates/rome_js_factory/src/generated/syntax_factory.rs b/crates/rome_js_factory/src/generated/syntax_factory.rs index deeb9b953de..977e4afc06e 100644 --- a/crates/rome_js_factory/src/generated/syntax_factory.rs +++ b/crates/rome_js_factory/src/generated/syntax_factory.rs @@ -748,8 +748,15 @@ impl SyntaxFactory for JsSyntaxFactory { } JS_CLASS_DECLARATION => { let mut elements = (&children).into_iter(); - let mut slots: RawNodeSlots<9usize> = RawNodeSlots::default(); + let mut slots: RawNodeSlots<10usize> = RawNodeSlots::default(); let mut current_element = elements.next(); + if let Some(element) = ¤t_element { + if JsDecoratorList::can_cast(element.kind()) { + slots.mark_present(); + current_element = elements.next(); + } + } + slots.next_slot(); if let Some(element) = ¤t_element { if element.kind() == T![abstract] { slots.mark_present(); @@ -823,8 +830,15 @@ impl SyntaxFactory for JsSyntaxFactory { } JS_CLASS_EXPORT_DEFAULT_DECLARATION => { let mut elements = (&children).into_iter(); - let mut slots: RawNodeSlots<9usize> = RawNodeSlots::default(); + let mut slots: RawNodeSlots<10usize> = RawNodeSlots::default(); let mut current_element = elements.next(); + if let Some(element) = ¤t_element { + if JsDecoratorList::can_cast(element.kind()) { + slots.mark_present(); + current_element = elements.next(); + } + } + slots.next_slot(); if let Some(element) = ¤t_element { if element.kind() == T![abstract] { slots.mark_present(); @@ -898,8 +912,15 @@ impl SyntaxFactory for JsSyntaxFactory { } JS_CLASS_EXPRESSION => { let mut elements = (&children).into_iter(); - let mut slots: RawNodeSlots<8usize> = RawNodeSlots::default(); + let mut slots: RawNodeSlots<9usize> = RawNodeSlots::default(); let mut current_element = elements.next(); + if let Some(element) = ¤t_element { + if JsDecoratorList::can_cast(element.kind()) { + slots.mark_present(); + current_element = elements.next(); + } + } + slots.next_slot(); if let Some(element) = ¤t_element { if element.kind() == T![class] { slots.mark_present(); @@ -1263,6 +1284,32 @@ impl SyntaxFactory for JsSyntaxFactory { } slots.into_node(JS_DEBUGGER_STATEMENT, children) } + JS_DECORATOR => { + let mut elements = (&children).into_iter(); + let mut slots: RawNodeSlots<2usize> = RawNodeSlots::default(); + let mut current_element = elements.next(); + if let Some(element) = ¤t_element { + if element.kind() == T ! [@] { + slots.mark_present(); + current_element = elements.next(); + } + } + slots.next_slot(); + if let Some(element) = ¤t_element { + if AnyJsDecorator::can_cast(element.kind()) { + slots.mark_present(); + current_element = elements.next(); + } + } + slots.next_slot(); + if current_element.is_some() { + return RawSyntaxNode::new( + JS_DECORATOR.to_bogus(), + children.into_iter().map(Some), + ); + } + slots.into_node(JS_DECORATOR, children) + } JS_DEFAULT_CLAUSE => { let mut elements = (&children).into_iter(); let mut slots: RawNodeSlots<3usize> = RawNodeSlots::default(); @@ -9782,6 +9829,7 @@ impl SyntaxFactory for JsSyntaxFactory { T ! [,], true, ), + JS_DECORATOR_LIST => Self::make_node_list_syntax(kind, children, JsDecorator::can_cast), JS_DIRECTIVE_LIST => Self::make_node_list_syntax(kind, children, JsDirective::can_cast), JS_EXPORT_NAMED_FROM_SPECIFIER_LIST => Self::make_separated_list_syntax( kind, diff --git a/crates/rome_js_formatter/src/generated.rs b/crates/rome_js_formatter/src/generated.rs index 3eb023aca75..0b22ca30504 100644 --- a/crates/rome_js_formatter/src/generated.rs +++ b/crates/rome_js_formatter/src/generated.rs @@ -6807,6 +6807,40 @@ impl IntoFormat for rome_js_syntax::TsThisParameter { ) } } +impl FormatRule + for crate::js::auxiliary::decorator::FormatJsDecorator +{ + type Context = JsFormatContext; + #[inline(always)] + fn fmt(&self, node: &rome_js_syntax::JsDecorator, f: &mut JsFormatter) -> FormatResult<()> { + FormatNodeRule::::fmt(self, node, f) + } +} +impl AsFormat for rome_js_syntax::JsDecorator { + type Format<'a> = FormatRefWithRule< + 'a, + rome_js_syntax::JsDecorator, + crate::js::auxiliary::decorator::FormatJsDecorator, + >; + fn format(&self) -> Self::Format<'_> { + FormatRefWithRule::new( + self, + crate::js::auxiliary::decorator::FormatJsDecorator::default(), + ) + } +} +impl IntoFormat for rome_js_syntax::JsDecorator { + type Format = FormatOwnedWithRule< + rome_js_syntax::JsDecorator, + crate::js::auxiliary::decorator::FormatJsDecorator, + >; + fn into_format(self) -> Self::Format { + FormatOwnedWithRule::new( + self, + crate::js::auxiliary::decorator::FormatJsDecorator::default(), + ) + } +} impl FormatRule for crate::ts::types::any_type::FormatTsAnyType { type Context = JsFormatContext; #[inline(always)] @@ -9843,6 +9877,31 @@ impl IntoFormat for rome_js_syntax::JsConstructorParameterList ) } } +impl AsFormat for rome_js_syntax::JsDecoratorList { + type Format<'a> = FormatRefWithRule< + 'a, + rome_js_syntax::JsDecoratorList, + crate::js::lists::decorator_list::FormatJsDecoratorList, + >; + fn format(&self) -> Self::Format<'_> { + FormatRefWithRule::new( + self, + crate::js::lists::decorator_list::FormatJsDecoratorList::default(), + ) + } +} +impl IntoFormat for rome_js_syntax::JsDecoratorList { + type Format = FormatOwnedWithRule< + rome_js_syntax::JsDecoratorList, + crate::js::lists::decorator_list::FormatJsDecoratorList, + >; + fn into_format(self) -> Self::Format { + FormatOwnedWithRule::new( + self, + crate::js::lists::decorator_list::FormatJsDecoratorList::default(), + ) + } +} impl AsFormat for rome_js_syntax::JsDirectiveList { type Format<'a> = FormatRefWithRule< 'a, @@ -12100,6 +12159,31 @@ impl IntoFormat for rome_js_syntax::AnyJsCallArgument { ) } } +impl AsFormat for rome_js_syntax::AnyJsDecorator { + type Format<'a> = FormatRefWithRule< + 'a, + rome_js_syntax::AnyJsDecorator, + crate::js::any::decorator::FormatAnyJsDecorator, + >; + fn format(&self) -> Self::Format<'_> { + FormatRefWithRule::new( + self, + crate::js::any::decorator::FormatAnyJsDecorator::default(), + ) + } +} +impl IntoFormat for rome_js_syntax::AnyJsDecorator { + type Format = FormatOwnedWithRule< + rome_js_syntax::AnyJsDecorator, + crate::js::any::decorator::FormatAnyJsDecorator, + >; + fn into_format(self) -> Self::Format { + FormatOwnedWithRule::new( + self, + crate::js::any::decorator::FormatAnyJsDecorator::default(), + ) + } +} impl AsFormat for rome_js_syntax::AnyTsName { type Format<'a> = FormatRefWithRule<'a, rome_js_syntax::AnyTsName, crate::ts::any::name::FormatAnyTsName>; diff --git a/crates/rome_js_formatter/src/js/any/decorator.rs b/crates/rome_js_formatter/src/js/any/decorator.rs new file mode 100644 index 00000000000..ee88158babb --- /dev/null +++ b/crates/rome_js_formatter/src/js/any/decorator.rs @@ -0,0 +1,18 @@ +//! This is a generated file. Don't modify it by hand! Run 'cargo codegen formatter' to re-generate the file. + +use crate::prelude::*; +use rome_js_syntax::AnyJsDecorator; +#[derive(Debug, Clone, Default)] +pub(crate) struct FormatAnyJsDecorator; +impl FormatRule for FormatAnyJsDecorator { + type Context = JsFormatContext; + fn fmt(&self, node: &AnyJsDecorator, f: &mut JsFormatter) -> FormatResult<()> { + match node { + AnyJsDecorator::JsParenthesizedExpression(node) => node.format().fmt(f), + AnyJsDecorator::JsCallExpression(node) => node.format().fmt(f), + AnyJsDecorator::JsStaticMemberExpression(node) => node.format().fmt(f), + AnyJsDecorator::JsIdentifierExpression(node) => node.format().fmt(f), + AnyJsDecorator::JsBogusExpression(node) => node.format().fmt(f), + } + } +} diff --git a/crates/rome_js_formatter/src/js/any/mod.rs b/crates/rome_js_formatter/src/js/any/mod.rs index d47b1e8d38d..d70d9abde92 100644 --- a/crates/rome_js_formatter/src/js/any/mod.rs +++ b/crates/rome_js_formatter/src/js/any/mod.rs @@ -15,6 +15,7 @@ pub(crate) mod class_member_name; pub(crate) mod constructor_parameter; pub(crate) mod declaration; pub(crate) mod declaration_clause; +pub(crate) mod decorator; pub(crate) mod export_clause; pub(crate) mod export_default_declaration; pub(crate) mod export_named_specifier; diff --git a/crates/rome_js_formatter/src/js/auxiliary/decorator.rs b/crates/rome_js_formatter/src/js/auxiliary/decorator.rs new file mode 100644 index 00000000000..7c4fa4a11e0 --- /dev/null +++ b/crates/rome_js_formatter/src/js/auxiliary/decorator.rs @@ -0,0 +1,10 @@ +use crate::prelude::*; +use rome_js_syntax::JsDecorator; +use rome_rowan::AstNode; +#[derive(Debug, Clone, Default)] +pub(crate) struct FormatJsDecorator; +impl FormatNodeRule for FormatJsDecorator { + fn fmt_fields(&self, node: &JsDecorator, f: &mut JsFormatter) -> FormatResult<()> { + format_verbatim_node(node.syntax()).fmt(f) + } +} diff --git a/crates/rome_js_formatter/src/js/auxiliary/mod.rs b/crates/rome_js_formatter/src/js/auxiliary/mod.rs index 369d76b8ed8..b3a556de680 100644 --- a/crates/rome_js_formatter/src/js/auxiliary/mod.rs +++ b/crates/rome_js_formatter/src/js/auxiliary/mod.rs @@ -4,6 +4,7 @@ pub(crate) mod accessor_modifier; pub(crate) mod array_hole; pub(crate) mod case_clause; pub(crate) mod catch_clause; +pub(crate) mod decorator; pub(crate) mod default_clause; pub(crate) mod directive; pub(crate) mod else_clause; diff --git a/crates/rome_js_formatter/src/js/lists/decorator_list.rs b/crates/rome_js_formatter/src/js/lists/decorator_list.rs new file mode 100644 index 00000000000..38ceb472200 --- /dev/null +++ b/crates/rome_js_formatter/src/js/lists/decorator_list.rs @@ -0,0 +1,20 @@ +use crate::prelude::*; +use rome_formatter::write; +use rome_js_syntax::JsDecoratorList; + +#[derive(Debug, Clone, Default)] +pub(crate) struct FormatJsDecoratorList; +impl FormatRule for FormatJsDecoratorList { + type Context = JsFormatContext; + fn fmt(&self, node: &JsDecoratorList, f: &mut JsFormatter) -> FormatResult<()> { + if node.is_empty() { + return Ok(()); + } + + f.join_with(&soft_line_break_or_space()) + .entries(node.iter().formatted()) + .finish()?; + + write!(f, [soft_line_break_or_space()]) + } +} diff --git a/crates/rome_js_formatter/src/js/lists/mod.rs b/crates/rome_js_formatter/src/js/lists/mod.rs index b289630aaf3..a89124f9e2c 100644 --- a/crates/rome_js_formatter/src/js/lists/mod.rs +++ b/crates/rome_js_formatter/src/js/lists/mod.rs @@ -7,6 +7,7 @@ pub(crate) mod call_argument_list; pub(crate) mod class_member_list; pub(crate) mod constructor_modifier_list; pub(crate) mod constructor_parameter_list; +pub(crate) mod decorator_list; pub(crate) mod directive_list; pub(crate) mod export_named_from_specifier_list; pub(crate) mod export_named_specifier_list; diff --git a/crates/rome_js_formatter/src/utils/format_class.rs b/crates/rome_js_formatter/src/utils/format_class.rs index 03b6e92d5a6..5d2deb3937e 100644 --- a/crates/rome_js_formatter/src/utils/format_class.rs +++ b/crates/rome_js_formatter/src/utils/format_class.rs @@ -42,6 +42,7 @@ impl<'a> From<&'a AnyJsClass> for FormatClass<'a> { impl Format for FormatClass<'_> { fn fmt(&self, f: &mut Formatter) -> FormatResult<()> { + let decorators = self.class.decorators(); let abstract_token = self.class.abstract_token(); let id = self.class.id()?; let extends = self.class.extends_clause(); @@ -52,6 +53,8 @@ impl Format for FormatClass<'_> { let group_mode = self.should_group(f.comments())?; + write!(f, [decorators.format()])?; + if let Some(abstract_token) = abstract_token { write!(f, [abstract_token.format(), space()])?; } diff --git a/crates/rome_js_formatter/tests/quick_test.rs b/crates/rome_js_formatter/tests/quick_test.rs index 6627d04fb62..bc02b1090b4 100644 --- a/crates/rome_js_formatter/tests/quick_test.rs +++ b/crates/rome_js_formatter/tests/quick_test.rs @@ -13,7 +13,7 @@ mod language { // use this test check if your snippet prints as you wish, without using a snapshot fn quick_test() { let src = r#" -f delete; +const foo = @deco class {} "#; let syntax = SourceType::tsx(); let tree = parse(src, syntax); diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/decorators-export/after_export.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/decorators-export/after_export.js.snap index 88aee256886..dd3cc9111cf 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/decorators-export/after_export.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/decorators-export/after_export.js.snap @@ -1,6 +1,5 @@ --- source: crates/rome_formatter_test/src/snapshot_builder.rs -assertion_line: 212 info: js/decorators-export/after_export.js --- @@ -20,74 +19,26 @@ export default @decorator class {} --- Prettier +++ Rome @@ -1,7 +1,5 @@ - export +-export -@decorator --class Foo {} -+@decorator class Foo {} - - export default ++export @decorator + class Foo {} + +-export default -@decorator -class {} -+@decorator class {} ++export default (@decorator ++class {}); ``` # Output ```js -export -@decorator class Foo {} - -export default -@decorator class {} -``` - -# Errors -``` -after_export.js:1:8 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × expected a class, a function, or a variable declaration but instead found '@' - - > 1 │ export @decorator class Foo {} - │ ^ - 2 │ - 3 │ export default @decorator class {} - - i Expected a class, a function, or a variable declaration here - - > 1 │ export @decorator class Foo {} - │ ^ - 2 │ - 3 │ export default @decorator class {} - -after_export.js:3:16 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × expected an expression but instead found '@' - - 1 │ export @decorator class Foo {} - 2 │ - > 3 │ export default @decorator class {} - │ ^ - 4 │ - - i Expected an expression here - - 1 │ export @decorator class Foo {} - 2 │ - > 3 │ export default @decorator class {} - │ ^ - 4 │ - -after_export.js:3:27 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × class declarations must have a name - - 1 │ export @decorator class Foo {} - 2 │ - > 3 │ export default @decorator class {} - │ ^^^^^^ - 4 │ - +export @decorator +class Foo {} +export default (@decorator +class {}); ``` diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/decorators/class-expression/arguments.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/decorators/class-expression/arguments.js.snap index d853d42c2c5..d767f373428 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/decorators/class-expression/arguments.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/decorators/class-expression/arguments.js.snap @@ -47,35 +47,35 @@ console.log(@deco class {}); arguments.js:1:13 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × expected an expression but instead found '@deco class Foo {}' - + > 1 │ console.log(@deco class Foo {}) │ ^^^^^^^^^^^^^^^^^^ 2 │ console.log(@deco class {}) - 3 │ - + 3 │ + i Expected an expression here - + > 1 │ console.log(@deco class Foo {}) │ ^^^^^^^^^^^^^^^^^^ 2 │ console.log(@deco class {}) - 3 │ - + 3 │ + arguments.js:2:13 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × expected an expression but instead found '@deco class {}' - + 1 │ console.log(@deco class Foo {}) > 2 │ console.log(@deco class {}) │ ^^^^^^^^^^^^^^ - 3 │ - + 3 │ + i Expected an expression here - + 1 │ console.log(@deco class Foo {}) > 2 │ console.log(@deco class {}) │ ^^^^^^^^^^^^^^ - 3 │ - + 3 │ + ``` diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/decorators/class-expression/class-expression.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/decorators/class-expression/class-expression.js.snap index 876ff408dfd..08c856f278e 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/decorators/class-expression/class-expression.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/decorators/class-expression/class-expression.js.snap @@ -47,7 +47,7 @@ const b2 = [] +const a2 = ( +@deco class {} +) - + ( - @deco - class Foo {} @@ -60,7 +60,7 @@ const b2 = [] -); +@deco class {} +) - + const b1 = []; ( - @deco @@ -68,7 +68,7 @@ const b2 = [] -); +@deco class Foo {} +) - + const b2 = []; ( - @deco @@ -76,7 +76,7 @@ const b2 = [] -); +@deco class {} +) - + // This is not a `ClassExpression` but `ClassDeclaration` -@deco -class Foo {} @@ -119,213 +119,213 @@ const b2 = []; class-expression.js:1:13 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × expected `)` but instead found `@` - + > 1 │ const a1 = (@deco class Foo {}); │ ^ 2 │ const a2 = (@deco class {}); - 3 │ - + 3 │ + i Remove @ - + class-expression.js:1:31 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × expected a statement but instead found ')' - + > 1 │ const a1 = (@deco class Foo {}); │ ^ 2 │ const a2 = (@deco class {}); - 3 │ - + 3 │ + i Expected a statement here - + > 1 │ const a1 = (@deco class Foo {}); │ ^ 2 │ const a2 = (@deco class {}); - 3 │ - + 3 │ + class-expression.js:2:13 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × expected `)` but instead found `@` - + 1 │ const a1 = (@deco class Foo {}); > 2 │ const a2 = (@deco class {}); │ ^ - 3 │ + 3 │ 4 │ (@deco class Foo {}); - + i Remove @ - + class-expression.js:2:19 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × class declarations must have a name - + 1 │ const a1 = (@deco class Foo {}); > 2 │ const a2 = (@deco class {}); │ ^^^^^^ - 3 │ + 3 │ 4 │ (@deco class Foo {}); - + class-expression.js:2:27 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × expected a statement but instead found ')' - + 1 │ const a1 = (@deco class Foo {}); > 2 │ const a2 = (@deco class {}); │ ^ - 3 │ + 3 │ 4 │ (@deco class Foo {}); - + i Expected a statement here - + 1 │ const a1 = (@deco class Foo {}); > 2 │ const a2 = (@deco class {}); │ ^ - 3 │ + 3 │ 4 │ (@deco class Foo {}); - + class-expression.js:4:2 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × expected `)` but instead found `@` - + 2 │ const a2 = (@deco class {}); - 3 │ + 3 │ > 4 │ (@deco class Foo {}); │ ^ 5 │ (@deco class {}); - 6 │ - + 6 │ + i Remove @ - + class-expression.js:4:20 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × expected a statement but instead found ')' - + 2 │ const a2 = (@deco class {}); - 3 │ + 3 │ > 4 │ (@deco class Foo {}); │ ^ 5 │ (@deco class {}); - 6 │ - + 6 │ + i Expected a statement here - + 2 │ const a2 = (@deco class {}); - 3 │ + 3 │ > 4 │ (@deco class Foo {}); │ ^ 5 │ (@deco class {}); - 6 │ - + 6 │ + class-expression.js:5:2 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × expected `)` but instead found `@` - + 4 │ (@deco class Foo {}); > 5 │ (@deco class {}); │ ^ - 6 │ + 6 │ 7 │ const b1 = [] - + i Remove @ - + class-expression.js:5:8 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × class declarations must have a name - + 4 │ (@deco class Foo {}); > 5 │ (@deco class {}); │ ^^^^^^ - 6 │ + 6 │ 7 │ const b1 = [] - + class-expression.js:5:16 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × expected a statement but instead found ')' - + 4 │ (@deco class Foo {}); > 5 │ (@deco class {}); │ ^ - 6 │ + 6 │ 7 │ const b1 = [] - + i Expected a statement here - + 4 │ (@deco class Foo {}); > 5 │ (@deco class {}); │ ^ - 6 │ + 6 │ 7 │ const b1 = [] - + class-expression.js:8:3 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × expected `)` but instead found `@` - + 7 │ const b1 = [] > 8 │ ;(@deco class Foo {}) │ ^ - 9 │ + 9 │ 10 │ const b2 = [] - + i Remove @ - + class-expression.js:8:21 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × expected a statement but instead found ')' - + 7 │ const b1 = [] > 8 │ ;(@deco class Foo {}) │ ^ - 9 │ + 9 │ 10 │ const b2 = [] - + i Expected a statement here - + 7 │ const b1 = [] > 8 │ ;(@deco class Foo {}) │ ^ - 9 │ + 9 │ 10 │ const b2 = [] - + class-expression.js:11:3 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × expected `)` but instead found `@` - + 10 │ const b2 = [] > 11 │ ;(@deco class {}) │ ^ - 12 │ + 12 │ 13 │ // This is not a `ClassExpression` but `ClassDeclaration` - + i Remove @ - + class-expression.js:11:9 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × class declarations must have a name - + 10 │ const b2 = [] > 11 │ ;(@deco class {}) │ ^^^^^^ - 12 │ + 12 │ 13 │ // This is not a `ClassExpression` but `ClassDeclaration` - + class-expression.js:11:17 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × expected a statement but instead found ')' - + 10 │ const b2 = [] > 11 │ ;(@deco class {}) │ ^ - 12 │ + 12 │ 13 │ // This is not a `ClassExpression` but `ClassDeclaration` - + i Expected a statement here - + 10 │ const b2 = [] > 11 │ ;(@deco class {}) │ ^ - 12 │ + 12 │ 13 │ // This is not a `ClassExpression` but `ClassDeclaration` - + ``` diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/decorators/class-expression/member-expression.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/decorators/class-expression/member-expression.js.snap index ab43ca6e37c..3689c35d016 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/decorators/class-expression/member-expression.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/decorators/class-expression/member-expression.js.snap @@ -49,66 +49,66 @@ info: js/decorators/class-expression/member-expression.js member-expression.js:1:2 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × expected `)` but instead found `@` - + > 1 │ (@deco class Foo {}).name; │ ^ 2 │ (@deco class {}).name; - 3 │ - + 3 │ + i Remove @ - + member-expression.js:1:20 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × expected a statement but instead found ').name' - + > 1 │ (@deco class Foo {}).name; │ ^^^^^^ 2 │ (@deco class {}).name; - 3 │ - + 3 │ + i Expected a statement here - + > 1 │ (@deco class Foo {}).name; │ ^^^^^^ 2 │ (@deco class {}).name; - 3 │ - + 3 │ + member-expression.js:2:2 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × expected `)` but instead found `@` - + 1 │ (@deco class Foo {}).name; > 2 │ (@deco class {}).name; │ ^ - 3 │ - + 3 │ + i Remove @ - + member-expression.js:2:8 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × class declarations must have a name - + 1 │ (@deco class Foo {}).name; > 2 │ (@deco class {}).name; │ ^^^^^^ - 3 │ - + 3 │ + member-expression.js:2:16 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × expected a statement but instead found ').name' - + 1 │ (@deco class Foo {}).name; > 2 │ (@deco class {}).name; │ ^^^^^^ - 3 │ - + 3 │ + i Expected a statement here - + 1 │ (@deco class Foo {}).name; > 2 │ (@deco class {}).name; │ ^^^^^^ - 3 │ - + 3 │ + ``` diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/decorators/class-expression/super-class.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/decorators/class-expression/super-class.js.snap index de958f2d526..10697199ca7 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/decorators/class-expression/super-class.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/decorators/class-expression/super-class.js.snap @@ -28,7 +28,7 @@ class Foo extends (@deco class {}){} +) +{ +} - + -class Foo extends ( - @deco - class {} @@ -58,103 +58,103 @@ class Foo extends (@deco class {} super-class.js:1:20 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × expected `)` but instead found `@` - + > 1 │ class Foo extends (@deco class Foo {}){} │ ^ - 2 │ + 2 │ 3 │ class Foo extends (@deco class {}){} - + i Remove @ - + super-class.js:1:32 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × expected a semicolon to end the class property, but found none - + > 1 │ class Foo extends (@deco class Foo {}){} │ ^^^ - 2 │ + 2 │ 3 │ class Foo extends (@deco class {}){} - + super-class.js:1:36 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × expected an identifier, a string literal, a number literal, a private field name, or a computed name but instead found '{' - + > 1 │ class Foo extends (@deco class Foo {}){} │ ^ - 2 │ + 2 │ 3 │ class Foo extends (@deco class {}){} - + i Expected an identifier, a string literal, a number literal, a private field name, or a computed name here - + > 1 │ class Foo extends (@deco class Foo {}){} │ ^ - 2 │ + 2 │ 3 │ class Foo extends (@deco class {}){} - + super-class.js:1:38 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × expected a statement but instead found ')' - + > 1 │ class Foo extends (@deco class Foo {}){} │ ^ - 2 │ + 2 │ 3 │ class Foo extends (@deco class {}){} - + i Expected a statement here - + > 1 │ class Foo extends (@deco class Foo {}){} │ ^ - 2 │ + 2 │ 3 │ class Foo extends (@deco class {}){} - + super-class.js:3:20 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × expected `)` but instead found `@` - + 1 │ class Foo extends (@deco class Foo {}){} - 2 │ + 2 │ > 3 │ class Foo extends (@deco class {}){} │ ^ - 4 │ - + 4 │ + i Remove @ - + super-class.js:3:32 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × expected an identifier, a string literal, a number literal, a private field name, or a computed name but instead found '{' - + 1 │ class Foo extends (@deco class Foo {}){} - 2 │ + 2 │ > 3 │ class Foo extends (@deco class {}){} │ ^ - 4 │ - + 4 │ + i Expected an identifier, a string literal, a number literal, a private field name, or a computed name here - + 1 │ class Foo extends (@deco class Foo {}){} - 2 │ + 2 │ > 3 │ class Foo extends (@deco class {}){} │ ^ - 4 │ - + 4 │ + super-class.js:3:34 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × expected a statement but instead found ')' - + 1 │ class Foo extends (@deco class Foo {}){} - 2 │ + 2 │ > 3 │ class Foo extends (@deco class {}){} │ ^ - 4 │ - + 4 │ + i Expected a statement here - + 1 │ class Foo extends (@deco class Foo {}){} - 2 │ + 2 │ > 3 │ class Foo extends (@deco class {}){} │ ^ - 4 │ - + 4 │ + ``` diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/decorators/classes.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/decorators/classes.js.snap index b2c6c63c508..140067513bd 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/decorators/classes.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/decorators/classes.js.snap @@ -35,15 +35,15 @@ const bar = -@deco -class Foo {} +@deco class Foo {} - + -@deco -export class Bar {} +@deco export class Bar {} - + -@deco -export default class Baz {} +@deco export default class Baz {} - + const foo = - ( - @deco @@ -54,7 +54,7 @@ const bar = +@deco class { + // +} - + const bar = - ( - @deco @@ -94,63 +94,63 @@ const bar = classes.js:7:13 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × expected an expression, or an assignment but instead found '@' - + 5 │ @deco export default class Baz {} - 6 │ + 6 │ > 7 │ const foo = @deco class { │ ^ 8 │ // 9 │ }; - + i Expected an expression, or an assignment here - + 5 │ @deco export default class Baz {} - 6 │ + 6 │ > 7 │ const foo = @deco class { │ ^ 8 │ // 9 │ }; - + classes.js:7:19 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × class declarations must have a name - + 5 │ @deco export default class Baz {} - 6 │ + 6 │ > 7 │ const foo = @deco class { │ ^^^^^^ 8 │ // 9 │ }; - + classes.js:12:3 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × expected an expression, or an assignment but instead found '@' - + 11 │ const bar = > 12 │ @deco │ ^ 13 │ class { 14 │ // - + i Expected an expression, or an assignment here - + 11 │ const bar = > 12 │ @deco │ ^ 13 │ class { 14 │ // - + classes.js:13:3 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × class declarations must have a name - + 11 │ const bar = 12 │ @deco > 13 │ class { │ ^^^^^^ 14 │ // 15 │ }; - + ``` diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/decorators/comments.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/decorators/comments.js.snap index 23fe2f2fc57..a3e8797fa82 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/decorators/comments.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/decorators/comments.js.snap @@ -49,7 +49,7 @@ export class Bar{} +++ Rome @@ -1,9 +1,9 @@ var x = 100; - + @Hello({ - a: "a", // Comment is in the wrong place + a: 'a', // Comment is in the wrong place @@ -58,7 +58,7 @@ export class Bar{} + b: '2' }) class X {} - + ``` # Output diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/decorators/mobx.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/decorators/mobx.js.snap index 8eab3624afe..4ef3952c1e0 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/decorators/mobx.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/decorators/mobx.js.snap @@ -34,13 +34,13 @@ import {observable} from "mobx"; setPrice(price) { this.price = price; } - + @computed @computed @computed @computed @computed @computed @computed get total() { return this.price * this.amount; } @action handleDecrease = (event: React.ChangeEvent) => this.count--; - + @action handleSomething = (event: React.ChangeEvent) => doSomething(); } @@ -54,7 +54,7 @@ import {observable} from "mobx"; +++ Rome @@ -1,9 +1,8 @@ import { observable } from "mobx"; - + -@observer -class OrderLine { - @observable price: number = 0; @@ -62,13 +62,13 @@ import {observable} from "mobx"; +@observer class OrderLine { + @observable price:number = 0; + @observable amount:number = 1; - + constructor(price) { this.price = price; @@ -27,20 +26,11 @@ this.price = price; } - + - @computed - @computed - @computed @@ -80,11 +80,11 @@ import {observable} from "mobx"; + @computed @computed @computed @computed @computed @computed @computed get total() { return this.price * this.amount; } - + - @action handleDecrease = (event: React.ChangeEvent) => - this.count--; + @action handleDecrease = (event: React.ChangeEvent) => this.count--; - + - @action handleSomething = (event: React.ChangeEvent) => - doSomething(); + @action handleSomething = (event: React.ChangeEvent) => doSomething(); @@ -137,54 +137,54 @@ import { observable } from "mobx"; mobx.js:4:20 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × return types can only be used in TypeScript files - + 3 │ @observer class OrderLine { > 4 │ @observable price:number = 0; │ ^^^^^^^ 5 │ @observable amount:number = 1; - 6 │ - + 6 │ + i remove this type annotation - + mobx.js:5:21 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × return types can only be used in TypeScript files - + 3 │ @observer class OrderLine { 4 │ @observable price:number = 0; > 5 │ @observable amount:number = 1; │ ^^^^^^^ - 6 │ + 6 │ 7 │ constructor(price) { - + i remove this type annotation - + mobx.js:33:34 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × Type annotations are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax. - + 31 │ } - 32 │ + 32 │ > 33 │ @action handleDecrease = (event: React.ChangeEvent) => this.count--; │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - 34 │ + 34 │ 35 │ @action handleSomething = (event: React.ChangeEvent) => doSomething(); - + i TypeScript only syntax - + mobx.js:35:35 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × Type annotations are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax. - + 33 │ @action handleDecrease = (event: React.ChangeEvent) => this.count--; - 34 │ + 34 │ > 35 │ @action handleSomething = (event: React.ChangeEvent) => doSomething(); │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 36 │ } - 37 │ - + 37 │ + i TypeScript only syntax - + ``` diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/decorators/multiple.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/decorators/multiple.js.snap index 5bd983f4c76..a0325288c7f 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/decorators/multiple.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/decorators/multiple.js.snap @@ -38,7 +38,7 @@ const foo = { @nonenumerable @doubledValue legs: 4, - + - @readonly +@readonly @nonenumerable @@ -47,7 +47,7 @@ const foo = { -}; +eyes: 2; +} - + const foo = { - @multipleDecorators - @inline @@ -83,97 +83,97 @@ const foo = { multiple.js:2:3 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × expected a property, a shorthand property, a getter, a setter, or a method but instead found '@' - + 1 │ const dog = { > 2 │ @readonly │ ^ 3 │ @nonenumerable 4 │ @doubledValue - + i Expected a property, a shorthand property, a getter, a setter, or a method here - + 1 │ const dog = { > 2 │ @readonly │ ^ 3 │ @nonenumerable 4 │ @doubledValue - + multiple.js:7:3 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × expected an expression but instead found '@' - + 5 │ legs: 4, - 6 │ + 6 │ > 7 │ @readonly │ ^ 8 │ @nonenumerable 9 │ @doubledValue - + i Expected an expression here - + 5 │ legs: 4, - 6 │ + 6 │ > 7 │ @readonly │ ^ 8 │ @nonenumerable 9 │ @doubledValue - + multiple.js:11:1 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × expected a statement but instead found '}' - + 9 │ @doubledValue 10 │ eyes: 2 > 11 │ }; │ ^ - 12 │ + 12 │ 13 │ const foo = { - + i Expected a statement here - + 9 │ @doubledValue 10 │ eyes: 2 > 11 │ }; │ ^ - 12 │ + 12 │ 13 │ const foo = { - + multiple.js:14:3 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × expected a property, a shorthand property, a getter, a setter, or a method but instead found '@' - + 13 │ const foo = { > 14 │ @multipleDecorators @inline @theyWontAllFitInOneline aVeryLongPropName: "A very long string as value" │ ^ 15 │ }; - 16 │ - + 16 │ + i Expected a property, a shorthand property, a getter, a setter, or a method here - + 13 │ const foo = { > 14 │ @multipleDecorators @inline @theyWontAllFitInOneline aVeryLongPropName: "A very long string as value" │ ^ 15 │ }; - 16 │ - + 16 │ + multiple.js:15:1 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × expected a statement but instead found '}' - + 13 │ const foo = { 14 │ @multipleDecorators @inline @theyWontAllFitInOneline aVeryLongPropName: "A very long string as value" > 15 │ }; │ ^ - 16 │ - + 16 │ + i Expected a statement here - + 13 │ const foo = { 14 │ @multipleDecorators @inline @theyWontAllFitInOneline aVeryLongPropName: "A very long string as value" > 15 │ }; │ ^ - 16 │ - + 16 │ + ``` diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/decorators/redux.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/decorators/redux.js.snap index 942f048b1a8..4c37ce1a1a8 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/decorators/redux.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/decorators/redux.js.snap @@ -24,7 +24,7 @@ export class Home extends React.Component {} @@ -1,5 +1,5 @@ @connect(mapStateToProps, mapDispatchToProps) export class MyApp extends React.Component {} - + -@connect((state) => ({ todos: state.todos })) +@connect(state => ({ todos: state.todos })) export class Home extends React.Component {} diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/angular-component-examples/test.component.ts.snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/angular-component-examples/test.component.ts.snap index 0c2f12fd8ba..e001c22ef6a 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/typescript/angular-component-examples/test.component.ts.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/angular-component-examples/test.component.ts.snap @@ -13,10 +13,10 @@ info: typescript/angular-component-examples/test.component.ts `, styles: [ ` - + :host { color: red; - } + } div { background: blue } ` @@ -54,10 +54,10 @@ class TestComponent {} + + `, + styles: [ ` -+ ++ + :host { + color: red; -+ } ++ } + div { background: blue + } +` @@ -76,10 +76,10 @@ class TestComponent {} `, styles: [ ` - + :host { color: red; - } + } div { background: blue } ` diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/decorators-ts/typeorm.ts.snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/decorators-ts/typeorm.ts.snap index 1ae8d75c204..d4bc229bd67 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/typescript/decorators-ts/typeorm.ts.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/decorators-ts/typeorm.ts.snap @@ -41,7 +41,7 @@ export class Board { @@ -15,6 +15,6 @@ @Column() description: string; - + - @OneToMany((type) => Topic, (topic) => topic.board) + @OneToMany(type => Topic, topic => topic.board) topics: Topic[]; diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/decorators/decorators.ts.snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/decorators/decorators.ts.snap index 497abbc6917..e99e15b9e8b 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/typescript/decorators/decorators.ts.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/decorators/decorators.ts.snap @@ -100,10 +100,10 @@ class Class6 { + @ILifecycleService lifecycleService, + ) {} } - + @commonEditorContribution export class TabCompletionController {} - + @Component({ - selector: "angular-component", + selector: 'angular-component', @@ -112,14 +112,14 @@ class Class6 { @Input() myInput: string; @@ -50,12 +52,24 @@ } - + class Class5 { - method(@Decorator { prop1 }: Type) {} + method( + @Decorator { prop1 }: Type, + ) {} } - + class Class6 { - method(@Decorator({}) { prop1 }: Type) {} - method(@Decorator({}) { prop1 }: Type) {} diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/decorators/inline-decorators.ts.snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/decorators/inline-decorators.ts.snap index 7aff2795a72..25e55d64a7e 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/typescript/decorators/inline-decorators.ts.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/decorators/inline-decorators.ts.snap @@ -66,7 +66,7 @@ class MyContainerComponent { --- Prettier +++ Rome @@ -6,9 +6,9 @@ - + class Class2 { @d1 - @d2(foo) @@ -76,7 +76,7 @@ class MyContainerComponent { + @d3.bar + @d4.baz() method1() {} - + @d1 @@ -30,22 +30,19 @@ constructor( @@ -92,15 +92,15 @@ class MyContainerComponent { + }) private a: string, ) {} } - + -@decorated -class Foo {} +@decorated class Foo {} - + class Bar { @decorated method() {} } - + class MyContainerComponent { - @ContentChildren(MyComponent) - components: QueryListSomeBigName; diff --git a/crates/rome_js_formatter/tests/specs/ts/decoartors.ts.snap b/crates/rome_js_formatter/tests/specs/ts/decoartors.ts.snap index 7e0f3475bf6..774970cf581 100644 --- a/crates/rome_js_formatter/tests/specs/ts/decoartors.ts.snap +++ b/crates/rome_js_formatter/tests/specs/ts/decoartors.ts.snap @@ -1,7 +1,6 @@ --- source: crates/rome_formatter_test/src/snapshot_builder.rs -info: - test_file: ts/decoartors.ts +info: ts/decoartors.ts --- # Input @@ -98,9 +97,9 @@ export default class {} export class Test {} // Leading comment before decorator -@test // first decorator -// Leading comment before class -class Test2 { +@test // first decorator // first decorator +class // Leading comment before class +Test2 { /* * Leading multiline comment */ @@ -124,8 +123,6 @@ class Test2 { "\t\t@aVeryLongDecoratorNameLetsSeeWhatHappensWith" => 104..151 "@param" => 175..181 "@param" => 219..225 -"@sealed" => 239..246 -"@sealed" => 272..279 -"@test" => 338..343 -"\t@test /* trailing multiline comment\n\t for decorator */ @anotherDecorator(" => 449..523 +"@test // first decorator // first decorator\nclass // Leading c" => 338..400 +"\t@test /* trailing multiline comment\n\t for decorator */ @anotherDecorator(" => 468..542 diff --git a/crates/rome_js_parser/src/syntax/auxiliary.rs b/crates/rome_js_parser/src/syntax/auxiliary.rs index 60efefece9e..6932f72a7f9 100644 --- a/crates/rome_js_parser/src/syntax/auxiliary.rs +++ b/crates/rome_js_parser/src/syntax/auxiliary.rs @@ -1,5 +1,5 @@ use crate::prelude::*; -use crate::syntax::class::parse_class_declaration; +use crate::syntax::class::{parse_class_declaration, parse_decorators}; use crate::syntax::function::parse_function_declaration; use crate::syntax::module::parse_import_or_import_equals_declaration; use crate::syntax::stmt::{ @@ -11,7 +11,7 @@ use crate::syntax::typescript::{ parse_ts_enum_declaration, parse_ts_interface_declaration, parse_ts_type_alias_declaration, }; use crate::{Absent, JsParser, ParsedSyntax}; -use rome_js_syntax::JsSyntaxKind::JS_VARIABLE_DECLARATION_CLAUSE; +use rome_js_syntax::JsSyntaxKind::{JS_BOGUS_STATEMENT, JS_VARIABLE_DECLARATION_CLAUSE}; use rome_js_syntax::T; use rome_rowan::{TextRange, TextSize}; @@ -37,7 +37,7 @@ pub(crate) fn parse_variable_declaration_clause(p: &mut JsParser) -> ParsedSynta pub(crate) fn is_nth_at_declaration_clause(p: &mut JsParser, n: usize) -> bool { if matches!( p.nth(n), - T![function] | T![const] | T![enum] | T![class] | T![import] + T![function] | T![const] | T![enum] | T![class] | T![import] | T![@] ) { return true; } @@ -76,8 +76,46 @@ pub(crate) fn is_nth_at_declaration_clause(p: &mut JsParser, n: usize) -> bool { pub(crate) fn parse_declaration_clause(p: &mut JsParser, stmt_start_pos: TextSize) -> ParsedSyntax { match p.cur() { T![function] => parse_function_declaration(p, StatementContext::StatementList), - T![class] => parse_class_declaration(p, StatementContext::StatementList), - T![abstract] => parse_class_declaration(p, StatementContext::StatementList), + T![@] => { + let decorator_list = parse_decorators(p); + + match p.cur() { + T![class] | T![abstract] if !p.state().in_ambient_context() => { + // test decorator_export_class_clause + // export @decorator class Bar {}; + // export @first @second class Foo { + // constructor() {} + // } + + //test ts decorator_abstract_export_class_clause + // export @decorator abstract class Bar {}; + // export @first @second abstract class Foo { + // constructor() {} + // } + parse_class_declaration(p, decorator_list, StatementContext::StatementList) + } + _ => { + // test_err decorator_export_class_clause + // @decorator + // export let a; + // @decorator1 @decorator2 + // export function Foo() { } + decorator_list + .add_diagnostic_if_present(p, |p, range| { + p.err_builder("Decorators are not valid here.", range) + }) + .map(|mut marker| { + marker.change_kind(p, JS_BOGUS_STATEMENT); + marker + }); + + parse_declaration_clause(p, stmt_start_pos) + } + } + } + T![class] | T![abstract] => { + parse_class_declaration(p, Absent, StatementContext::StatementList) + } T![const] => { if p.nth_at(1, T![enum]) { parse_ts_enum_declaration(p) diff --git a/crates/rome_js_parser/src/syntax/class.rs b/crates/rome_js_parser/src/syntax/class.rs index 7dcc3b982c8..9572af57ba0 100644 --- a/crates/rome_js_parser/src/syntax/class.rs +++ b/crates/rome_js_parser/src/syntax/class.rs @@ -6,7 +6,8 @@ use crate::state::{ }; use crate::syntax::binding::parse_binding; use crate::syntax::expr::{ - parse_assignment_expression_or_higher, parse_lhs_expr, parse_private_name, ExpressionContext, + parse_assignment_expression_or_higher, parse_expression, parse_lhs_expr, parse_private_name, + ExpressionContext, }; use crate::syntax::function::{ parse_any_parameter, parse_formal_parameter, parse_function_body, parse_parameter_list, @@ -14,8 +15,8 @@ use crate::syntax::function::{ }; use crate::syntax::js_parse_error; use crate::syntax::js_parse_error::{ - expected_binding, modifier_already_seen, modifier_cannot_be_used_with_modifier, - modifier_must_precede_modifier, + expected_binding, expected_expression, invalid_decorator_error, modifier_already_seen, + modifier_cannot_be_used_with_modifier, modifier_must_precede_modifier, }; use crate::syntax::object::{ is_at_literal_member_name, parse_computed_member_name, parse_literal_member_name, @@ -29,8 +30,7 @@ use crate::syntax::typescript::ts_parse_error::{ }; use crate::syntax::typescript::{ is_reserved_type_name, parse_ts_implements_clause, parse_ts_return_type_annotation, - parse_ts_type_annotation, parse_ts_type_arguments, parse_ts_type_parameters, - skip_ts_decorators, TypeContext, + parse_ts_type_annotation, parse_ts_type_arguments, parse_ts_type_parameters, TypeContext, }; use crate::JsSyntaxFeature::TypeScript; @@ -70,12 +70,15 @@ pub(crate) fn is_at_ts_abstract_class_declaration( } /// Parses a class expression, e.g. let a = class {} -pub(super) fn parse_class_expression(p: &mut JsParser) -> ParsedSyntax { +pub(super) fn parse_class_expression( + p: &mut JsParser, + decorator_list: ParsedSyntax, +) -> ParsedSyntax { if !p.at(T![class]) { return Absent; } - Present(parse_class(p, ClassKind::Expression)) + Present(parse_class(p, ClassKind::Expression, decorator_list)) } // test class_declaration @@ -141,12 +144,16 @@ pub(super) fn parse_class_expression(p: &mut JsParser) -> ParsedSyntax { /// /// A class can be invalid if /// * It uses an illegal identifier name -pub(super) fn parse_class_declaration(p: &mut JsParser, context: StatementContext) -> ParsedSyntax { +pub(super) fn parse_class_declaration( + p: &mut JsParser, + decorator_list: ParsedSyntax, + context: StatementContext, +) -> ParsedSyntax { if !matches!(p.cur(), T![abstract] | T![class]) { return Absent; } - let mut class = parse_class(p, ClassKind::Declaration); + let mut class = parse_class(p, ClassKind::Declaration, decorator_list); if !class.kind(p).is_bogus() && context.is_single_statement() { // test_err class_in_single_statement_context @@ -169,12 +176,15 @@ pub(super) fn parse_class_declaration(p: &mut JsParser, context: StatementContex // test ts typescript_export_default_abstract_class_case // export default abstract class {} -pub(super) fn parse_class_export_default_declaration(p: &mut JsParser) -> ParsedSyntax { +pub(super) fn parse_class_export_default_declaration( + p: &mut JsParser, + decorator_list: ParsedSyntax, +) -> ParsedSyntax { if !matches!(p.cur(), T![abstract] | T![class]) { return Absent; } - Present(parse_class(p, ClassKind::ExportDefault)) + Present(parse_class(p, ClassKind::ExportDefault, decorator_list)) } #[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)] @@ -206,8 +216,13 @@ impl From for JsSyntaxKind { // test ts ts_class_named_abstract_is_valid_in_ts // class abstract {} #[inline] -fn parse_class(p: &mut JsParser, kind: ClassKind) -> CompletedMarker { - let m = p.start(); +fn parse_class(p: &mut JsParser, kind: ClassKind, decorator_list: ParsedSyntax) -> CompletedMarker { + let decorator_list = decorator_list.or_else(|| { + let m = p.start(); + Present(m.complete(p, JS_DECORATOR_LIST)) + }); + + let m = decorator_list.precede(p); let is_abstract = p.eat(T![abstract]); let class_token_range = p.cur_range(); @@ -2377,3 +2392,128 @@ impl ClassMemberModifiers { None } } + +// test ts decorator +// // class expressions +// let a = @decorator class {}; +// let b = @decorator @functionDecorator(1,2,3) class {}; +// let c = @first @second class Foo {} +// // class declarations +// @decorator class Foo {}; +// @decorator @functionDecorator(1,2,3) class Bar {}; +// @first @second class Baz {} +// // abstract class declarations +// @decorator abstract class Foo {}; +// @decorator @functionDecorator(1,2,3) abstract class Bar {}; +// @first @second abstract class Baz {} +// // exported class declarations +// export @decorator class Foo {}; +// export @decorator @functionDecorator(1,2,3) class Bar {}; +// export @first @second class Baz {} + +// test ts decorator_class_not_top_level +// if (a) { +// @dec class MyClass {} +// } +// function foo() { +// @dec class MyClass {} +// } + +// test_err ts decorator +// @'dsads' class MyClass {} +// @1 class MyClass {} +// @++1 class MyClass {} +// @[] in 1 class MyClass {} +// @[] class MyClass {} +// @() => {} class MyClass {} +// @1 == 2 ? true : false class MyClass {} +// @await fn class MyClass {} +// @function(){} class MyClass {} +// @obj instanceof Object class MyClass {} +// @1 === 2 class MyClass {} +// @new Object() class MyClass {} +// @{} class MyClass {} +// @a++ class MyClass {} +// @a,b class MyClass {} +// @`${d}foo` class MyClass {} +// @obj as MyType class MyClass {} +// @obj class MyClass {} +// @obj satisfies MyType class MyClass {} +// @obj! class MyClass {} +pub(crate) fn parse_decorators(p: &mut JsParser) -> ParsedSyntax { + if !p.at(T![@]) { + return Absent; + } + + let decorators = p.start(); + + while p.at(T![@]) { + parse_decorator(p).ok(); + } + + Present(decorators.complete(p, JS_DECORATOR_LIST)) +} + +fn parse_decorator(p: &mut JsParser) -> ParsedSyntax { + if !p.at(T![@]) { + return Absent; + } + + let m = p.start(); + p.bump(T![@]); + if let Some(mut complete_marker) = + parse_lhs_expr(p, ExpressionContext::default().and_in_decorator(true)) + .or_add_diagnostic(p, expected_expression) + { + if !matches!( + complete_marker.kind(p), + JS_PARENTHESIZED_EXPRESSION + | JS_CALL_EXPRESSION + | JS_STATIC_MEMBER_EXPRESSION + | JS_IDENTIFIER_EXPRESSION + ) { + p.error(invalid_decorator_error(p, complete_marker.range(p))); + complete_marker.change_to_bogus(p); + } + } + + Present(m.complete(p, JS_DECORATOR)) +} + +// test ts ts_class_decorator +// function test() {} +// @test +// class Test {} +// @test.a?.c @test @test +// class Test2{} + +/// Skips over any TypeScript decorator syntax. +pub(crate) fn skip_ts_decorators(p: &mut JsParser) { + if !p.at(T![@]) { + return; + } + + p.parse_as_skipped_trivia_tokens(|p| { + while p.at(T![@]) { + parse_decorator_bogus(p).ok(); + } + }); +} + +fn parse_decorator_bogus(p: &mut JsParser) -> ParsedSyntax { + if p.at(T![@]) { + let m = p.start(); + p.bump(T![@]); + // test ts ts_decorator_call_expression_with_arrow + // export class Foo { + // @Decorator((val) => val) + // badField!: number + // } + parse_lhs_expr(p, ExpressionContext::default().and_in_decorator(true)) + .or_add_diagnostic(p, expected_expression); + + Present(m.complete(p, JS_BOGUS)) + } else { + Absent + } +} diff --git a/crates/rome_js_parser/src/syntax/expr.rs b/crates/rome_js_parser/src/syntax/expr.rs index c9e864b5900..b869e2936e9 100644 --- a/crates/rome_js_parser/src/syntax/expr.rs +++ b/crates/rome_js_parser/src/syntax/expr.rs @@ -13,7 +13,7 @@ use crate::rewrite::RewriteParseEvents; use crate::syntax::assignment::parse_assignment; use crate::syntax::assignment::AssignmentExprPrecedence; use crate::syntax::assignment::{expression_to_assignment, expression_to_assignment_pattern}; -use crate::syntax::class::parse_class_expression; +use crate::syntax::class::{parse_class_expression, parse_decorators}; use crate::syntax::function::{ is_at_async_function, parse_arrow_function_expression, parse_function_expression, LineBreak, }; @@ -57,7 +57,7 @@ bitflags! { /// If `true` then, don't parse computed member expressions because they can as well indicate /// the start of a computed class member. - const IN_TS_DECORATOR = 1 << 2; + const IN_DECORATOR = 1 << 2; /// If `true` allows a typescript type assertion. /// Currently disabled on "new" expressions. @@ -74,8 +74,8 @@ impl ExpressionContext { self.and(ExpressionContextFlags::ALLOW_OBJECT_EXPRESSION, allowed) } - pub(crate) fn and_in_ts_decorator(self, in_decorator: bool) -> Self { - self.and(ExpressionContextFlags::IN_TS_DECORATOR, in_decorator) + pub(crate) fn and_in_decorator(self, in_decorator: bool) -> Self { + self.and(ExpressionContextFlags::IN_DECORATOR, in_decorator) } pub(crate) fn and_ts_type_assertion_allowed(self, allowed: bool) -> Self { @@ -94,8 +94,8 @@ impl ExpressionContext { } /// Returns `true` if currently parsing a decorator expression `@`. - pub(crate) const fn is_in_ts_decorator(&self) -> bool { - self.0.contains(ExpressionContextFlags::IN_TS_DECORATOR) + pub(crate) const fn is_in_decorator(&self) -> bool { + self.0.contains(ExpressionContextFlags::IN_DECORATOR) } /// Adds the `flag` if `set` is `true`, otherwise removes the `flag` @@ -721,7 +721,7 @@ fn parse_member_expression_rest( lhs = match p.cur() { T![.] => parse_static_member_expression(p, lhs, T![.]).unwrap(), // Don't parse out `[` as a member expression because it may as well be the start of a computed class member - T!['['] if !context.is_in_ts_decorator() => { + T!['['] if !context.is_in_decorator() => { parse_computed_member_expression(p, lhs, false).unwrap() } T![?.] if allow_optional_chain => { @@ -1277,6 +1277,35 @@ fn parse_primary_expression(p: &mut JsParser, context: ExpressionContext) -> Par p.expect(T![this]); m.complete(p, JS_THIS_EXPRESSION) } + T![@] => { + let decorator_list = parse_decorators(p); + + return match p.cur() { + T![class] => { + // test decorator_expression_class + // let a = @decorator class {}; + // let b = @first @second class foo { + // constructor() {} + // } + parse_class_expression(p, decorator_list) + } + _ => { + // test_err decorator_expression_class + // let a = @decorator () => {}; + // let b = @first @second function foo {} + // let a = @decorator ( () => {} ) + decorator_list + .add_diagnostic_if_present(p, |p, range| { + p.err_builder("Decorators are not valid here.", range) + }) + .map(|mut marker| { + marker.change_kind(p, JS_BOGUS_EXPRESSION); + marker + }); + parse_assignment_expression_or_higher(p, context) + } + }; + } T![class] => { // test class_expr // let a = class {}; @@ -1284,7 +1313,7 @@ fn parse_primary_expression(p: &mut JsParser, context: ExpressionContext) -> Par // constructor() {} // } // foo[class {}] - parse_class_expression(p).unwrap() + parse_class_expression(p, Absent).unwrap() } // test async_ident // let a = async; diff --git a/crates/rome_js_parser/src/syntax/function.rs b/crates/rome_js_parser/src/syntax/function.rs index d2b91f51083..6f8cbb11096 100644 --- a/crates/rome_js_parser/src/syntax/function.rs +++ b/crates/rome_js_parser/src/syntax/function.rs @@ -4,7 +4,7 @@ use crate::state::{EnterFunction, EnterParameters, SignatureFlags}; use crate::syntax::binding::{ is_at_identifier_binding, is_nth_at_identifier_binding, parse_binding, parse_binding_pattern, }; -use crate::syntax::class::parse_initializer_clause; +use crate::syntax::class::{parse_initializer_clause, skip_ts_decorators}; use crate::syntax::expr::{ is_nth_at_identifier, parse_assignment_expression_or_higher, ExpressionContext, }; @@ -14,7 +14,7 @@ use crate::syntax::stmt::{is_semi, parse_block_impl, semi, StatementContext}; use crate::syntax::typescript::ts_parse_error::ts_only_syntax_error; use crate::syntax::typescript::{ is_nth_at_type_parameter_modifier, parse_ts_return_type_annotation, parse_ts_type_annotation, - parse_ts_type_parameters, skip_ts_decorators, try_parse, TypeContext, + parse_ts_type_parameters, try_parse, TypeContext, }; use crate::JsSyntaxFeature::TypeScript; diff --git a/crates/rome_js_parser/src/syntax/js_parse_error.rs b/crates/rome_js_parser/src/syntax/js_parse_error.rs index 05e7aa04185..de874ddec81 100644 --- a/crates/rome_js_parser/src/syntax/js_parse_error.rs +++ b/crates/rome_js_parser/src/syntax/js_parse_error.rs @@ -254,3 +254,10 @@ pub(crate) fn modifier_must_precede_modifier( .detail(range, "move this modifier") .detail(to_precede_modifier_range, "before this modifier") } + +pub(crate) fn invalid_decorator_error(p: &JsParser, range: TextRange) -> ParseDiagnostic { + p.err_builder( + format!("Invalid decorator `{}`", p.text(range.as_range()),), + range, + ) +} diff --git a/crates/rome_js_parser/src/syntax/module.rs b/crates/rome_js_parser/src/syntax/module.rs index 3e9b3171789..69634125927 100644 --- a/crates/rome_js_parser/src/syntax/module.rs +++ b/crates/rome_js_parser/src/syntax/module.rs @@ -4,12 +4,15 @@ use crate::state::{EnterAmbientContext, ExportDefaultItem, ExportDefaultItemKind use crate::syntax::binding::{ is_at_identifier_binding, is_nth_at_identifier_binding, parse_binding, parse_identifier_binding, }; -use crate::syntax::class::parse_class_export_default_declaration; +use crate::syntax::class::{ + is_at_ts_abstract_class_declaration, parse_class_declaration, + parse_class_export_default_declaration, parse_decorators, +}; use crate::syntax::expr::{ is_nth_at_expression, is_nth_at_reference_identifier, parse_assignment_expression_or_higher, parse_name, parse_reference_identifier, ExpressionContext, }; -use crate::syntax::function::parse_function_export_default_declaration; +use crate::syntax::function::{parse_function_export_default_declaration, LineBreak}; use crate::syntax::js_parse_error::{ duplicate_assertion_keys_error, expected_binding, expected_declaration, expected_export_clause, expected_export_name_specifier, expected_expression, expected_identifier, @@ -20,7 +23,7 @@ use crate::syntax::stmt::{parse_statement, semi, StatementContext, STMT_RECOVERY use crate::syntax::typescript::ts_parse_error::ts_only_syntax_error; use crate::syntax::typescript::{ parse_ts_enum_declaration, parse_ts_import_equals_declaration_rest, - parse_ts_interface_declaration, skip_ts_decorators, + parse_ts_interface_declaration, }; use crate::JsSyntaxFeature::TypeScript; use crate::{Absent, JsParser, ParseRecovery, ParsedSyntax, Present}; @@ -115,8 +118,54 @@ fn parse_module_item(p: &mut JsParser) -> ParsedSyntax { } T![export] => parse_export(p), T![@] => { - skip_ts_decorators(p); - parse_module_item(p) + let decorator_list = parse_decorators(p); + + match p.cur() { + T![class] => { + // test decorator_class_declaration_top_level + // @decorator + // class Foo { } + // @first.field @second @(() => decorator)() + // class Bar {} + parse_class_declaration(p, decorator_list, StatementContext::StatementList) + } + T![abstract] if is_at_ts_abstract_class_declaration(p, LineBreak::DoCheck) => { + // test ts decorator_abstract_class_declaration_top_level + // @decorator abstract class A {} + // @first.field @second @(() => decorator)() + // abstract class Bar {} + TypeScript.parse_exclusive_syntax( + p, + |p| { + parse_class_declaration( + p, + decorator_list, + StatementContext::StatementList, + ) + }, + |p, abstract_class| { + ts_only_syntax_error(p, "abstract classes", abstract_class.range(p)) + }, + ) + } + _ => { + // test_err decorator_class_declaration_top_level + // @decorator + // let a; + // @decorator1 @decorator2 + // function Foo() { } + decorator_list + .add_diagnostic_if_present(p, |p, range| { + p.err_builder("Decorators are not valid here.", range) + }) + .map(|mut marker| { + marker.change_kind(p, JS_BOGUS_STATEMENT); + marker + }); + + parse_module_item(p) + } + } } _ => parse_statement(p, StatementContext::StatementList), } @@ -1182,7 +1231,7 @@ fn parse_export_default_declaration_clause( let declaration = match kind { ExportDefaultDeclarationKind::Function => parse_function_export_default_declaration(p), - ExportDefaultDeclarationKind::Class => parse_class_export_default_declaration(p), + ExportDefaultDeclarationKind::Class => parse_class_export_default_declaration(p, Absent), // test ts ts_export_default_interface // export default interface A { } @@ -1326,6 +1375,9 @@ fn parse_ts_export_declare_clause(p: &mut JsParser, stmt_start: TextSize) -> Par let m = p.start(); p.expect(T![declare]); p.with_state(EnterAmbientContext, |p| { + // test_err ts ts_export_declare + // export declare @decorator class D {} + // export declare @decorator abstract class D {} parse_declaration_clause(p, stmt_start).or_add_diagnostic(p, expected_declaration) }); diff --git a/crates/rome_js_parser/src/syntax/stmt.rs b/crates/rome_js_parser/src/syntax/stmt.rs index d686badfad2..972dc6bf218 100644 --- a/crates/rome_js_parser/src/syntax/stmt.rs +++ b/crates/rome_js_parser/src/syntax/stmt.rs @@ -14,7 +14,7 @@ use crate::state::{ LabelledItem, StrictMode as StrictModeState, WithLabel, }; use crate::syntax::assignment::expression_to_assignment_pattern; -use crate::syntax::class::{parse_class_declaration, parse_initializer_clause}; +use crate::syntax::class::{parse_class_declaration, parse_decorators, parse_initializer_clause}; use crate::syntax::expr::{ is_at_expression, is_at_identifier, is_nth_at_identifier, parse_assignment_expression_or_higher, parse_expression_or_recover_to_next_statement, @@ -221,17 +221,63 @@ pub(crate) fn parse_statement(p: &mut JsParser, context: StatementContext) -> Pa parse_function_declaration(p, context) } // class and abstract class - T![class] => parse_class_declaration(p, context), + T![class] => parse_class_declaration(p, Absent, context), T![@] => { - skip_ts_decorators(p); - parse_statement(p, context) + let decorator_list = parse_decorators(p); + + match p.cur() { + T![class] => { + // test decorator_class_declaration + // function foo() { + // @decorator + // class Foo { } + // @first.field @second @(() => decorator)() + // class Bar {} + // } + parse_class_declaration(p, decorator_list, context) + } + T![abstract] if is_at_ts_abstract_class_declaration(p, LineBreak::DoCheck) => { + // test ts decorator_abstract_class_declaration + // function foo() { + // @decorator abstract class A {} + // @first.field @second @(() => decorator)() + // abstract class Bar {} + // } + TypeScript.parse_exclusive_syntax( + p, + |p| parse_class_declaration(p, decorator_list, context), + |p, abstract_class| { + ts_only_syntax_error(p, "abstract classes", abstract_class.range(p)) + }, + ) + } + _ => { + // test_err decorator_class_declaration + // function bar() { + // @decorator + // let a; + // @decorator @decorator2 + // function Foo() { } + // } + decorator_list + .add_diagnostic_if_present(p, |p, range| { + p.err_builder("Decorators are not valid here.", range) + }) + .map(|mut marker| { + marker.change_kind(p, JS_BOGUS_STATEMENT); + marker + }); + + parse_statement(p, context) + } + } } T![abstract] if is_at_ts_abstract_class_declaration(p, LineBreak::DoCheck) => { // test_err abstract_class_in_js // abstract class A {} TypeScript.parse_exclusive_syntax( p, - |p| parse_class_declaration(p, context), + |p| parse_class_declaration(p, Absent, context), |p, abstract_class| { ts_only_syntax_error(p, "abstract classes", abstract_class.range(p)) }, diff --git a/crates/rome_js_parser/src/syntax/typescript.rs b/crates/rome_js_parser/src/syntax/typescript.rs index 8574c336cad..6e711aac5a8 100644 --- a/crates/rome_js_parser/src/syntax/typescript.rs +++ b/crates/rome_js_parser/src/syntax/typescript.rs @@ -5,7 +5,7 @@ mod statement; pub mod ts_parse_error; mod types; -use crate::syntax::expr::{parse_identifier, parse_lhs_expr, parse_unary_expr, ExpressionContext}; +use crate::syntax::expr::{parse_identifier, parse_unary_expr, ExpressionContext}; use crate::syntax::js_parse_error::expected_expression; use crate::syntax::typescript::ts_parse_error::expected_ts_type; @@ -243,43 +243,3 @@ fn eat_members_separator(p: &mut JsParser, parent: MemberParent) { } } } - -// test ts ts_class_decorator -// function test() {} -// @test -// class Test {} -// @test.a?.c @test @test -// class Test2{} -// @test export class Test {} -// @test export default class Test {} - -/// Skips over any TypeScript decorator syntax. -pub(crate) fn skip_ts_decorators(p: &mut JsParser) { - if !p.at(T![@]) { - return; - } - - p.parse_as_skipped_trivia_tokens(|p| { - while p.at(T![@]) { - parse_decorator(p).ok(); - } - }); -} - -fn parse_decorator(p: &mut JsParser) -> ParsedSyntax { - if p.at(T![@]) { - let m = p.start(); - p.bump(T![@]); - // test ts ts_decorator_call_expression_with_arrow - // export class Foo { - // @Decorator((val) => val) - // badField!: number - // } - parse_lhs_expr(p, ExpressionContext::default().and_in_ts_decorator(true)) - .or_add_diagnostic(p, expected_expression); - - Present(m.complete(p, JS_BOGUS)) - } else { - Absent - } -} diff --git a/crates/rome_js_parser/src/syntax/typescript/statement.rs b/crates/rome_js_parser/src/syntax/typescript/statement.rs index 98867023e68..cb582e20616 100644 --- a/crates/rome_js_parser/src/syntax/typescript/statement.rs +++ b/crates/rome_js_parser/src/syntax/typescript/statement.rs @@ -228,6 +228,9 @@ pub(crate) fn parse_ts_declare_statement(p: &mut JsParser) -> ParsedSyntax { p.expect(T![declare]); p.with_state(EnterAmbientContext, |p| { + // test_err ts ts_declare_const_initializer + // declare @decorator class D {} + // declare @decorator abstract class D {} parse_declaration_clause(p, stmt_start_pos) .expect("Expected a declaration as guaranteed by is_at_ts_declare_statement") }); diff --git a/crates/rome_js_parser/src/tests.rs b/crates/rome_js_parser/src/tests.rs index c7c11eb410a..dbcd2cb1ae9 100644 --- a/crates/rome_js_parser/src/tests.rs +++ b/crates/rome_js_parser/src/tests.rs @@ -388,3 +388,14 @@ fn diagnostics_print_correctly() { ); } } + +#[ignore] +#[test] +pub fn quick_test() { + let code = r"@1 + 2 class MyClass {}; +"; + let root = parse(code, SourceType::ts()); + let syntax = root.syntax(); + + dbg!(syntax); +} diff --git a/crates/rome_js_parser/test_data/inline/err/abstract_class_in_js.rast b/crates/rome_js_parser/test_data/inline/err/abstract_class_in_js.rast index 9eae749902e..15740d1b41e 100644 --- a/crates/rome_js_parser/test_data/inline/err/abstract_class_in_js.rast +++ b/crates/rome_js_parser/test_data/inline/err/abstract_class_in_js.rast @@ -4,6 +4,7 @@ JsModule { items: JsModuleItemList [ JsBogusStatement { items: [ + JsDecoratorList [], ABSTRACT_KW@0..9 "abstract" [] [Whitespace(" ")], CLASS_KW@9..15 "class" [] [Whitespace(" ")], JsIdentifierBinding { @@ -23,13 +24,14 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..19 0: JS_BOGUS_STATEMENT@0..19 - 0: ABSTRACT_KW@0..9 "abstract" [] [Whitespace(" ")] - 1: CLASS_KW@9..15 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@15..17 + 0: JS_DECORATOR_LIST@0..0 + 1: ABSTRACT_KW@0..9 "abstract" [] [Whitespace(" ")] + 2: CLASS_KW@9..15 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@15..17 0: IDENT@15..17 "A" [] [Whitespace(" ")] - 3: L_CURLY@17..18 "{" [] [] - 4: JS_CLASS_MEMBER_LIST@18..18 - 5: R_CURLY@18..19 "}" [] [] + 4: L_CURLY@17..18 "{" [] [] + 5: JS_CLASS_MEMBER_LIST@18..18 + 6: R_CURLY@18..19 "}" [] [] 3: EOF@19..20 "" [Newline("\n")] [] -- abstract_class_in_js.js:1:1 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ diff --git a/crates/rome_js_parser/test_data/inline/err/await_in_static_initialization_block_member.rast b/crates/rome_js_parser/test_data/inline/err/await_in_static_initialization_block_member.rast index 750156c507c..5e61bd1e6c8 100644 --- a/crates/rome_js_parser/test_data/inline/err/await_in_static_initialization_block_member.rast +++ b/crates/rome_js_parser/test_data/inline/err/await_in_static_initialization_block_member.rast @@ -3,6 +3,7 @@ JsScript { directives: JsDirectiveList [], statements: JsStatementList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@0..16 "class" [Comments("// SCRIPT"), Newline("\n")] [Whitespace(" ")], id: JsIdentifierBinding { @@ -36,6 +37,7 @@ JsScript { r_curly_token: R_CURLY@38..39 "}" [] [], }, JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@39..46 "class" [Newline("\n")] [Whitespace(" ")], id: JsIdentifierBinding { @@ -76,15 +78,16 @@ JsScript { 1: JS_DIRECTIVE_LIST@0..0 2: JS_STATEMENT_LIST@0..72 0: JS_CLASS_DECLARATION@0..39 - 0: (empty) - 1: CLASS_KW@0..16 "class" [Comments("// SCRIPT"), Newline("\n")] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@16..18 + 0: JS_DECORATOR_LIST@0..0 + 1: (empty) + 2: CLASS_KW@0..16 "class" [Comments("// SCRIPT"), Newline("\n")] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@16..18 0: IDENT@16..18 "A" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@18..20 "{" [] [Whitespace(" ")] - 7: JS_CLASS_MEMBER_LIST@20..38 + 6: (empty) + 7: L_CURLY@18..20 "{" [] [Whitespace(" ")] + 8: JS_CLASS_MEMBER_LIST@20..38 0: JS_STATIC_INITIALIZATION_BLOCK_CLASS_MEMBER@20..38 0: STATIC_KW@20..27 "static" [] [Whitespace(" ")] 1: L_CURLY@27..29 "{" [] [Whitespace(" ")] @@ -95,17 +98,18 @@ JsScript { 0: IDENT@29..34 "await" [] [] 1: SEMICOLON@34..36 ";" [] [Whitespace(" ")] 3: R_CURLY@36..38 "}" [] [Whitespace(" ")] - 8: R_CURLY@38..39 "}" [] [] + 9: R_CURLY@38..39 "}" [] [] 1: JS_CLASS_DECLARATION@39..72 - 0: (empty) - 1: CLASS_KW@39..46 "class" [Newline("\n")] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@46..48 + 0: JS_DECORATOR_LIST@39..39 + 1: (empty) + 2: CLASS_KW@39..46 "class" [Newline("\n")] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@46..48 0: IDENT@46..48 "B" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@48..50 "{" [] [Whitespace(" ")] - 7: JS_CLASS_MEMBER_LIST@50..71 + 6: (empty) + 7: L_CURLY@48..50 "{" [] [Whitespace(" ")] + 8: JS_CLASS_MEMBER_LIST@50..71 0: JS_STATIC_INITIALIZATION_BLOCK_CLASS_MEMBER@50..71 0: STATIC_KW@50..57 "static" [] [Whitespace(" ")] 1: L_CURLY@57..59 "{" [] [Whitespace(" ")] @@ -117,7 +121,7 @@ JsScript { 0: JS_NUMBER_LITERAL@65..67 "10" [] [] 1: SEMICOLON@67..69 ";" [] [Whitespace(" ")] 3: R_CURLY@69..71 "}" [] [Whitespace(" ")] - 8: R_CURLY@71..72 "}" [] [] + 9: R_CURLY@71..72 "}" [] [] 3: EOF@72..73 "" [Newline("\n")] [] -- await_in_static_initialization_block_member.js:2:20 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ diff --git a/crates/rome_js_parser/test_data/inline/err/block_stmt_in_class.rast b/crates/rome_js_parser/test_data/inline/err/block_stmt_in_class.rast index 2751a376b5b..6817eb0a981 100644 --- a/crates/rome_js_parser/test_data/inline/err/block_stmt_in_class.rast +++ b/crates/rome_js_parser/test_data/inline/err/block_stmt_in_class.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@0..6 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -35,18 +36,19 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..11 0: JS_CLASS_DECLARATION@0..10 - 0: (empty) - 1: CLASS_KW@0..6 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@6..7 + 0: JS_DECORATOR_LIST@0..0 + 1: (empty) + 2: CLASS_KW@0..6 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@6..7 0: IDENT@6..7 "S" [] [] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@7..8 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@8..9 + 6: (empty) + 7: L_CURLY@7..8 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@8..9 0: JS_BOGUS_MEMBER@8..9 0: L_CURLY@8..9 "{" [] [] - 8: R_CURLY@9..10 "}" [] [] + 9: R_CURLY@9..10 "}" [] [] 1: JS_BOGUS_STATEMENT@10..11 0: R_CURLY@10..11 "}" [] [] 3: EOF@11..12 "" [Newline("\n")] [] diff --git a/crates/rome_js_parser/test_data/inline/err/class_constructor_parameter.rast b/crates/rome_js_parser/test_data/inline/err/class_constructor_parameter.rast index 6604d789917..c244f648ad3 100644 --- a/crates/rome_js_parser/test_data/inline/err/class_constructor_parameter.rast +++ b/crates/rome_js_parser/test_data/inline/err/class_constructor_parameter.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@0..6 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -60,15 +61,16 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..39 0: JS_CLASS_DECLARATION@0..39 - 0: (empty) - 1: CLASS_KW@0..6 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@6..8 + 0: JS_DECORATOR_LIST@0..0 + 1: (empty) + 2: CLASS_KW@0..6 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@6..8 0: IDENT@6..8 "B" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@8..10 "{" [] [Whitespace(" ")] - 7: JS_CLASS_MEMBER_LIST@10..38 + 6: (empty) + 7: L_CURLY@8..10 "{" [] [Whitespace(" ")] + 8: JS_CLASS_MEMBER_LIST@10..38 0: JS_CONSTRUCTOR_CLASS_MEMBER@10..38 0: JS_CONSTRUCTOR_MODIFIER_LIST@10..10 1: JS_LITERAL_MEMBER_NAME@10..21 @@ -92,7 +94,7 @@ JsModule { 1: JS_DIRECTIVE_LIST@36..36 2: JS_STATEMENT_LIST@36..36 3: R_CURLY@36..38 "}" [] [Whitespace(" ")] - 8: R_CURLY@38..39 "}" [] [] + 9: R_CURLY@38..39 "}" [] [] 3: EOF@39..40 "" [Newline("\n")] [] -- class_constructor_parameter.js:1:23 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ diff --git a/crates/rome_js_parser/test_data/inline/err/class_constructor_parameter_readonly.rast b/crates/rome_js_parser/test_data/inline/err/class_constructor_parameter_readonly.rast index ea676cfe862..7f05317c49a 100644 --- a/crates/rome_js_parser/test_data/inline/err/class_constructor_parameter_readonly.rast +++ b/crates/rome_js_parser/test_data/inline/err/class_constructor_parameter_readonly.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@0..6 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -60,15 +61,16 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..38 0: JS_CLASS_DECLARATION@0..38 - 0: (empty) - 1: CLASS_KW@0..6 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@6..8 + 0: JS_DECORATOR_LIST@0..0 + 1: (empty) + 2: CLASS_KW@0..6 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@6..8 0: IDENT@6..8 "B" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@8..10 "{" [] [Whitespace(" ")] - 7: JS_CLASS_MEMBER_LIST@10..37 + 6: (empty) + 7: L_CURLY@8..10 "{" [] [Whitespace(" ")] + 8: JS_CLASS_MEMBER_LIST@10..37 0: JS_CONSTRUCTOR_CLASS_MEMBER@10..37 0: JS_CONSTRUCTOR_MODIFIER_LIST@10..10 1: JS_LITERAL_MEMBER_NAME@10..21 @@ -92,7 +94,7 @@ JsModule { 1: JS_DIRECTIVE_LIST@35..35 2: JS_STATEMENT_LIST@35..35 3: R_CURLY@35..37 "}" [] [Whitespace(" ")] - 8: R_CURLY@37..38 "}" [] [] + 9: R_CURLY@37..38 "}" [] [] 3: EOF@38..39 "" [Newline("\n")] [] -- class_constructor_parameter_readonly.js:1:23 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ diff --git a/crates/rome_js_parser/test_data/inline/err/class_decl_err.rast b/crates/rome_js_parser/test_data/inline/err/class_decl_err.rast index 77521e5b5cf..982a57fd199 100644 --- a/crates/rome_js_parser/test_data/inline/err/class_decl_err.rast +++ b/crates/rome_js_parser/test_data/inline/err/class_decl_err.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@0..6 "class" [] [Whitespace(" ")], id: missing (required), @@ -14,6 +15,7 @@ JsModule { r_curly_token: R_CURLY@7..8 "}" [] [], }, JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@8..15 "class" [Newline("\n")] [Whitespace(" ")], id: missing (required), @@ -33,6 +35,7 @@ JsModule { r_curly_token: R_CURLY@28..29 "}" [] [], }, JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@29..36 "class" [Newline("\n")] [Whitespace(" ")], id: JsIdentifierBinding { @@ -66,6 +69,7 @@ JsModule { ], }, JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@50..57 "class" [Newline("\n")] [Whitespace(" ")], id: missing (required), @@ -89,40 +93,43 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..67 0: JS_CLASS_DECLARATION@0..8 - 0: (empty) - 1: CLASS_KW@0..6 "class" [] [Whitespace(" ")] - 2: (empty) + 0: JS_DECORATOR_LIST@0..0 + 1: (empty) + 2: CLASS_KW@0..6 "class" [] [Whitespace(" ")] 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@6..7 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@7..7 - 8: R_CURLY@7..8 "}" [] [] + 6: (empty) + 7: L_CURLY@6..7 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@7..7 + 9: R_CURLY@7..8 "}" [] [] 1: JS_CLASS_DECLARATION@8..29 - 0: (empty) - 1: CLASS_KW@8..15 "class" [Newline("\n")] [Whitespace(" ")] - 2: (empty) + 0: JS_DECORATOR_LIST@8..8 + 1: (empty) + 2: CLASS_KW@8..15 "class" [Newline("\n")] [Whitespace(" ")] 3: (empty) - 4: JS_EXTENDS_CLAUSE@15..27 + 4: (empty) + 5: JS_EXTENDS_CLAUSE@15..27 0: EXTENDS_KW@15..23 "extends" [] [Whitespace(" ")] 1: JS_IDENTIFIER_EXPRESSION@23..27 0: JS_REFERENCE_IDENTIFIER@23..27 0: IDENT@23..27 "bar" [] [Whitespace(" ")] 2: (empty) - 5: (empty) - 6: L_CURLY@27..28 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@28..28 - 8: R_CURLY@28..29 "}" [] [] + 6: (empty) + 7: L_CURLY@27..28 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@28..28 + 9: R_CURLY@28..29 "}" [] [] 2: JS_CLASS_DECLARATION@29..49 - 0: (empty) - 1: CLASS_KW@29..36 "class" [Newline("\n")] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@36..40 + 0: JS_DECORATOR_LIST@29..29 + 1: (empty) + 2: CLASS_KW@29..36 "class" [Newline("\n")] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@36..40 0: IDENT@36..40 "foo" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@40..42 "{" [] [Whitespace(" ")] - 7: JS_CLASS_MEMBER_LIST@42..47 + 6: (empty) + 7: L_CURLY@40..42 "{" [] [Whitespace(" ")] + 8: JS_CLASS_MEMBER_LIST@42..47 0: JS_PROPERTY_CLASS_MEMBER@42..46 0: JS_PROPERTY_MODIFIER_LIST@42..42 1: JS_LITERAL_MEMBER_NAME@42..46 @@ -132,22 +139,23 @@ JsModule { 4: (empty) 1: JS_BOGUS_MEMBER@46..47 0: L_CURLY@46..47 "{" [] [] - 8: R_CURLY@47..49 "}" [] [Whitespace(" ")] + 9: R_CURLY@47..49 "}" [] [Whitespace(" ")] 3: JS_BOGUS_STATEMENT@49..50 0: R_CURLY@49..50 "}" [] [] 4: JS_CLASS_DECLARATION@50..67 - 0: (empty) - 1: CLASS_KW@50..57 "class" [Newline("\n")] [Whitespace(" ")] - 2: (empty) + 0: JS_DECORATOR_LIST@50..50 + 1: (empty) + 2: CLASS_KW@50..57 "class" [Newline("\n")] [Whitespace(" ")] 3: (empty) - 4: JS_EXTENDS_CLAUSE@57..65 + 4: (empty) + 5: JS_EXTENDS_CLAUSE@57..65 0: EXTENDS_KW@57..65 "extends" [] [Whitespace(" ")] 1: (empty) 2: (empty) - 5: (empty) - 6: L_CURLY@65..66 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@66..66 - 8: R_CURLY@66..67 "}" [] [] + 6: (empty) + 7: L_CURLY@65..66 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@66..66 + 9: R_CURLY@66..67 "}" [] [] 3: EOF@67..68 "" [Newline("\n")] [] -- class_decl_err.js:1:1 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ diff --git a/crates/rome_js_parser/test_data/inline/err/class_decl_no_id.rast b/crates/rome_js_parser/test_data/inline/err/class_decl_no_id.rast index 4f38a6d7225..dd169e872b9 100644 --- a/crates/rome_js_parser/test_data/inline/err/class_decl_no_id.rast +++ b/crates/rome_js_parser/test_data/inline/err/class_decl_no_id.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@0..6 "class" [] [Whitespace(" ")], id: missing (required), @@ -14,6 +15,7 @@ JsModule { r_curly_token: R_CURLY@7..8 "}" [] [], }, JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@8..15 "class" [Newline("\n")] [Whitespace(" ")], id: missing (required), @@ -43,31 +45,33 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..30 0: JS_CLASS_DECLARATION@0..8 - 0: (empty) - 1: CLASS_KW@0..6 "class" [] [Whitespace(" ")] - 2: (empty) + 0: JS_DECORATOR_LIST@0..0 + 1: (empty) + 2: CLASS_KW@0..6 "class" [] [Whitespace(" ")] 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@6..7 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@7..7 - 8: R_CURLY@7..8 "}" [] [] + 6: (empty) + 7: L_CURLY@6..7 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@7..7 + 9: R_CURLY@7..8 "}" [] [] 1: JS_CLASS_DECLARATION@8..30 - 0: (empty) - 1: CLASS_KW@8..15 "class" [Newline("\n")] [Whitespace(" ")] - 2: (empty) + 0: JS_DECORATOR_LIST@8..8 + 1: (empty) + 2: CLASS_KW@8..15 "class" [Newline("\n")] [Whitespace(" ")] 3: (empty) 4: (empty) - 5: TS_IMPLEMENTS_CLAUSE@15..28 + 5: (empty) + 6: TS_IMPLEMENTS_CLAUSE@15..28 0: IMPLEMENTS_KW@15..26 "implements" [] [Whitespace(" ")] 1: TS_TYPE_LIST@26..28 0: TS_NAME_WITH_TYPE_ARGUMENTS@26..28 0: JS_REFERENCE_IDENTIFIER@26..28 0: IDENT@26..28 "B" [] [Whitespace(" ")] 1: (empty) - 6: L_CURLY@28..29 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@29..29 - 8: R_CURLY@29..30 "}" [] [] + 7: L_CURLY@28..29 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@29..29 + 9: R_CURLY@29..30 "}" [] [] 3: EOF@30..31 "" [Newline("\n")] [] -- class_decl_no_id.ts:1:1 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ diff --git a/crates/rome_js_parser/test_data/inline/err/class_declare_member.rast b/crates/rome_js_parser/test_data/inline/err/class_declare_member.rast index 4bfc91055be..fe80cae079a 100644 --- a/crates/rome_js_parser/test_data/inline/err/class_declare_member.rast +++ b/crates/rome_js_parser/test_data/inline/err/class_declare_member.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@0..6 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -37,22 +38,23 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..23 0: JS_CLASS_DECLARATION@0..23 - 0: (empty) - 1: CLASS_KW@0..6 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@6..8 + 0: JS_DECORATOR_LIST@0..0 + 1: (empty) + 2: CLASS_KW@0..6 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@6..8 0: IDENT@6..8 "B" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@8..10 "{" [] [Whitespace(" ")] - 7: JS_CLASS_MEMBER_LIST@10..22 + 6: (empty) + 7: L_CURLY@8..10 "{" [] [Whitespace(" ")] + 8: JS_CLASS_MEMBER_LIST@10..22 0: JS_BOGUS_MEMBER@10..22 0: TS_PROPERTY_SIGNATURE_MODIFIER_LIST@10..18 0: TS_DECLARE_MODIFIER@10..18 0: DECLARE_KW@10..18 "declare" [] [Whitespace(" ")] 1: JS_LITERAL_MEMBER_NAME@18..22 0: IDENT@18..22 "foo" [] [Whitespace(" ")] - 8: R_CURLY@22..23 "}" [] [] + 9: R_CURLY@22..23 "}" [] [] 3: EOF@23..24 "" [Newline("\n")] [] -- class_declare_member.js:1:11 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ diff --git a/crates/rome_js_parser/test_data/inline/err/class_declare_method.rast b/crates/rome_js_parser/test_data/inline/err/class_declare_method.rast index 902def958e6..85f990ae463 100644 --- a/crates/rome_js_parser/test_data/inline/err/class_declare_method.rast +++ b/crates/rome_js_parser/test_data/inline/err/class_declare_method.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@0..6 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -50,15 +51,16 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..27 0: JS_CLASS_DECLARATION@0..27 - 0: (empty) - 1: CLASS_KW@0..6 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@6..8 + 0: JS_DECORATOR_LIST@0..0 + 1: (empty) + 2: CLASS_KW@0..6 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@6..8 0: IDENT@6..8 "B" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@8..10 "{" [] [Whitespace(" ")] - 7: JS_CLASS_MEMBER_LIST@10..26 + 6: (empty) + 7: L_CURLY@8..10 "{" [] [Whitespace(" ")] + 8: JS_CLASS_MEMBER_LIST@10..26 0: JS_BOGUS_MEMBER@10..26 0: JS_BOGUS@10..18 0: TS_DECLARE_MODIFIER@10..18 @@ -74,7 +76,7 @@ JsModule { 1: JS_DIRECTIVE_LIST@24..24 2: JS_STATEMENT_LIST@24..24 3: R_CURLY@24..26 "}" [] [Whitespace(" ")] - 8: R_CURLY@26..27 "}" [] [] + 9: R_CURLY@26..27 "}" [] [] 3: EOF@27..28 "" [Newline("\n")] [] -- class_declare_method.js:1:11 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ diff --git a/crates/rome_js_parser/test_data/inline/err/class_extends_err.rast b/crates/rome_js_parser/test_data/inline/err/class_extends_err.rast index 9b364c0d7c4..3b68925fad0 100644 --- a/crates/rome_js_parser/test_data/inline/err/class_extends_err.rast +++ b/crates/rome_js_parser/test_data/inline/err/class_extends_err.rast @@ -4,6 +4,7 @@ JsModule { items: JsModuleItemList [ JsBogusStatement { items: [ + JsDecoratorList [], CLASS_KW@0..6 "class" [] [Whitespace(" ")], JsIdentifierBinding { name_token: IDENT@6..8 "A" [] [Whitespace(" ")], @@ -33,6 +34,7 @@ JsModule { }, JsBogusStatement { items: [ + JsDecoratorList [], CLASS_KW@34..41 "class" [Newline("\n")] [Whitespace(" ")], JsIdentifierBinding { name_token: IDENT@41..43 "B" [] [Whitespace(" ")], @@ -64,6 +66,7 @@ JsModule { }, JsBogusStatement { items: [ + JsDecoratorList [], CLASS_KW@62..69 "class" [Newline("\n")] [Whitespace(" ")], JsIdentifierBinding { name_token: IDENT@69..71 "C" [] [Whitespace(" ")], @@ -95,29 +98,31 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..86 0: JS_BOGUS_STATEMENT@0..34 - 0: CLASS_KW@0..6 "class" [] [Whitespace(" ")] - 1: JS_IDENTIFIER_BINDING@6..8 + 0: JS_DECORATOR_LIST@0..0 + 1: CLASS_KW@0..6 "class" [] [Whitespace(" ")] + 2: JS_IDENTIFIER_BINDING@6..8 0: IDENT@6..8 "A" [] [Whitespace(" ")] - 2: JS_EXTENDS_CLAUSE@8..20 + 3: JS_EXTENDS_CLAUSE@8..20 0: EXTENDS_KW@8..16 "extends" [] [Whitespace(" ")] 1: JS_IDENTIFIER_EXPRESSION@16..20 0: JS_REFERENCE_IDENTIFIER@16..20 0: IDENT@16..20 "bar" [] [Whitespace(" ")] 2: (empty) - 3: JS_EXTENDS_CLAUSE@20..32 + 4: JS_EXTENDS_CLAUSE@20..32 0: EXTENDS_KW@20..28 "extends" [] [Whitespace(" ")] 1: JS_IDENTIFIER_EXPRESSION@28..32 0: JS_REFERENCE_IDENTIFIER@28..32 0: IDENT@28..32 "foo" [] [Whitespace(" ")] 2: (empty) - 4: L_CURLY@32..33 "{" [] [] - 5: JS_CLASS_MEMBER_LIST@33..33 - 6: R_CURLY@33..34 "}" [] [] + 5: L_CURLY@32..33 "{" [] [] + 6: JS_CLASS_MEMBER_LIST@33..33 + 7: R_CURLY@33..34 "}" [] [] 1: JS_BOGUS_STATEMENT@34..62 - 0: CLASS_KW@34..41 "class" [Newline("\n")] [Whitespace(" ")] - 1: JS_IDENTIFIER_BINDING@41..43 + 0: JS_DECORATOR_LIST@34..34 + 1: CLASS_KW@34..41 "class" [Newline("\n")] [Whitespace(" ")] + 2: JS_IDENTIFIER_BINDING@41..43 0: IDENT@41..43 "B" [] [Whitespace(" ")] - 2: JS_BOGUS@43..60 + 3: JS_BOGUS@43..60 0: EXTENDS_KW@43..51 "extends" [] [Whitespace(" ")] 1: JS_IDENTIFIER_EXPRESSION@51..54 0: JS_REFERENCE_IDENTIFIER@51..54 @@ -127,23 +132,24 @@ JsModule { 0: JS_IDENTIFIER_EXPRESSION@56..60 0: JS_REFERENCE_IDENTIFIER@56..60 0: IDENT@56..60 "foo" [] [Whitespace(" ")] - 3: L_CURLY@60..61 "{" [] [] - 4: JS_CLASS_MEMBER_LIST@61..61 - 5: R_CURLY@61..62 "}" [] [] + 4: L_CURLY@60..61 "{" [] [] + 5: JS_CLASS_MEMBER_LIST@61..61 + 6: R_CURLY@61..62 "}" [] [] 2: JS_BOGUS_STATEMENT@62..86 - 0: CLASS_KW@62..69 "class" [Newline("\n")] [Whitespace(" ")] - 1: JS_IDENTIFIER_BINDING@69..71 + 0: JS_DECORATOR_LIST@62..62 + 1: CLASS_KW@62..69 "class" [Newline("\n")] [Whitespace(" ")] + 2: JS_IDENTIFIER_BINDING@69..71 0: IDENT@69..71 "C" [] [Whitespace(" ")] - 2: JS_BOGUS@71..84 + 3: JS_BOGUS@71..84 0: IMPLEMENTS_KW@71..82 "implements" [] [Whitespace(" ")] 1: TS_TYPE_LIST@82..84 0: TS_NAME_WITH_TYPE_ARGUMENTS@82..84 0: JS_REFERENCE_IDENTIFIER@82..84 0: IDENT@82..84 "B" [] [Whitespace(" ")] 1: (empty) - 3: L_CURLY@84..85 "{" [] [] - 4: JS_CLASS_MEMBER_LIST@85..85 - 5: R_CURLY@85..86 "}" [] [] + 4: L_CURLY@84..85 "{" [] [] + 5: JS_CLASS_MEMBER_LIST@85..85 + 6: R_CURLY@85..86 "}" [] [] 3: EOF@86..87 "" [Newline("\n")] [] -- class_extends_err.js:1:21 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ diff --git a/crates/rome_js_parser/test_data/inline/err/class_implements.rast b/crates/rome_js_parser/test_data/inline/err/class_implements.rast index 7b4a7b426ff..caa44059419 100644 --- a/crates/rome_js_parser/test_data/inline/err/class_implements.rast +++ b/crates/rome_js_parser/test_data/inline/err/class_implements.rast @@ -4,6 +4,7 @@ JsModule { items: JsModuleItemList [ JsBogusStatement { items: [ + JsDecoratorList [], CLASS_KW@0..6 "class" [] [Whitespace(" ")], JsIdentifierBinding { name_token: IDENT@6..8 "B" [] [Whitespace(" ")], @@ -35,19 +36,20 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..23 0: JS_BOGUS_STATEMENT@0..23 - 0: CLASS_KW@0..6 "class" [] [Whitespace(" ")] - 1: JS_IDENTIFIER_BINDING@6..8 + 0: JS_DECORATOR_LIST@0..0 + 1: CLASS_KW@0..6 "class" [] [Whitespace(" ")] + 2: JS_IDENTIFIER_BINDING@6..8 0: IDENT@6..8 "B" [] [Whitespace(" ")] - 2: JS_BOGUS@8..21 + 3: JS_BOGUS@8..21 0: IMPLEMENTS_KW@8..19 "implements" [] [Whitespace(" ")] 1: TS_TYPE_LIST@19..21 0: TS_NAME_WITH_TYPE_ARGUMENTS@19..21 0: JS_REFERENCE_IDENTIFIER@19..21 0: IDENT@19..21 "C" [] [Whitespace(" ")] 1: (empty) - 3: L_CURLY@21..22 "{" [] [] - 4: JS_CLASS_MEMBER_LIST@22..22 - 5: R_CURLY@22..23 "}" [] [] + 4: L_CURLY@21..22 "{" [] [] + 5: JS_CLASS_MEMBER_LIST@22..22 + 6: R_CURLY@22..23 "}" [] [] 3: EOF@23..24 "" [Newline("\n")] [] -- class_implements.js:1:9 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ diff --git a/crates/rome_js_parser/test_data/inline/err/class_in_single_statement_context.rast b/crates/rome_js_parser/test_data/inline/err/class_in_single_statement_context.rast index 07cc8c26e05..825e0b0a6b1 100644 --- a/crates/rome_js_parser/test_data/inline/err/class_in_single_statement_context.rast +++ b/crates/rome_js_parser/test_data/inline/err/class_in_single_statement_context.rast @@ -11,6 +11,7 @@ JsModule { r_paren_token: R_PAREN@8..10 ")" [] [Whitespace(" ")], consequent: JsBogusStatement { items: [ + JsDecoratorList [], CLASS_KW@10..16 "class" [] [Whitespace(" ")], JsIdentifierBinding { name_token: IDENT@16..18 "A" [] [Whitespace(" ")], @@ -37,12 +38,13 @@ JsModule { 0: TRUE_KW@4..8 "true" [] [] 3: R_PAREN@8..10 ")" [] [Whitespace(" ")] 4: JS_BOGUS_STATEMENT@10..20 - 0: CLASS_KW@10..16 "class" [] [Whitespace(" ")] - 1: JS_IDENTIFIER_BINDING@16..18 + 0: JS_DECORATOR_LIST@10..10 + 1: CLASS_KW@10..16 "class" [] [Whitespace(" ")] + 2: JS_IDENTIFIER_BINDING@16..18 0: IDENT@16..18 "A" [] [Whitespace(" ")] - 2: L_CURLY@18..19 "{" [] [] - 3: JS_CLASS_MEMBER_LIST@19..19 - 4: R_CURLY@19..20 "}" [] [] + 3: L_CURLY@18..19 "{" [] [] + 4: JS_CLASS_MEMBER_LIST@19..19 + 5: R_CURLY@19..20 "}" [] [] 5: (empty) 3: EOF@20..21 "" [Newline("\n")] [] -- diff --git a/crates/rome_js_parser/test_data/inline/err/class_invalid_modifiers.rast b/crates/rome_js_parser/test_data/inline/err/class_invalid_modifiers.rast index baa2426931e..ebea082ffbb 100644 --- a/crates/rome_js_parser/test_data/inline/err/class_invalid_modifiers.rast +++ b/crates/rome_js_parser/test_data/inline/err/class_invalid_modifiers.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@0..6 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -40,6 +41,7 @@ JsModule { r_curly_token: R_CURLY@26..27 "}" [] [], }, JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@27..34 "class" [Newline("\n")] [Whitespace(" ")], id: JsIdentifierBinding { @@ -80,6 +82,7 @@ JsModule { r_curly_token: R_CURLY@61..62 "}" [] [], }, JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@62..69 "class" [Newline("\n")] [Whitespace(" ")], id: JsIdentifierBinding { @@ -127,15 +130,16 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..92 0: JS_CLASS_DECLARATION@0..27 - 0: (empty) - 1: CLASS_KW@0..6 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@6..8 + 0: JS_DECORATOR_LIST@0..0 + 1: (empty) + 2: CLASS_KW@0..6 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@6..8 0: IDENT@6..8 "A" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@8..10 "{" [] [Whitespace(" ")] - 7: JS_CLASS_MEMBER_LIST@10..26 + 6: (empty) + 7: L_CURLY@8..10 "{" [] [Whitespace(" ")] + 8: JS_CLASS_MEMBER_LIST@10..26 0: JS_BOGUS_MEMBER@10..26 0: JS_METHOD_MODIFIER_LIST@10..17 0: TS_ACCESSIBILITY_MODIFIER@10..17 @@ -151,17 +155,18 @@ JsModule { 1: JS_DIRECTIVE_LIST@24..24 2: JS_STATEMENT_LIST@24..24 3: R_CURLY@24..26 "}" [] [Whitespace(" ")] - 8: R_CURLY@26..27 "}" [] [] + 9: R_CURLY@26..27 "}" [] [] 1: JS_CLASS_DECLARATION@27..62 - 0: (empty) - 1: CLASS_KW@27..34 "class" [Newline("\n")] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@34..36 + 0: JS_DECORATOR_LIST@27..27 + 1: (empty) + 2: CLASS_KW@27..34 "class" [Newline("\n")] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@34..36 0: IDENT@34..36 "B" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@36..38 "{" [] [Whitespace(" ")] - 7: JS_CLASS_MEMBER_LIST@38..61 + 6: (empty) + 7: L_CURLY@36..38 "{" [] [Whitespace(" ")] + 8: JS_CLASS_MEMBER_LIST@38..61 0: JS_BOGUS_MEMBER@38..61 0: JS_METHOD_MODIFIER_LIST@38..52 0: JS_STATIC_MODIFIER@38..45 @@ -179,17 +184,18 @@ JsModule { 1: JS_DIRECTIVE_LIST@59..59 2: JS_STATEMENT_LIST@59..59 3: R_CURLY@59..61 "}" [] [Whitespace(" ")] - 8: R_CURLY@61..62 "}" [] [] + 9: R_CURLY@61..62 "}" [] [] 2: JS_CLASS_DECLARATION@62..92 - 0: (empty) - 1: CLASS_KW@62..69 "class" [Newline("\n")] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@69..71 + 0: JS_DECORATOR_LIST@62..62 + 1: (empty) + 2: CLASS_KW@62..69 "class" [Newline("\n")] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@69..71 0: IDENT@69..71 "C" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@71..73 "{" [] [Whitespace(" ")] - 7: JS_CLASS_MEMBER_LIST@73..91 + 6: (empty) + 7: L_CURLY@71..73 "{" [] [Whitespace(" ")] + 8: JS_CLASS_MEMBER_LIST@73..91 0: JS_BOGUS_MEMBER@73..91 0: JS_BOGUS@73..82 0: JS_ACCESSOR_MODIFIER@73..82 @@ -205,7 +211,7 @@ JsModule { 1: JS_DIRECTIVE_LIST@89..89 2: JS_STATEMENT_LIST@89..89 3: R_CURLY@89..91 "}" [] [Whitespace(" ")] - 8: R_CURLY@91..92 "}" [] [] + 9: R_CURLY@91..92 "}" [] [] 3: EOF@92..93 "" [Newline("\n")] [] -- class_invalid_modifiers.js:1:11 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ diff --git a/crates/rome_js_parser/test_data/inline/err/class_member_method_parameters.rast b/crates/rome_js_parser/test_data/inline/err/class_member_method_parameters.rast index f852eb85c05..d73262ea678 100644 --- a/crates/rome_js_parser/test_data/inline/err/class_member_method_parameters.rast +++ b/crates/rome_js_parser/test_data/inline/err/class_member_method_parameters.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@0..6 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -68,15 +69,16 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..20 0: JS_CLASS_DECLARATION@0..20 - 0: (empty) - 1: CLASS_KW@0..6 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@6..8 + 0: JS_DECORATOR_LIST@0..0 + 1: (empty) + 2: CLASS_KW@0..6 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@6..8 0: IDENT@6..8 "B" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@8..10 "{" [] [Whitespace(" ")] - 7: JS_CLASS_MEMBER_LIST@10..20 + 6: (empty) + 7: L_CURLY@8..10 "{" [] [Whitespace(" ")] + 8: JS_CLASS_MEMBER_LIST@10..20 0: JS_METHOD_CLASS_MEMBER@10..20 0: JS_METHOD_MODIFIER_LIST@10..10 1: (empty) @@ -109,7 +111,7 @@ JsModule { 2: (empty) 7: (empty) 8: (empty) - 8: (empty) + 9: (empty) 3: EOF@20..21 "" [Newline("\n")] [] -- class_member_method_parameters.js:1:17 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ diff --git a/crates/rome_js_parser/test_data/inline/err/class_member_modifier.rast b/crates/rome_js_parser/test_data/inline/err/class_member_modifier.rast index 78d8757320d..f6baa9df933 100644 --- a/crates/rome_js_parser/test_data/inline/err/class_member_modifier.rast +++ b/crates/rome_js_parser/test_data/inline/err/class_member_modifier.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@0..6 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -38,15 +39,16 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..25 0: JS_CLASS_DECLARATION@0..25 - 0: (empty) - 1: CLASS_KW@0..6 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@6..8 + 0: JS_DECORATOR_LIST@0..0 + 1: (empty) + 2: CLASS_KW@0..6 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@6..8 0: IDENT@6..8 "A" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@8..10 "{" [] [Whitespace(" ")] - 7: JS_CLASS_MEMBER_LIST@10..24 + 6: (empty) + 7: L_CURLY@8..10 "{" [] [Whitespace(" ")] + 8: JS_CLASS_MEMBER_LIST@10..24 0: JS_BOGUS_MEMBER@10..24 0: TS_PROPERTY_SIGNATURE_MODIFIER_LIST@10..19 0: TS_ABSTRACT_MODIFIER@10..19 @@ -54,7 +56,7 @@ JsModule { 1: JS_LITERAL_MEMBER_NAME@19..22 0: IDENT@19..22 "foo" [] [] 2: SEMICOLON@22..24 ";" [] [Whitespace(" ")] - 8: R_CURLY@24..25 "}" [] [] + 9: R_CURLY@24..25 "}" [] [] 3: EOF@25..26 "" [Newline("\n")] [] -- class_member_modifier.js:1:11 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ diff --git a/crates/rome_js_parser/test_data/inline/err/class_member_static_accessor_precedence.rast b/crates/rome_js_parser/test_data/inline/err/class_member_static_accessor_precedence.rast index 5e6b2604074..50d3c9cce7b 100644 --- a/crates/rome_js_parser/test_data/inline/err/class_member_static_accessor_precedence.rast +++ b/crates/rome_js_parser/test_data/inline/err/class_member_static_accessor_precedence.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@0..6 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -47,15 +48,16 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..40 0: JS_CLASS_DECLARATION@0..40 - 0: (empty) - 1: CLASS_KW@0..6 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@6..8 + 0: JS_DECORATOR_LIST@0..0 + 1: (empty) + 2: CLASS_KW@0..6 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@6..8 0: IDENT@6..8 "A" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@8..9 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@9..38 + 6: (empty) + 7: L_CURLY@8..9 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@9..38 0: JS_BOGUS_MEMBER@9..38 0: JS_PROPERTY_MODIFIER_LIST@9..30 0: JS_ACCESSOR_MODIFIER@9..23 @@ -69,7 +71,7 @@ JsModule { 1: JS_NUMBER_LITERAL_EXPRESSION@36..37 0: JS_NUMBER_LITERAL@36..37 "1" [] [] 3: SEMICOLON@37..38 ";" [] [] - 8: R_CURLY@38..40 "}" [Newline("\n")] [] + 9: R_CURLY@38..40 "}" [Newline("\n")] [] 3: EOF@40..41 "" [Newline("\n")] [] -- class_member_static_accessor_precedence.js:2:14 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ diff --git a/crates/rome_js_parser/test_data/inline/err/class_property_initializer.rast b/crates/rome_js_parser/test_data/inline/err/class_property_initializer.rast index b45fb9b33c1..673b4389d2d 100644 --- a/crates/rome_js_parser/test_data/inline/err/class_property_initializer.rast +++ b/crates/rome_js_parser/test_data/inline/err/class_property_initializer.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@0..6 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -37,15 +38,16 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..21 0: JS_CLASS_DECLARATION@0..21 - 0: (empty) - 1: CLASS_KW@0..6 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@6..8 + 0: JS_DECORATOR_LIST@0..0 + 1: (empty) + 2: CLASS_KW@0..6 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@6..8 0: IDENT@6..8 "B" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@8..10 "{" [] [Whitespace(" ")] - 7: JS_CLASS_MEMBER_LIST@10..20 + 6: (empty) + 7: L_CURLY@8..10 "{" [] [Whitespace(" ")] + 8: JS_CLASS_MEMBER_LIST@10..20 0: JS_PROPERTY_CLASS_MEMBER@10..20 0: JS_PROPERTY_MODIFIER_LIST@10..10 1: JS_LITERAL_MEMBER_NAME@10..16 @@ -55,7 +57,7 @@ JsModule { 0: EQ@16..18 "=" [] [Whitespace(" ")] 1: (empty) 4: SEMICOLON@18..20 ";" [] [Whitespace(" ")] - 8: R_CURLY@20..21 "}" [] [] + 9: R_CURLY@20..21 "}" [] [] 3: EOF@21..22 "" [Newline("\n")] [] -- class_property_initializer.js:1:19 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ diff --git a/crates/rome_js_parser/test_data/inline/err/class_yield_property_initializer.rast b/crates/rome_js_parser/test_data/inline/err/class_yield_property_initializer.rast index 78326028a60..1fda3e817d5 100644 --- a/crates/rome_js_parser/test_data/inline/err/class_yield_property_initializer.rast +++ b/crates/rome_js_parser/test_data/inline/err/class_yield_property_initializer.rast @@ -21,6 +21,7 @@ JsScript { directives: JsDirectiveList [], statements: JsStatementList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@34..43 "class" [Newline("\n"), Whitespace(" ")] [Whitespace(" ")], id: JsIdentifierBinding { @@ -83,15 +84,16 @@ JsScript { 1: JS_DIRECTIVE_LIST@34..34 2: JS_STATEMENT_LIST@34..68 0: JS_CLASS_DECLARATION@34..68 - 0: (empty) - 1: CLASS_KW@34..43 "class" [Newline("\n"), Whitespace(" ")] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@43..45 + 0: JS_DECORATOR_LIST@34..34 + 1: (empty) + 2: CLASS_KW@34..43 "class" [Newline("\n"), Whitespace(" ")] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@43..45 0: IDENT@43..45 "A" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@45..46 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@46..64 + 6: (empty) + 7: L_CURLY@45..46 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@46..64 0: JS_PROPERTY_CLASS_MEMBER@46..64 0: JS_PROPERTY_MODIFIER_LIST@46..46 1: JS_LITERAL_MEMBER_NAME@46..56 @@ -103,7 +105,7 @@ JsScript { 0: JS_BOGUS@58..63 0: IDENT@58..63 "yield" [] [] 4: SEMICOLON@63..64 ";" [] [] - 8: R_CURLY@64..68 "}" [Newline("\n"), Whitespace(" ")] [] + 9: R_CURLY@64..68 "}" [Newline("\n"), Whitespace(" ")] [] 3: R_CURLY@68..70 "}" [Newline("\n")] [] 3: EOF@70..71 "" [Newline("\n")] [] -- diff --git a/crates/rome_js_parser/test_data/inline/err/decorator.rast b/crates/rome_js_parser/test_data/inline/err/decorator.rast new file mode 100644 index 00000000000..66622f336d0 --- /dev/null +++ b/crates/rome_js_parser/test_data/inline/err/decorator.rast @@ -0,0 +1,1835 @@ +JsModule { + interpreter_token: missing (optional), + directives: JsDirectiveList [], + items: JsModuleItemList [ + JsClassDeclaration { + decorators: JsDecoratorList [ + JsDecorator { + at_token: AT@0..1 "@" [] [], + expression: JsBogusExpression { + items: [ + JS_STRING_LITERAL@1..9 "'dsads'" [] [Whitespace(" ")], + ], + }, + }, + ], + abstract_token: missing (optional), + class_token: CLASS_KW@9..15 "class" [] [Whitespace(" ")], + id: JsIdentifierBinding { + name_token: IDENT@15..23 "MyClass" [] [Whitespace(" ")], + }, + type_parameters: missing (optional), + extends_clause: missing (optional), + implements_clause: missing (optional), + l_curly_token: L_CURLY@23..24 "{" [] [], + members: JsClassMemberList [], + r_curly_token: R_CURLY@24..25 "}" [] [], + }, + JsClassDeclaration { + decorators: JsDecoratorList [ + JsDecorator { + at_token: AT@25..27 "@" [Newline("\n")] [], + expression: JsBogusExpression { + items: [ + JS_NUMBER_LITERAL@27..29 "1" [] [Whitespace(" ")], + ], + }, + }, + ], + abstract_token: missing (optional), + class_token: CLASS_KW@29..35 "class" [] [Whitespace(" ")], + id: JsIdentifierBinding { + name_token: IDENT@35..43 "MyClass" [] [Whitespace(" ")], + }, + type_parameters: missing (optional), + extends_clause: missing (optional), + implements_clause: missing (optional), + l_curly_token: L_CURLY@43..44 "{" [] [], + members: JsClassMemberList [], + r_curly_token: R_CURLY@44..45 "}" [] [], + }, + JsBogusStatement { + items: [ + JsDecorator { + at_token: AT@45..47 "@" [Newline("\n")] [], + expression: missing (required), + }, + ], + }, + JsExpressionStatement { + expression: JsPreUpdateExpression { + operator_token: PLUS2@47..49 "++" [] [], + operand: JsBogusAssignment { + items: [ + JS_NUMBER_LITERAL@49..51 "1" [] [Whitespace(" ")], + ], + }, + }, + semicolon_token: missing (optional), + }, + JsClassDeclaration { + decorators: JsDecoratorList [], + abstract_token: missing (optional), + class_token: CLASS_KW@51..57 "class" [] [Whitespace(" ")], + id: JsIdentifierBinding { + name_token: IDENT@57..65 "MyClass" [] [Whitespace(" ")], + }, + type_parameters: missing (optional), + extends_clause: missing (optional), + implements_clause: missing (optional), + l_curly_token: L_CURLY@65..66 "{" [] [], + members: JsClassMemberList [], + r_curly_token: R_CURLY@66..67 "}" [] [], + }, + JsBogusStatement { + items: [ + JsDecorator { + at_token: AT@67..69 "@" [Newline("\n")] [], + expression: JsBogusExpression { + items: [ + L_BRACK@69..70 "[" [] [], + JsArrayElementList [], + R_BRACK@70..72 "]" [] [Whitespace(" ")], + ], + }, + }, + ], + }, + JsBogusStatement { + items: [ + IN_KW@72..75 "in" [] [Whitespace(" ")], + JS_NUMBER_LITERAL@75..77 "1" [] [Whitespace(" ")], + ], + }, + JsClassDeclaration { + decorators: JsDecoratorList [], + abstract_token: missing (optional), + class_token: CLASS_KW@77..83 "class" [] [Whitespace(" ")], + id: JsIdentifierBinding { + name_token: IDENT@83..91 "MyClass" [] [Whitespace(" ")], + }, + type_parameters: missing (optional), + extends_clause: missing (optional), + implements_clause: missing (optional), + l_curly_token: L_CURLY@91..92 "{" [] [], + members: JsClassMemberList [], + r_curly_token: R_CURLY@92..93 "}" [] [], + }, + JsClassDeclaration { + decorators: JsDecoratorList [ + JsDecorator { + at_token: AT@93..95 "@" [Newline("\n")] [], + expression: JsBogusExpression { + items: [ + L_BRACK@95..96 "[" [] [], + JsArrayElementList [], + R_BRACK@96..98 "]" [] [Whitespace(" ")], + ], + }, + }, + ], + abstract_token: missing (optional), + class_token: CLASS_KW@98..104 "class" [] [Whitespace(" ")], + id: JsIdentifierBinding { + name_token: IDENT@104..112 "MyClass" [] [Whitespace(" ")], + }, + type_parameters: missing (optional), + extends_clause: missing (optional), + implements_clause: missing (optional), + l_curly_token: L_CURLY@112..113 "{" [] [], + members: JsClassMemberList [], + r_curly_token: R_CURLY@113..114 "}" [] [], + }, + JsBogusStatement { + items: [ + JsDecorator { + at_token: AT@114..116 "@" [Newline("\n")] [], + expression: JsParenthesizedExpression { + l_paren_token: L_PAREN@116..117 "(" [] [], + expression: missing (required), + r_paren_token: R_PAREN@117..119 ")" [] [Whitespace(" ")], + }, + }, + ], + }, + JsBogusStatement { + items: [ + FAT_ARROW@119..122 "=>" [] [Whitespace(" ")], + ], + }, + JsBlockStatement { + l_curly_token: L_CURLY@122..123 "{" [] [], + statements: JsStatementList [], + r_curly_token: R_CURLY@123..125 "}" [] [Whitespace(" ")], + }, + JsClassDeclaration { + decorators: JsDecoratorList [], + abstract_token: missing (optional), + class_token: CLASS_KW@125..131 "class" [] [Whitespace(" ")], + id: JsIdentifierBinding { + name_token: IDENT@131..139 "MyClass" [] [Whitespace(" ")], + }, + type_parameters: missing (optional), + extends_clause: missing (optional), + implements_clause: missing (optional), + l_curly_token: L_CURLY@139..140 "{" [] [], + members: JsClassMemberList [], + r_curly_token: R_CURLY@140..141 "}" [] [], + }, + JsBogusStatement { + items: [ + JsDecorator { + at_token: AT@141..143 "@" [Newline("\n")] [], + expression: JsBogusExpression { + items: [ + JS_NUMBER_LITERAL@143..145 "1" [] [Whitespace(" ")], + ], + }, + }, + ], + }, + JsBogusStatement { + items: [ + EQ2@145..148 "==" [] [Whitespace(" ")], + JS_NUMBER_LITERAL@148..150 "2" [] [Whitespace(" ")], + QUESTION@150..152 "?" [] [Whitespace(" ")], + TRUE_KW@152..157 "true" [] [Whitespace(" ")], + COLON@157..159 ":" [] [Whitespace(" ")], + FALSE_KW@159..165 "false" [] [Whitespace(" ")], + ], + }, + JsClassDeclaration { + decorators: JsDecoratorList [], + abstract_token: missing (optional), + class_token: CLASS_KW@165..171 "class" [] [Whitespace(" ")], + id: JsIdentifierBinding { + name_token: IDENT@171..179 "MyClass" [] [Whitespace(" ")], + }, + type_parameters: missing (optional), + extends_clause: missing (optional), + implements_clause: missing (optional), + l_curly_token: L_CURLY@179..180 "{" [] [], + members: JsClassMemberList [], + r_curly_token: R_CURLY@180..181 "}" [] [], + }, + JsBogusStatement { + items: [ + JsDecorator { + at_token: AT@181..183 "@" [Newline("\n")] [], + expression: JsBogusExpression { + items: [ + JsBogus { + items: [ + IDENT@183..189 "await" [] [Whitespace(" ")], + ], + }, + ], + }, + }, + ], + }, + JsExpressionStatement { + expression: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@189..192 "fn" [] [Whitespace(" ")], + }, + }, + semicolon_token: missing (optional), + }, + JsClassDeclaration { + decorators: JsDecoratorList [], + abstract_token: missing (optional), + class_token: CLASS_KW@192..198 "class" [] [Whitespace(" ")], + id: JsIdentifierBinding { + name_token: IDENT@198..206 "MyClass" [] [Whitespace(" ")], + }, + type_parameters: missing (optional), + extends_clause: missing (optional), + implements_clause: missing (optional), + l_curly_token: L_CURLY@206..207 "{" [] [], + members: JsClassMemberList [], + r_curly_token: R_CURLY@207..208 "}" [] [], + }, + JsClassDeclaration { + decorators: JsDecoratorList [ + JsDecorator { + at_token: AT@208..210 "@" [Newline("\n")] [], + expression: JsBogusExpression { + items: [ + FUNCTION_KW@210..218 "function" [] [], + JsParameters { + l_paren_token: L_PAREN@218..219 "(" [] [], + items: JsParameterList [], + r_paren_token: R_PAREN@219..220 ")" [] [], + }, + JsFunctionBody { + l_curly_token: L_CURLY@220..221 "{" [] [], + directives: JsDirectiveList [], + statements: JsStatementList [], + r_curly_token: R_CURLY@221..223 "}" [] [Whitespace(" ")], + }, + ], + }, + }, + ], + abstract_token: missing (optional), + class_token: CLASS_KW@223..229 "class" [] [Whitespace(" ")], + id: JsIdentifierBinding { + name_token: IDENT@229..237 "MyClass" [] [Whitespace(" ")], + }, + type_parameters: missing (optional), + extends_clause: missing (optional), + implements_clause: missing (optional), + l_curly_token: L_CURLY@237..238 "{" [] [], + members: JsClassMemberList [], + r_curly_token: R_CURLY@238..239 "}" [] [], + }, + JsBogusStatement { + items: [ + JsDecorator { + at_token: AT@239..241 "@" [Newline("\n")] [], + expression: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@241..245 "obj" [] [Whitespace(" ")], + }, + }, + }, + ], + }, + JsBogusStatement { + items: [ + INSTANCEOF_KW@245..256 "instanceof" [] [Whitespace(" ")], + IDENT@256..263 "Object" [] [Whitespace(" ")], + ], + }, + JsClassDeclaration { + decorators: JsDecoratorList [], + abstract_token: missing (optional), + class_token: CLASS_KW@263..269 "class" [] [Whitespace(" ")], + id: JsIdentifierBinding { + name_token: IDENT@269..277 "MyClass" [] [Whitespace(" ")], + }, + type_parameters: missing (optional), + extends_clause: missing (optional), + implements_clause: missing (optional), + l_curly_token: L_CURLY@277..278 "{" [] [], + members: JsClassMemberList [], + r_curly_token: R_CURLY@278..279 "}" [] [], + }, + JsBogusStatement { + items: [ + JsDecorator { + at_token: AT@279..281 "@" [Newline("\n")] [], + expression: JsBogusExpression { + items: [ + JS_NUMBER_LITERAL@281..283 "1" [] [Whitespace(" ")], + ], + }, + }, + ], + }, + JsBogusStatement { + items: [ + EQ3@283..287 "===" [] [Whitespace(" ")], + JS_NUMBER_LITERAL@287..289 "2" [] [Whitespace(" ")], + ], + }, + JsClassDeclaration { + decorators: JsDecoratorList [], + abstract_token: missing (optional), + class_token: CLASS_KW@289..295 "class" [] [Whitespace(" ")], + id: JsIdentifierBinding { + name_token: IDENT@295..303 "MyClass" [] [Whitespace(" ")], + }, + type_parameters: missing (optional), + extends_clause: missing (optional), + implements_clause: missing (optional), + l_curly_token: L_CURLY@303..304 "{" [] [], + members: JsClassMemberList [], + r_curly_token: R_CURLY@304..305 "}" [] [], + }, + JsClassDeclaration { + decorators: JsDecoratorList [ + JsDecorator { + at_token: AT@305..307 "@" [Newline("\n")] [], + expression: JsBogusExpression { + items: [ + NEW_KW@307..311 "new" [] [Whitespace(" ")], + JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@311..317 "Object" [] [], + }, + }, + JsCallArguments { + l_paren_token: L_PAREN@317..318 "(" [] [], + args: JsCallArgumentList [], + r_paren_token: R_PAREN@318..320 ")" [] [Whitespace(" ")], + }, + ], + }, + }, + ], + abstract_token: missing (optional), + class_token: CLASS_KW@320..326 "class" [] [Whitespace(" ")], + id: JsIdentifierBinding { + name_token: IDENT@326..334 "MyClass" [] [Whitespace(" ")], + }, + type_parameters: missing (optional), + extends_clause: missing (optional), + implements_clause: missing (optional), + l_curly_token: L_CURLY@334..335 "{" [] [], + members: JsClassMemberList [], + r_curly_token: R_CURLY@335..336 "}" [] [], + }, + JsClassDeclaration { + decorators: JsDecoratorList [ + JsDecorator { + at_token: AT@336..338 "@" [Newline("\n")] [], + expression: JsBogusExpression { + items: [ + L_CURLY@338..339 "{" [] [], + JsObjectMemberList [], + R_CURLY@339..341 "}" [] [Whitespace(" ")], + ], + }, + }, + ], + abstract_token: missing (optional), + class_token: CLASS_KW@341..347 "class" [] [Whitespace(" ")], + id: JsIdentifierBinding { + name_token: IDENT@347..355 "MyClass" [] [Whitespace(" ")], + }, + type_parameters: missing (optional), + extends_clause: missing (optional), + implements_clause: missing (optional), + l_curly_token: L_CURLY@355..356 "{" [] [], + members: JsClassMemberList [], + r_curly_token: R_CURLY@356..357 "}" [] [], + }, + JsBogusStatement { + items: [ + JsDecorator { + at_token: AT@357..359 "@" [Newline("\n")] [], + expression: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@359..360 "a" [] [], + }, + }, + }, + ], + }, + JsExpressionStatement { + expression: JsPreUpdateExpression { + operator_token: PLUS2@360..363 "++" [] [Whitespace(" ")], + operand: JsBogusAssignment { + items: [ + JsDecoratorList [], + CLASS_KW@363..369 "class" [] [Whitespace(" ")], + JsIdentifierBinding { + name_token: IDENT@369..377 "MyClass" [] [Whitespace(" ")], + }, + L_CURLY@377..378 "{" [] [], + JsClassMemberList [], + R_CURLY@378..379 "}" [] [], + ], + }, + }, + semicolon_token: missing (optional), + }, + JsBogusStatement { + items: [ + JsDecorator { + at_token: AT@379..381 "@" [Newline("\n")] [], + expression: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@381..382 "a" [] [], + }, + }, + }, + ], + }, + JsBogusStatement { + items: [ + COMMA@382..383 "," [] [], + IDENT@383..385 "b" [] [Whitespace(" ")], + ], + }, + JsClassDeclaration { + decorators: JsDecoratorList [], + abstract_token: missing (optional), + class_token: CLASS_KW@385..391 "class" [] [Whitespace(" ")], + id: JsIdentifierBinding { + name_token: IDENT@391..399 "MyClass" [] [Whitespace(" ")], + }, + type_parameters: missing (optional), + extends_clause: missing (optional), + implements_clause: missing (optional), + l_curly_token: L_CURLY@399..400 "{" [] [], + members: JsClassMemberList [], + r_curly_token: R_CURLY@400..401 "}" [] [], + }, + JsClassDeclaration { + decorators: JsDecoratorList [ + JsDecorator { + at_token: AT@401..403 "@" [Newline("\n")] [], + expression: JsBogusExpression { + items: [ + BACKTICK@403..404 "`" [] [], + JsTemplateElementList [ + JsTemplateElement { + dollar_curly_token: DOLLAR_CURLY@404..406 "${" [] [], + expression: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@406..407 "d" [] [], + }, + }, + r_curly_token: R_CURLY@407..408 "}" [] [], + }, + JsTemplateChunkElement { + template_chunk_token: TEMPLATE_CHUNK@408..411 "foo" [] [], + }, + ], + BACKTICK@411..413 "`" [] [Whitespace(" ")], + ], + }, + }, + ], + abstract_token: missing (optional), + class_token: CLASS_KW@413..419 "class" [] [Whitespace(" ")], + id: JsIdentifierBinding { + name_token: IDENT@419..427 "MyClass" [] [Whitespace(" ")], + }, + type_parameters: missing (optional), + extends_clause: missing (optional), + implements_clause: missing (optional), + l_curly_token: L_CURLY@427..428 "{" [] [], + members: JsClassMemberList [], + r_curly_token: R_CURLY@428..429 "}" [] [], + }, + JsBogusStatement { + items: [ + JsDecorator { + at_token: AT@429..431 "@" [Newline("\n")] [], + expression: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@431..435 "obj" [] [Whitespace(" ")], + }, + }, + }, + ], + }, + JsExpressionStatement { + expression: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@435..438 "as" [] [Whitespace(" ")], + }, + }, + semicolon_token: missing (optional), + }, + JsExpressionStatement { + expression: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@438..445 "MyType" [] [Whitespace(" ")], + }, + }, + semicolon_token: missing (optional), + }, + JsClassDeclaration { + decorators: JsDecoratorList [], + abstract_token: missing (optional), + class_token: CLASS_KW@445..451 "class" [] [Whitespace(" ")], + id: JsIdentifierBinding { + name_token: IDENT@451..459 "MyClass" [] [Whitespace(" ")], + }, + type_parameters: missing (optional), + extends_clause: missing (optional), + implements_clause: missing (optional), + l_curly_token: L_CURLY@459..460 "{" [] [], + members: JsClassMemberList [], + r_curly_token: R_CURLY@460..461 "}" [] [], + }, + JsBogusStatement { + items: [ + JsDecorator { + at_token: AT@461..463 "@" [Newline("\n")] [], + expression: missing (required), + }, + ], + }, + JsExpressionStatement { + expression: TsTypeAssertionExpression { + l_angle_token: L_ANGLE@463..464 "<" [] [], + ty: TsReferenceType { + name: JsReferenceIdentifier { + value_token: IDENT@464..470 "MyType" [] [], + }, + type_arguments: missing (optional), + }, + r_angle_token: R_ANGLE@470..471 ">" [] [], + expression: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@471..475 "obj" [] [Whitespace(" ")], + }, + }, + }, + semicolon_token: missing (optional), + }, + JsClassDeclaration { + decorators: JsDecoratorList [], + abstract_token: missing (optional), + class_token: CLASS_KW@475..481 "class" [] [Whitespace(" ")], + id: JsIdentifierBinding { + name_token: IDENT@481..489 "MyClass" [] [Whitespace(" ")], + }, + type_parameters: missing (optional), + extends_clause: missing (optional), + implements_clause: missing (optional), + l_curly_token: L_CURLY@489..490 "{" [] [], + members: JsClassMemberList [], + r_curly_token: R_CURLY@490..491 "}" [] [], + }, + JsBogusStatement { + items: [ + JsDecorator { + at_token: AT@491..493 "@" [Newline("\n")] [], + expression: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@493..497 "obj" [] [Whitespace(" ")], + }, + }, + }, + ], + }, + JsExpressionStatement { + expression: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@497..507 "satisfies" [] [Whitespace(" ")], + }, + }, + semicolon_token: missing (optional), + }, + JsExpressionStatement { + expression: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@507..514 "MyType" [] [Whitespace(" ")], + }, + }, + semicolon_token: missing (optional), + }, + JsClassDeclaration { + decorators: JsDecoratorList [], + abstract_token: missing (optional), + class_token: CLASS_KW@514..520 "class" [] [Whitespace(" ")], + id: JsIdentifierBinding { + name_token: IDENT@520..528 "MyClass" [] [Whitespace(" ")], + }, + type_parameters: missing (optional), + extends_clause: missing (optional), + implements_clause: missing (optional), + l_curly_token: L_CURLY@528..529 "{" [] [], + members: JsClassMemberList [], + r_curly_token: R_CURLY@529..530 "}" [] [], + }, + JsClassDeclaration { + decorators: JsDecoratorList [ + JsDecorator { + at_token: AT@530..532 "@" [Newline("\n")] [], + expression: JsBogusExpression { + items: [ + JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@532..535 "obj" [] [], + }, + }, + BANG@535..537 "!" [] [Whitespace(" ")], + ], + }, + }, + ], + abstract_token: missing (optional), + class_token: CLASS_KW@537..543 "class" [] [Whitespace(" ")], + id: JsIdentifierBinding { + name_token: IDENT@543..551 "MyClass" [] [Whitespace(" ")], + }, + type_parameters: missing (optional), + extends_clause: missing (optional), + implements_clause: missing (optional), + l_curly_token: L_CURLY@551..552 "{" [] [], + members: JsClassMemberList [], + r_curly_token: R_CURLY@552..553 "}" [] [], + }, + ], + eof_token: EOF@553..554 "" [Newline("\n")] [], +} + +0: JS_MODULE@0..554 + 0: (empty) + 1: JS_DIRECTIVE_LIST@0..0 + 2: JS_MODULE_ITEM_LIST@0..553 + 0: JS_CLASS_DECLARATION@0..25 + 0: JS_DECORATOR_LIST@0..9 + 0: JS_DECORATOR@0..9 + 0: AT@0..1 "@" [] [] + 1: JS_BOGUS_EXPRESSION@1..9 + 0: JS_STRING_LITERAL@1..9 "'dsads'" [] [Whitespace(" ")] + 1: (empty) + 2: CLASS_KW@9..15 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@15..23 + 0: IDENT@15..23 "MyClass" [] [Whitespace(" ")] + 4: (empty) + 5: (empty) + 6: (empty) + 7: L_CURLY@23..24 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@24..24 + 9: R_CURLY@24..25 "}" [] [] + 1: JS_CLASS_DECLARATION@25..45 + 0: JS_DECORATOR_LIST@25..29 + 0: JS_DECORATOR@25..29 + 0: AT@25..27 "@" [Newline("\n")] [] + 1: JS_BOGUS_EXPRESSION@27..29 + 0: JS_NUMBER_LITERAL@27..29 "1" [] [Whitespace(" ")] + 1: (empty) + 2: CLASS_KW@29..35 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@35..43 + 0: IDENT@35..43 "MyClass" [] [Whitespace(" ")] + 4: (empty) + 5: (empty) + 6: (empty) + 7: L_CURLY@43..44 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@44..44 + 9: R_CURLY@44..45 "}" [] [] + 2: JS_BOGUS_STATEMENT@45..47 + 0: JS_DECORATOR@45..47 + 0: AT@45..47 "@" [Newline("\n")] [] + 1: (empty) + 3: JS_EXPRESSION_STATEMENT@47..51 + 0: JS_PRE_UPDATE_EXPRESSION@47..51 + 0: PLUS2@47..49 "++" [] [] + 1: JS_BOGUS_ASSIGNMENT@49..51 + 0: JS_NUMBER_LITERAL@49..51 "1" [] [Whitespace(" ")] + 1: (empty) + 4: JS_CLASS_DECLARATION@51..67 + 0: JS_DECORATOR_LIST@51..51 + 1: (empty) + 2: CLASS_KW@51..57 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@57..65 + 0: IDENT@57..65 "MyClass" [] [Whitespace(" ")] + 4: (empty) + 5: (empty) + 6: (empty) + 7: L_CURLY@65..66 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@66..66 + 9: R_CURLY@66..67 "}" [] [] + 5: JS_BOGUS_STATEMENT@67..72 + 0: JS_DECORATOR@67..72 + 0: AT@67..69 "@" [Newline("\n")] [] + 1: JS_BOGUS_EXPRESSION@69..72 + 0: L_BRACK@69..70 "[" [] [] + 1: JS_ARRAY_ELEMENT_LIST@70..70 + 2: R_BRACK@70..72 "]" [] [Whitespace(" ")] + 6: JS_BOGUS_STATEMENT@72..77 + 0: IN_KW@72..75 "in" [] [Whitespace(" ")] + 1: JS_NUMBER_LITERAL@75..77 "1" [] [Whitespace(" ")] + 7: JS_CLASS_DECLARATION@77..93 + 0: JS_DECORATOR_LIST@77..77 + 1: (empty) + 2: CLASS_KW@77..83 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@83..91 + 0: IDENT@83..91 "MyClass" [] [Whitespace(" ")] + 4: (empty) + 5: (empty) + 6: (empty) + 7: L_CURLY@91..92 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@92..92 + 9: R_CURLY@92..93 "}" [] [] + 8: JS_CLASS_DECLARATION@93..114 + 0: JS_DECORATOR_LIST@93..98 + 0: JS_DECORATOR@93..98 + 0: AT@93..95 "@" [Newline("\n")] [] + 1: JS_BOGUS_EXPRESSION@95..98 + 0: L_BRACK@95..96 "[" [] [] + 1: JS_ARRAY_ELEMENT_LIST@96..96 + 2: R_BRACK@96..98 "]" [] [Whitespace(" ")] + 1: (empty) + 2: CLASS_KW@98..104 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@104..112 + 0: IDENT@104..112 "MyClass" [] [Whitespace(" ")] + 4: (empty) + 5: (empty) + 6: (empty) + 7: L_CURLY@112..113 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@113..113 + 9: R_CURLY@113..114 "}" [] [] + 9: JS_BOGUS_STATEMENT@114..119 + 0: JS_DECORATOR@114..119 + 0: AT@114..116 "@" [Newline("\n")] [] + 1: JS_PARENTHESIZED_EXPRESSION@116..119 + 0: L_PAREN@116..117 "(" [] [] + 1: (empty) + 2: R_PAREN@117..119 ")" [] [Whitespace(" ")] + 10: JS_BOGUS_STATEMENT@119..122 + 0: FAT_ARROW@119..122 "=>" [] [Whitespace(" ")] + 11: JS_BLOCK_STATEMENT@122..125 + 0: L_CURLY@122..123 "{" [] [] + 1: JS_STATEMENT_LIST@123..123 + 2: R_CURLY@123..125 "}" [] [Whitespace(" ")] + 12: JS_CLASS_DECLARATION@125..141 + 0: JS_DECORATOR_LIST@125..125 + 1: (empty) + 2: CLASS_KW@125..131 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@131..139 + 0: IDENT@131..139 "MyClass" [] [Whitespace(" ")] + 4: (empty) + 5: (empty) + 6: (empty) + 7: L_CURLY@139..140 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@140..140 + 9: R_CURLY@140..141 "}" [] [] + 13: JS_BOGUS_STATEMENT@141..145 + 0: JS_DECORATOR@141..145 + 0: AT@141..143 "@" [Newline("\n")] [] + 1: JS_BOGUS_EXPRESSION@143..145 + 0: JS_NUMBER_LITERAL@143..145 "1" [] [Whitespace(" ")] + 14: JS_BOGUS_STATEMENT@145..165 + 0: EQ2@145..148 "==" [] [Whitespace(" ")] + 1: JS_NUMBER_LITERAL@148..150 "2" [] [Whitespace(" ")] + 2: QUESTION@150..152 "?" [] [Whitespace(" ")] + 3: TRUE_KW@152..157 "true" [] [Whitespace(" ")] + 4: COLON@157..159 ":" [] [Whitespace(" ")] + 5: FALSE_KW@159..165 "false" [] [Whitespace(" ")] + 15: JS_CLASS_DECLARATION@165..181 + 0: JS_DECORATOR_LIST@165..165 + 1: (empty) + 2: CLASS_KW@165..171 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@171..179 + 0: IDENT@171..179 "MyClass" [] [Whitespace(" ")] + 4: (empty) + 5: (empty) + 6: (empty) + 7: L_CURLY@179..180 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@180..180 + 9: R_CURLY@180..181 "}" [] [] + 16: JS_BOGUS_STATEMENT@181..189 + 0: JS_DECORATOR@181..189 + 0: AT@181..183 "@" [Newline("\n")] [] + 1: JS_BOGUS_EXPRESSION@183..189 + 0: JS_BOGUS@183..189 + 0: IDENT@183..189 "await" [] [Whitespace(" ")] + 17: JS_EXPRESSION_STATEMENT@189..192 + 0: JS_IDENTIFIER_EXPRESSION@189..192 + 0: JS_REFERENCE_IDENTIFIER@189..192 + 0: IDENT@189..192 "fn" [] [Whitespace(" ")] + 1: (empty) + 18: JS_CLASS_DECLARATION@192..208 + 0: JS_DECORATOR_LIST@192..192 + 1: (empty) + 2: CLASS_KW@192..198 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@198..206 + 0: IDENT@198..206 "MyClass" [] [Whitespace(" ")] + 4: (empty) + 5: (empty) + 6: (empty) + 7: L_CURLY@206..207 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@207..207 + 9: R_CURLY@207..208 "}" [] [] + 19: JS_CLASS_DECLARATION@208..239 + 0: JS_DECORATOR_LIST@208..223 + 0: JS_DECORATOR@208..223 + 0: AT@208..210 "@" [Newline("\n")] [] + 1: JS_BOGUS_EXPRESSION@210..223 + 0: FUNCTION_KW@210..218 "function" [] [] + 1: JS_PARAMETERS@218..220 + 0: L_PAREN@218..219 "(" [] [] + 1: JS_PARAMETER_LIST@219..219 + 2: R_PAREN@219..220 ")" [] [] + 2: JS_FUNCTION_BODY@220..223 + 0: L_CURLY@220..221 "{" [] [] + 1: JS_DIRECTIVE_LIST@221..221 + 2: JS_STATEMENT_LIST@221..221 + 3: R_CURLY@221..223 "}" [] [Whitespace(" ")] + 1: (empty) + 2: CLASS_KW@223..229 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@229..237 + 0: IDENT@229..237 "MyClass" [] [Whitespace(" ")] + 4: (empty) + 5: (empty) + 6: (empty) + 7: L_CURLY@237..238 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@238..238 + 9: R_CURLY@238..239 "}" [] [] + 20: JS_BOGUS_STATEMENT@239..245 + 0: JS_DECORATOR@239..245 + 0: AT@239..241 "@" [Newline("\n")] [] + 1: JS_IDENTIFIER_EXPRESSION@241..245 + 0: JS_REFERENCE_IDENTIFIER@241..245 + 0: IDENT@241..245 "obj" [] [Whitespace(" ")] + 21: JS_BOGUS_STATEMENT@245..263 + 0: INSTANCEOF_KW@245..256 "instanceof" [] [Whitespace(" ")] + 1: IDENT@256..263 "Object" [] [Whitespace(" ")] + 22: JS_CLASS_DECLARATION@263..279 + 0: JS_DECORATOR_LIST@263..263 + 1: (empty) + 2: CLASS_KW@263..269 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@269..277 + 0: IDENT@269..277 "MyClass" [] [Whitespace(" ")] + 4: (empty) + 5: (empty) + 6: (empty) + 7: L_CURLY@277..278 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@278..278 + 9: R_CURLY@278..279 "}" [] [] + 23: JS_BOGUS_STATEMENT@279..283 + 0: JS_DECORATOR@279..283 + 0: AT@279..281 "@" [Newline("\n")] [] + 1: JS_BOGUS_EXPRESSION@281..283 + 0: JS_NUMBER_LITERAL@281..283 "1" [] [Whitespace(" ")] + 24: JS_BOGUS_STATEMENT@283..289 + 0: EQ3@283..287 "===" [] [Whitespace(" ")] + 1: JS_NUMBER_LITERAL@287..289 "2" [] [Whitespace(" ")] + 25: JS_CLASS_DECLARATION@289..305 + 0: JS_DECORATOR_LIST@289..289 + 1: (empty) + 2: CLASS_KW@289..295 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@295..303 + 0: IDENT@295..303 "MyClass" [] [Whitespace(" ")] + 4: (empty) + 5: (empty) + 6: (empty) + 7: L_CURLY@303..304 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@304..304 + 9: R_CURLY@304..305 "}" [] [] + 26: JS_CLASS_DECLARATION@305..336 + 0: JS_DECORATOR_LIST@305..320 + 0: JS_DECORATOR@305..320 + 0: AT@305..307 "@" [Newline("\n")] [] + 1: JS_BOGUS_EXPRESSION@307..320 + 0: NEW_KW@307..311 "new" [] [Whitespace(" ")] + 1: JS_IDENTIFIER_EXPRESSION@311..317 + 0: JS_REFERENCE_IDENTIFIER@311..317 + 0: IDENT@311..317 "Object" [] [] + 2: JS_CALL_ARGUMENTS@317..320 + 0: L_PAREN@317..318 "(" [] [] + 1: JS_CALL_ARGUMENT_LIST@318..318 + 2: R_PAREN@318..320 ")" [] [Whitespace(" ")] + 1: (empty) + 2: CLASS_KW@320..326 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@326..334 + 0: IDENT@326..334 "MyClass" [] [Whitespace(" ")] + 4: (empty) + 5: (empty) + 6: (empty) + 7: L_CURLY@334..335 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@335..335 + 9: R_CURLY@335..336 "}" [] [] + 27: JS_CLASS_DECLARATION@336..357 + 0: JS_DECORATOR_LIST@336..341 + 0: JS_DECORATOR@336..341 + 0: AT@336..338 "@" [Newline("\n")] [] + 1: JS_BOGUS_EXPRESSION@338..341 + 0: L_CURLY@338..339 "{" [] [] + 1: JS_OBJECT_MEMBER_LIST@339..339 + 2: R_CURLY@339..341 "}" [] [Whitespace(" ")] + 1: (empty) + 2: CLASS_KW@341..347 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@347..355 + 0: IDENT@347..355 "MyClass" [] [Whitespace(" ")] + 4: (empty) + 5: (empty) + 6: (empty) + 7: L_CURLY@355..356 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@356..356 + 9: R_CURLY@356..357 "}" [] [] + 28: JS_BOGUS_STATEMENT@357..360 + 0: JS_DECORATOR@357..360 + 0: AT@357..359 "@" [Newline("\n")] [] + 1: JS_IDENTIFIER_EXPRESSION@359..360 + 0: JS_REFERENCE_IDENTIFIER@359..360 + 0: IDENT@359..360 "a" [] [] + 29: JS_EXPRESSION_STATEMENT@360..379 + 0: JS_PRE_UPDATE_EXPRESSION@360..379 + 0: PLUS2@360..363 "++" [] [Whitespace(" ")] + 1: JS_BOGUS_ASSIGNMENT@363..379 + 0: JS_DECORATOR_LIST@363..363 + 1: CLASS_KW@363..369 "class" [] [Whitespace(" ")] + 2: JS_IDENTIFIER_BINDING@369..377 + 0: IDENT@369..377 "MyClass" [] [Whitespace(" ")] + 3: L_CURLY@377..378 "{" [] [] + 4: JS_CLASS_MEMBER_LIST@378..378 + 5: R_CURLY@378..379 "}" [] [] + 1: (empty) + 30: JS_BOGUS_STATEMENT@379..382 + 0: JS_DECORATOR@379..382 + 0: AT@379..381 "@" [Newline("\n")] [] + 1: JS_IDENTIFIER_EXPRESSION@381..382 + 0: JS_REFERENCE_IDENTIFIER@381..382 + 0: IDENT@381..382 "a" [] [] + 31: JS_BOGUS_STATEMENT@382..385 + 0: COMMA@382..383 "," [] [] + 1: IDENT@383..385 "b" [] [Whitespace(" ")] + 32: JS_CLASS_DECLARATION@385..401 + 0: JS_DECORATOR_LIST@385..385 + 1: (empty) + 2: CLASS_KW@385..391 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@391..399 + 0: IDENT@391..399 "MyClass" [] [Whitespace(" ")] + 4: (empty) + 5: (empty) + 6: (empty) + 7: L_CURLY@399..400 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@400..400 + 9: R_CURLY@400..401 "}" [] [] + 33: JS_CLASS_DECLARATION@401..429 + 0: JS_DECORATOR_LIST@401..413 + 0: JS_DECORATOR@401..413 + 0: AT@401..403 "@" [Newline("\n")] [] + 1: JS_BOGUS_EXPRESSION@403..413 + 0: BACKTICK@403..404 "`" [] [] + 1: JS_TEMPLATE_ELEMENT_LIST@404..411 + 0: JS_TEMPLATE_ELEMENT@404..408 + 0: DOLLAR_CURLY@404..406 "${" [] [] + 1: JS_IDENTIFIER_EXPRESSION@406..407 + 0: JS_REFERENCE_IDENTIFIER@406..407 + 0: IDENT@406..407 "d" [] [] + 2: R_CURLY@407..408 "}" [] [] + 1: JS_TEMPLATE_CHUNK_ELEMENT@408..411 + 0: TEMPLATE_CHUNK@408..411 "foo" [] [] + 2: BACKTICK@411..413 "`" [] [Whitespace(" ")] + 1: (empty) + 2: CLASS_KW@413..419 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@419..427 + 0: IDENT@419..427 "MyClass" [] [Whitespace(" ")] + 4: (empty) + 5: (empty) + 6: (empty) + 7: L_CURLY@427..428 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@428..428 + 9: R_CURLY@428..429 "}" [] [] + 34: JS_BOGUS_STATEMENT@429..435 + 0: JS_DECORATOR@429..435 + 0: AT@429..431 "@" [Newline("\n")] [] + 1: JS_IDENTIFIER_EXPRESSION@431..435 + 0: JS_REFERENCE_IDENTIFIER@431..435 + 0: IDENT@431..435 "obj" [] [Whitespace(" ")] + 35: JS_EXPRESSION_STATEMENT@435..438 + 0: JS_IDENTIFIER_EXPRESSION@435..438 + 0: JS_REFERENCE_IDENTIFIER@435..438 + 0: IDENT@435..438 "as" [] [Whitespace(" ")] + 1: (empty) + 36: JS_EXPRESSION_STATEMENT@438..445 + 0: JS_IDENTIFIER_EXPRESSION@438..445 + 0: JS_REFERENCE_IDENTIFIER@438..445 + 0: IDENT@438..445 "MyType" [] [Whitespace(" ")] + 1: (empty) + 37: JS_CLASS_DECLARATION@445..461 + 0: JS_DECORATOR_LIST@445..445 + 1: (empty) + 2: CLASS_KW@445..451 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@451..459 + 0: IDENT@451..459 "MyClass" [] [Whitespace(" ")] + 4: (empty) + 5: (empty) + 6: (empty) + 7: L_CURLY@459..460 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@460..460 + 9: R_CURLY@460..461 "}" [] [] + 38: JS_BOGUS_STATEMENT@461..463 + 0: JS_DECORATOR@461..463 + 0: AT@461..463 "@" [Newline("\n")] [] + 1: (empty) + 39: JS_EXPRESSION_STATEMENT@463..475 + 0: TS_TYPE_ASSERTION_EXPRESSION@463..475 + 0: L_ANGLE@463..464 "<" [] [] + 1: TS_REFERENCE_TYPE@464..470 + 0: JS_REFERENCE_IDENTIFIER@464..470 + 0: IDENT@464..470 "MyType" [] [] + 1: (empty) + 2: R_ANGLE@470..471 ">" [] [] + 3: JS_IDENTIFIER_EXPRESSION@471..475 + 0: JS_REFERENCE_IDENTIFIER@471..475 + 0: IDENT@471..475 "obj" [] [Whitespace(" ")] + 1: (empty) + 40: JS_CLASS_DECLARATION@475..491 + 0: JS_DECORATOR_LIST@475..475 + 1: (empty) + 2: CLASS_KW@475..481 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@481..489 + 0: IDENT@481..489 "MyClass" [] [Whitespace(" ")] + 4: (empty) + 5: (empty) + 6: (empty) + 7: L_CURLY@489..490 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@490..490 + 9: R_CURLY@490..491 "}" [] [] + 41: JS_BOGUS_STATEMENT@491..497 + 0: JS_DECORATOR@491..497 + 0: AT@491..493 "@" [Newline("\n")] [] + 1: JS_IDENTIFIER_EXPRESSION@493..497 + 0: JS_REFERENCE_IDENTIFIER@493..497 + 0: IDENT@493..497 "obj" [] [Whitespace(" ")] + 42: JS_EXPRESSION_STATEMENT@497..507 + 0: JS_IDENTIFIER_EXPRESSION@497..507 + 0: JS_REFERENCE_IDENTIFIER@497..507 + 0: IDENT@497..507 "satisfies" [] [Whitespace(" ")] + 1: (empty) + 43: JS_EXPRESSION_STATEMENT@507..514 + 0: JS_IDENTIFIER_EXPRESSION@507..514 + 0: JS_REFERENCE_IDENTIFIER@507..514 + 0: IDENT@507..514 "MyType" [] [Whitespace(" ")] + 1: (empty) + 44: JS_CLASS_DECLARATION@514..530 + 0: JS_DECORATOR_LIST@514..514 + 1: (empty) + 2: CLASS_KW@514..520 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@520..528 + 0: IDENT@520..528 "MyClass" [] [Whitespace(" ")] + 4: (empty) + 5: (empty) + 6: (empty) + 7: L_CURLY@528..529 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@529..529 + 9: R_CURLY@529..530 "}" [] [] + 45: JS_CLASS_DECLARATION@530..553 + 0: JS_DECORATOR_LIST@530..537 + 0: JS_DECORATOR@530..537 + 0: AT@530..532 "@" [Newline("\n")] [] + 1: JS_BOGUS_EXPRESSION@532..537 + 0: JS_IDENTIFIER_EXPRESSION@532..535 + 0: JS_REFERENCE_IDENTIFIER@532..535 + 0: IDENT@532..535 "obj" [] [] + 1: BANG@535..537 "!" [] [Whitespace(" ")] + 1: (empty) + 2: CLASS_KW@537..543 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@543..551 + 0: IDENT@543..551 "MyClass" [] [Whitespace(" ")] + 4: (empty) + 5: (empty) + 6: (empty) + 7: L_CURLY@551..552 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@552..552 + 9: R_CURLY@552..553 "}" [] [] + 3: EOF@553..554 "" [Newline("\n")] [] +-- +decorator.ts:1:2 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Invalid decorator `'dsads'` + + > 1 │ @'dsads' class MyClass {} + │ ^^^^^^^ + 2 │ @1 class MyClass {} + 3 │ @++1 class MyClass {} + +-- +decorator.ts:2:2 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Invalid decorator `1` + + 1 │ @'dsads' class MyClass {} + > 2 │ @1 class MyClass {} + │ ^ + 3 │ @++1 class MyClass {} + 4 │ @[] in 1 class MyClass {} + +-- +decorator.ts:3:2 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × expected an expression but instead found '++' + + 1 │ @'dsads' class MyClass {} + 2 │ @1 class MyClass {} + > 3 │ @++1 class MyClass {} + │ ^^ + 4 │ @[] in 1 class MyClass {} + 5 │ @[] class MyClass {} + + i Expected an expression here + + 1 │ @'dsads' class MyClass {} + 2 │ @1 class MyClass {} + > 3 │ @++1 class MyClass {} + │ ^^ + 4 │ @[] in 1 class MyClass {} + 5 │ @[] class MyClass {} + +-- +decorator.ts:3:1 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Decorators are not valid here. + + 1 │ @'dsads' class MyClass {} + 2 │ @1 class MyClass {} + > 3 │ @++1 class MyClass {} + │ ^ + 4 │ @[] in 1 class MyClass {} + 5 │ @[] class MyClass {} + +-- +decorator.ts:3:4 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Invalid assignment to `1` + + 1 │ @'dsads' class MyClass {} + 2 │ @1 class MyClass {} + > 3 │ @++1 class MyClass {} + │ ^ + 4 │ @[] in 1 class MyClass {} + 5 │ @[] class MyClass {} + + i This expression cannot be assigned to + +-- +decorator.ts:3:6 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 1 │ @'dsads' class MyClass {} + 2 │ @1 class MyClass {} + > 3 │ @++1 class MyClass {} + │ ^^^^^ + 4 │ @[] in 1 class MyClass {} + 5 │ @[] class MyClass {} + + i An explicit or implicit semicolon is expected here... + + 1 │ @'dsads' class MyClass {} + 2 │ @1 class MyClass {} + > 3 │ @++1 class MyClass {} + │ ^^^^^ + 4 │ @[] in 1 class MyClass {} + 5 │ @[] class MyClass {} + + i ...Which is required to end this statement + + 1 │ @'dsads' class MyClass {} + 2 │ @1 class MyClass {} + > 3 │ @++1 class MyClass {} + │ ^^^^^^^^^ + 4 │ @[] in 1 class MyClass {} + 5 │ @[] class MyClass {} + +-- +decorator.ts:4:2 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Invalid decorator `[]` + + 2 │ @1 class MyClass {} + 3 │ @++1 class MyClass {} + > 4 │ @[] in 1 class MyClass {} + │ ^^ + 5 │ @[] class MyClass {} + 6 │ @() => {} class MyClass {} + +-- +decorator.ts:4:1 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Decorators are not valid here. + + 2 │ @1 class MyClass {} + 3 │ @++1 class MyClass {} + > 4 │ @[] in 1 class MyClass {} + │ ^^^ + 5 │ @[] class MyClass {} + 6 │ @() => {} class MyClass {} + +-- +decorator.ts:4:5 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × expected a statement but instead found 'in 1' + + 2 │ @1 class MyClass {} + 3 │ @++1 class MyClass {} + > 4 │ @[] in 1 class MyClass {} + │ ^^^^ + 5 │ @[] class MyClass {} + 6 │ @() => {} class MyClass {} + + i Expected a statement here + + 2 │ @1 class MyClass {} + 3 │ @++1 class MyClass {} + > 4 │ @[] in 1 class MyClass {} + │ ^^^^ + 5 │ @[] class MyClass {} + 6 │ @() => {} class MyClass {} + +-- +decorator.ts:5:2 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Invalid decorator `[]` + + 3 │ @++1 class MyClass {} + 4 │ @[] in 1 class MyClass {} + > 5 │ @[] class MyClass {} + │ ^^ + 6 │ @() => {} class MyClass {} + 7 │ @1 == 2 ? true : false class MyClass {} + +-- +decorator.ts:6:3 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Parenthesized expression didnt contain anything + + 4 │ @[] in 1 class MyClass {} + 5 │ @[] class MyClass {} + > 6 │ @() => {} class MyClass {} + │ ^ + 7 │ @1 == 2 ? true : false class MyClass {} + 8 │ @await fn class MyClass {} + + i Expected an expression here + +-- +decorator.ts:6:1 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Decorators are not valid here. + + 4 │ @[] in 1 class MyClass {} + 5 │ @[] class MyClass {} + > 6 │ @() => {} class MyClass {} + │ ^^^ + 7 │ @1 == 2 ? true : false class MyClass {} + 8 │ @await fn class MyClass {} + +-- +decorator.ts:6:5 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × expected a statement but instead found '=>' + + 4 │ @[] in 1 class MyClass {} + 5 │ @[] class MyClass {} + > 6 │ @() => {} class MyClass {} + │ ^^ + 7 │ @1 == 2 ? true : false class MyClass {} + 8 │ @await fn class MyClass {} + + i Expected a statement here + + 4 │ @[] in 1 class MyClass {} + 5 │ @[] class MyClass {} + > 6 │ @() => {} class MyClass {} + │ ^^ + 7 │ @1 == 2 ? true : false class MyClass {} + 8 │ @await fn class MyClass {} + +-- +decorator.ts:7:2 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Invalid decorator `1` + + 5 │ @[] class MyClass {} + 6 │ @() => {} class MyClass {} + > 7 │ @1 == 2 ? true : false class MyClass {} + │ ^ + 8 │ @await fn class MyClass {} + 9 │ @function(){} class MyClass {} + +-- +decorator.ts:7:1 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Decorators are not valid here. + + 5 │ @[] class MyClass {} + 6 │ @() => {} class MyClass {} + > 7 │ @1 == 2 ? true : false class MyClass {} + │ ^^ + 8 │ @await fn class MyClass {} + 9 │ @function(){} class MyClass {} + +-- +decorator.ts:7:4 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × expected a statement but instead found '== 2 ? true : false' + + 5 │ @[] class MyClass {} + 6 │ @() => {} class MyClass {} + > 7 │ @1 == 2 ? true : false class MyClass {} + │ ^^^^^^^^^^^^^^^^^^^ + 8 │ @await fn class MyClass {} + 9 │ @function(){} class MyClass {} + + i Expected a statement here + + 5 │ @[] class MyClass {} + 6 │ @() => {} class MyClass {} + > 7 │ @1 == 2 ? true : false class MyClass {} + │ ^^^^^^^^^^^^^^^^^^^ + 8 │ @await fn class MyClass {} + 9 │ @function(){} class MyClass {} + +-- +decorator.ts:8:2 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Illegal use of `await` as an identifier in an async context + + 6 │ @() => {} class MyClass {} + 7 │ @1 == 2 ? true : false class MyClass {} + > 8 │ @await fn class MyClass {} + │ ^^^^^ + 9 │ @function(){} class MyClass {} + 10 │ @obj instanceof Object class MyClass {} + +-- +decorator.ts:8:1 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Decorators are not valid here. + + 6 │ @() => {} class MyClass {} + 7 │ @1 == 2 ? true : false class MyClass {} + > 8 │ @await fn class MyClass {} + │ ^^^^^^ + 9 │ @function(){} class MyClass {} + 10 │ @obj instanceof Object class MyClass {} + +-- +decorator.ts:8:11 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 6 │ @() => {} class MyClass {} + 7 │ @1 == 2 ? true : false class MyClass {} + > 8 │ @await fn class MyClass {} + │ ^^^^^ + 9 │ @function(){} class MyClass {} + 10 │ @obj instanceof Object class MyClass {} + + i An explicit or implicit semicolon is expected here... + + 6 │ @() => {} class MyClass {} + 7 │ @1 == 2 ? true : false class MyClass {} + > 8 │ @await fn class MyClass {} + │ ^^^^^ + 9 │ @function(){} class MyClass {} + 10 │ @obj instanceof Object class MyClass {} + + i ...Which is required to end this statement + + 6 │ @() => {} class MyClass {} + 7 │ @1 == 2 ? true : false class MyClass {} + > 8 │ @await fn class MyClass {} + │ ^^^^^^^^ + 9 │ @function(){} class MyClass {} + 10 │ @obj instanceof Object class MyClass {} + +-- +decorator.ts:9:2 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Invalid decorator `function(){}` + + 7 │ @1 == 2 ? true : false class MyClass {} + 8 │ @await fn class MyClass {} + > 9 │ @function(){} class MyClass {} + │ ^^^^^^^^^^^^ + 10 │ @obj instanceof Object class MyClass {} + 11 │ @1 === 2 class MyClass {} + +-- +decorator.ts:10:1 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Decorators are not valid here. + + 8 │ @await fn class MyClass {} + 9 │ @function(){} class MyClass {} + > 10 │ @obj instanceof Object class MyClass {} + │ ^^^^ + 11 │ @1 === 2 class MyClass {} + 12 │ @new Object() class MyClass {} + +-- +decorator.ts:10:6 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × expected a statement but instead found 'instanceof Object' + + 8 │ @await fn class MyClass {} + 9 │ @function(){} class MyClass {} + > 10 │ @obj instanceof Object class MyClass {} + │ ^^^^^^^^^^^^^^^^^ + 11 │ @1 === 2 class MyClass {} + 12 │ @new Object() class MyClass {} + + i Expected a statement here + + 8 │ @await fn class MyClass {} + 9 │ @function(){} class MyClass {} + > 10 │ @obj instanceof Object class MyClass {} + │ ^^^^^^^^^^^^^^^^^ + 11 │ @1 === 2 class MyClass {} + 12 │ @new Object() class MyClass {} + +-- +decorator.ts:11:2 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Invalid decorator `1` + + 9 │ @function(){} class MyClass {} + 10 │ @obj instanceof Object class MyClass {} + > 11 │ @1 === 2 class MyClass {} + │ ^ + 12 │ @new Object() class MyClass {} + 13 │ @{} class MyClass {} + +-- +decorator.ts:11:1 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Decorators are not valid here. + + 9 │ @function(){} class MyClass {} + 10 │ @obj instanceof Object class MyClass {} + > 11 │ @1 === 2 class MyClass {} + │ ^^ + 12 │ @new Object() class MyClass {} + 13 │ @{} class MyClass {} + +-- +decorator.ts:11:4 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × expected a statement but instead found '=== 2' + + 9 │ @function(){} class MyClass {} + 10 │ @obj instanceof Object class MyClass {} + > 11 │ @1 === 2 class MyClass {} + │ ^^^^^ + 12 │ @new Object() class MyClass {} + 13 │ @{} class MyClass {} + + i Expected a statement here + + 9 │ @function(){} class MyClass {} + 10 │ @obj instanceof Object class MyClass {} + > 11 │ @1 === 2 class MyClass {} + │ ^^^^^ + 12 │ @new Object() class MyClass {} + 13 │ @{} class MyClass {} + +-- +decorator.ts:12:2 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Invalid decorator `new Object()` + + 10 │ @obj instanceof Object class MyClass {} + 11 │ @1 === 2 class MyClass {} + > 12 │ @new Object() class MyClass {} + │ ^^^^^^^^^^^^ + 13 │ @{} class MyClass {} + 14 │ @a++ class MyClass {} + +-- +decorator.ts:13:2 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Invalid decorator `{}` + + 11 │ @1 === 2 class MyClass {} + 12 │ @new Object() class MyClass {} + > 13 │ @{} class MyClass {} + │ ^^ + 14 │ @a++ class MyClass {} + 15 │ @a,b class MyClass {} + +-- +decorator.ts:14:1 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Decorators are not valid here. + + 12 │ @new Object() class MyClass {} + 13 │ @{} class MyClass {} + > 14 │ @a++ class MyClass {} + │ ^^ + 15 │ @a,b class MyClass {} + 16 │ @`${d}foo` class MyClass {} + +-- +decorator.ts:14:6 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Invalid assignment to `class MyClass {}` + + 12 │ @new Object() class MyClass {} + 13 │ @{} class MyClass {} + > 14 │ @a++ class MyClass {} + │ ^^^^^^^^^^^^^^^^ + 15 │ @a,b class MyClass {} + 16 │ @`${d}foo` class MyClass {} + + i This expression cannot be assigned to + +-- +decorator.ts:15:1 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Decorators are not valid here. + + 13 │ @{} class MyClass {} + 14 │ @a++ class MyClass {} + > 15 │ @a,b class MyClass {} + │ ^^ + 16 │ @`${d}foo` class MyClass {} + 17 │ @obj as MyType class MyClass {} + +-- +decorator.ts:15:3 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × expected a statement but instead found ',b' + + 13 │ @{} class MyClass {} + 14 │ @a++ class MyClass {} + > 15 │ @a,b class MyClass {} + │ ^^ + 16 │ @`${d}foo` class MyClass {} + 17 │ @obj as MyType class MyClass {} + + i Expected a statement here + + 13 │ @{} class MyClass {} + 14 │ @a++ class MyClass {} + > 15 │ @a,b class MyClass {} + │ ^^ + 16 │ @`${d}foo` class MyClass {} + 17 │ @obj as MyType class MyClass {} + +-- +decorator.ts:16:2 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Invalid decorator ``${d}foo`` + + 14 │ @a++ class MyClass {} + 15 │ @a,b class MyClass {} + > 16 │ @`${d}foo` class MyClass {} + │ ^^^^^^^^^ + 17 │ @obj as MyType class MyClass {} + 18 │ @obj class MyClass {} + +-- +decorator.ts:17:1 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Decorators are not valid here. + + 15 │ @a,b class MyClass {} + 16 │ @`${d}foo` class MyClass {} + > 17 │ @obj as MyType class MyClass {} + │ ^^^^ + 18 │ @obj class MyClass {} + 19 │ @obj satisfies MyType class MyClass {} + +-- +decorator.ts:17:9 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 15 │ @a,b class MyClass {} + 16 │ @`${d}foo` class MyClass {} + > 17 │ @obj as MyType class MyClass {} + │ ^^^^^^ + 18 │ @obj class MyClass {} + 19 │ @obj satisfies MyType class MyClass {} + + i An explicit or implicit semicolon is expected here... + + 15 │ @a,b class MyClass {} + 16 │ @`${d}foo` class MyClass {} + > 17 │ @obj as MyType class MyClass {} + │ ^^^^^^ + 18 │ @obj class MyClass {} + 19 │ @obj satisfies MyType class MyClass {} + + i ...Which is required to end this statement + + 15 │ @a,b class MyClass {} + 16 │ @`${d}foo` class MyClass {} + > 17 │ @obj as MyType class MyClass {} + │ ^^^^^^^^^ + 18 │ @obj class MyClass {} + 19 │ @obj satisfies MyType class MyClass {} + +-- +decorator.ts:17:16 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 15 │ @a,b class MyClass {} + 16 │ @`${d}foo` class MyClass {} + > 17 │ @obj as MyType class MyClass {} + │ ^^^^^ + 18 │ @obj class MyClass {} + 19 │ @obj satisfies MyType class MyClass {} + + i An explicit or implicit semicolon is expected here... + + 15 │ @a,b class MyClass {} + 16 │ @`${d}foo` class MyClass {} + > 17 │ @obj as MyType class MyClass {} + │ ^^^^^ + 18 │ @obj class MyClass {} + 19 │ @obj satisfies MyType class MyClass {} + + i ...Which is required to end this statement + + 15 │ @a,b class MyClass {} + 16 │ @`${d}foo` class MyClass {} + > 17 │ @obj as MyType class MyClass {} + │ ^^^^^^^^^^^^ + 18 │ @obj class MyClass {} + 19 │ @obj satisfies MyType class MyClass {} + +-- +decorator.ts:18:2 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × expected an expression but instead found '<' + + 16 │ @`${d}foo` class MyClass {} + 17 │ @obj as MyType class MyClass {} + > 18 │ @obj class MyClass {} + │ ^ + 19 │ @obj satisfies MyType class MyClass {} + 20 │ @obj! class MyClass {} + + i Expected an expression here + + 16 │ @`${d}foo` class MyClass {} + 17 │ @obj as MyType class MyClass {} + > 18 │ @obj class MyClass {} + │ ^ + 19 │ @obj satisfies MyType class MyClass {} + 20 │ @obj! class MyClass {} + +-- +decorator.ts:18:1 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Decorators are not valid here. + + 16 │ @`${d}foo` class MyClass {} + 17 │ @obj as MyType class MyClass {} + > 18 │ @obj class MyClass {} + │ ^ + 19 │ @obj satisfies MyType class MyClass {} + 20 │ @obj! class MyClass {} + +-- +decorator.ts:18:14 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 16 │ @`${d}foo` class MyClass {} + 17 │ @obj as MyType class MyClass {} + > 18 │ @obj class MyClass {} + │ ^^^^^ + 19 │ @obj satisfies MyType class MyClass {} + 20 │ @obj! class MyClass {} + + i An explicit or implicit semicolon is expected here... + + 16 │ @`${d}foo` class MyClass {} + 17 │ @obj as MyType class MyClass {} + > 18 │ @obj class MyClass {} + │ ^^^^^ + 19 │ @obj satisfies MyType class MyClass {} + 20 │ @obj! class MyClass {} + + i ...Which is required to end this statement + + 16 │ @`${d}foo` class MyClass {} + 17 │ @obj as MyType class MyClass {} + > 18 │ @obj class MyClass {} + │ ^^^^^^^^^^^^^^^^^ + 19 │ @obj satisfies MyType class MyClass {} + 20 │ @obj! class MyClass {} + +-- +decorator.ts:19:1 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Decorators are not valid here. + + 17 │ @obj as MyType class MyClass {} + 18 │ @obj class MyClass {} + > 19 │ @obj satisfies MyType class MyClass {} + │ ^^^^ + 20 │ @obj! class MyClass {} + 21 │ + +-- +decorator.ts:19:16 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 17 │ @obj as MyType class MyClass {} + 18 │ @obj class MyClass {} + > 19 │ @obj satisfies MyType class MyClass {} + │ ^^^^^^ + 20 │ @obj! class MyClass {} + 21 │ + + i An explicit or implicit semicolon is expected here... + + 17 │ @obj as MyType class MyClass {} + 18 │ @obj class MyClass {} + > 19 │ @obj satisfies MyType class MyClass {} + │ ^^^^^^ + 20 │ @obj! class MyClass {} + 21 │ + + i ...Which is required to end this statement + + 17 │ @obj as MyType class MyClass {} + 18 │ @obj class MyClass {} + > 19 │ @obj satisfies MyType class MyClass {} + │ ^^^^^^^^^^^^^^^^ + 20 │ @obj! class MyClass {} + 21 │ + +-- +decorator.ts:19:23 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 17 │ @obj as MyType class MyClass {} + 18 │ @obj class MyClass {} + > 19 │ @obj satisfies MyType class MyClass {} + │ ^^^^^ + 20 │ @obj! class MyClass {} + 21 │ + + i An explicit or implicit semicolon is expected here... + + 17 │ @obj as MyType class MyClass {} + 18 │ @obj class MyClass {} + > 19 │ @obj satisfies MyType class MyClass {} + │ ^^^^^ + 20 │ @obj! class MyClass {} + 21 │ + + i ...Which is required to end this statement + + 17 │ @obj as MyType class MyClass {} + 18 │ @obj class MyClass {} + > 19 │ @obj satisfies MyType class MyClass {} + │ ^^^^^^^^^^^^ + 20 │ @obj! class MyClass {} + 21 │ + +-- +decorator.ts:20:2 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Invalid decorator `obj!` + + 18 │ @obj class MyClass {} + 19 │ @obj satisfies MyType class MyClass {} + > 20 │ @obj! class MyClass {} + │ ^^^^ + 21 │ + +-- +@'dsads' class MyClass {} +@1 class MyClass {} +@++1 class MyClass {} +@[] in 1 class MyClass {} +@[] class MyClass {} +@() => {} class MyClass {} +@1 == 2 ? true : false class MyClass {} +@await fn class MyClass {} +@function(){} class MyClass {} +@obj instanceof Object class MyClass {} +@1 === 2 class MyClass {} +@new Object() class MyClass {} +@{} class MyClass {} +@a++ class MyClass {} +@a,b class MyClass {} +@`${d}foo` class MyClass {} +@obj as MyType class MyClass {} +@obj class MyClass {} +@obj satisfies MyType class MyClass {} +@obj! class MyClass {} diff --git a/crates/rome_js_parser/test_data/inline/err/decorator.ts b/crates/rome_js_parser/test_data/inline/err/decorator.ts new file mode 100644 index 00000000000..40e784c41c7 --- /dev/null +++ b/crates/rome_js_parser/test_data/inline/err/decorator.ts @@ -0,0 +1,20 @@ +@'dsads' class MyClass {} +@1 class MyClass {} +@++1 class MyClass {} +@[] in 1 class MyClass {} +@[] class MyClass {} +@() => {} class MyClass {} +@1 == 2 ? true : false class MyClass {} +@await fn class MyClass {} +@function(){} class MyClass {} +@obj instanceof Object class MyClass {} +@1 === 2 class MyClass {} +@new Object() class MyClass {} +@{} class MyClass {} +@a++ class MyClass {} +@a,b class MyClass {} +@`${d}foo` class MyClass {} +@obj as MyType class MyClass {} +@obj class MyClass {} +@obj satisfies MyType class MyClass {} +@obj! class MyClass {} diff --git a/crates/rome_js_parser/test_data/inline/err/decorator_class_declaration.js b/crates/rome_js_parser/test_data/inline/err/decorator_class_declaration.js new file mode 100644 index 00000000000..4020e8382eb --- /dev/null +++ b/crates/rome_js_parser/test_data/inline/err/decorator_class_declaration.js @@ -0,0 +1,6 @@ +function bar() { + @decorator + let a; + @decorator @decorator2 + function Foo() { } +} diff --git a/crates/rome_js_parser/test_data/inline/err/decorator_class_declaration.rast b/crates/rome_js_parser/test_data/inline/err/decorator_class_declaration.rast new file mode 100644 index 00000000000..b29e008143e --- /dev/null +++ b/crates/rome_js_parser/test_data/inline/err/decorator_class_declaration.rast @@ -0,0 +1,194 @@ +JsModule { + interpreter_token: missing (optional), + directives: JsDirectiveList [], + items: JsModuleItemList [ + JsFunctionDeclaration { + async_token: missing (optional), + function_token: FUNCTION_KW@0..9 "function" [] [Whitespace(" ")], + star_token: missing (optional), + id: JsIdentifierBinding { + name_token: IDENT@9..12 "bar" [] [], + }, + type_parameters: missing (optional), + parameters: JsParameters { + l_paren_token: L_PAREN@12..13 "(" [] [], + items: JsParameterList [], + r_paren_token: R_PAREN@13..15 ")" [] [Whitespace(" ")], + }, + return_type_annotation: missing (optional), + body: JsFunctionBody { + l_curly_token: L_CURLY@15..16 "{" [] [], + directives: JsDirectiveList [], + statements: JsStatementList [ + JsBogusStatement { + items: [ + JsDecorator { + at_token: AT@16..23 "@" [Newline("\n"), Whitespace(" ")] [], + expression: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@23..32 "decorator" [] [], + }, + }, + }, + ], + }, + JsVariableStatement { + declaration: JsVariableDeclaration { + kind: LET_KW@32..42 "let" [Newline("\n"), Whitespace(" ")] [Whitespace(" ")], + declarators: JsVariableDeclaratorList [ + JsVariableDeclarator { + id: JsIdentifierBinding { + name_token: IDENT@42..43 "a" [] [], + }, + variable_annotation: missing (optional), + initializer: missing (optional), + }, + ], + }, + semicolon_token: SEMICOLON@43..44 ";" [] [], + }, + JsBogusStatement { + items: [ + JsDecorator { + at_token: AT@44..51 "@" [Newline("\n"), Whitespace(" ")] [], + expression: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@51..61 "decorator" [] [Whitespace(" ")], + }, + }, + }, + JsDecorator { + at_token: AT@61..62 "@" [] [], + expression: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@62..72 "decorator2" [] [], + }, + }, + }, + ], + }, + JsFunctionDeclaration { + async_token: missing (optional), + function_token: FUNCTION_KW@72..87 "function" [Newline("\n"), Whitespace(" ")] [Whitespace(" ")], + star_token: missing (optional), + id: JsIdentifierBinding { + name_token: IDENT@87..90 "Foo" [] [], + }, + type_parameters: missing (optional), + parameters: JsParameters { + l_paren_token: L_PAREN@90..91 "(" [] [], + items: JsParameterList [], + r_paren_token: R_PAREN@91..93 ")" [] [Whitespace(" ")], + }, + return_type_annotation: missing (optional), + body: JsFunctionBody { + l_curly_token: L_CURLY@93..95 "{" [] [Whitespace(" ")], + directives: JsDirectiveList [], + statements: JsStatementList [], + r_curly_token: R_CURLY@95..96 "}" [] [], + }, + }, + ], + r_curly_token: R_CURLY@96..98 "}" [Newline("\n")] [], + }, + }, + ], + eof_token: EOF@98..99 "" [Newline("\n")] [], +} + +0: JS_MODULE@0..99 + 0: (empty) + 1: JS_DIRECTIVE_LIST@0..0 + 2: JS_MODULE_ITEM_LIST@0..98 + 0: JS_FUNCTION_DECLARATION@0..98 + 0: (empty) + 1: FUNCTION_KW@0..9 "function" [] [Whitespace(" ")] + 2: (empty) + 3: JS_IDENTIFIER_BINDING@9..12 + 0: IDENT@9..12 "bar" [] [] + 4: (empty) + 5: JS_PARAMETERS@12..15 + 0: L_PAREN@12..13 "(" [] [] + 1: JS_PARAMETER_LIST@13..13 + 2: R_PAREN@13..15 ")" [] [Whitespace(" ")] + 6: (empty) + 7: JS_FUNCTION_BODY@15..98 + 0: L_CURLY@15..16 "{" [] [] + 1: JS_DIRECTIVE_LIST@16..16 + 2: JS_STATEMENT_LIST@16..96 + 0: JS_BOGUS_STATEMENT@16..32 + 0: JS_DECORATOR@16..32 + 0: AT@16..23 "@" [Newline("\n"), Whitespace(" ")] [] + 1: JS_IDENTIFIER_EXPRESSION@23..32 + 0: JS_REFERENCE_IDENTIFIER@23..32 + 0: IDENT@23..32 "decorator" [] [] + 1: JS_VARIABLE_STATEMENT@32..44 + 0: JS_VARIABLE_DECLARATION@32..43 + 0: LET_KW@32..42 "let" [Newline("\n"), Whitespace(" ")] [Whitespace(" ")] + 1: JS_VARIABLE_DECLARATOR_LIST@42..43 + 0: JS_VARIABLE_DECLARATOR@42..43 + 0: JS_IDENTIFIER_BINDING@42..43 + 0: IDENT@42..43 "a" [] [] + 1: (empty) + 2: (empty) + 1: SEMICOLON@43..44 ";" [] [] + 2: JS_BOGUS_STATEMENT@44..72 + 0: JS_DECORATOR@44..61 + 0: AT@44..51 "@" [Newline("\n"), Whitespace(" ")] [] + 1: JS_IDENTIFIER_EXPRESSION@51..61 + 0: JS_REFERENCE_IDENTIFIER@51..61 + 0: IDENT@51..61 "decorator" [] [Whitespace(" ")] + 1: JS_DECORATOR@61..72 + 0: AT@61..62 "@" [] [] + 1: JS_IDENTIFIER_EXPRESSION@62..72 + 0: JS_REFERENCE_IDENTIFIER@62..72 + 0: IDENT@62..72 "decorator2" [] [] + 3: JS_FUNCTION_DECLARATION@72..96 + 0: (empty) + 1: FUNCTION_KW@72..87 "function" [Newline("\n"), Whitespace(" ")] [Whitespace(" ")] + 2: (empty) + 3: JS_IDENTIFIER_BINDING@87..90 + 0: IDENT@87..90 "Foo" [] [] + 4: (empty) + 5: JS_PARAMETERS@90..93 + 0: L_PAREN@90..91 "(" [] [] + 1: JS_PARAMETER_LIST@91..91 + 2: R_PAREN@91..93 ")" [] [Whitespace(" ")] + 6: (empty) + 7: JS_FUNCTION_BODY@93..96 + 0: L_CURLY@93..95 "{" [] [Whitespace(" ")] + 1: JS_DIRECTIVE_LIST@95..95 + 2: JS_STATEMENT_LIST@95..95 + 3: R_CURLY@95..96 "}" [] [] + 3: R_CURLY@96..98 "}" [Newline("\n")] [] + 3: EOF@98..99 "" [Newline("\n")] [] +-- +decorator_class_declaration.js:2:6 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Decorators are not valid here. + + 1 │ function bar() { + > 2 │ @decorator + │ ^^^^^^^^^^ + 3 │ let a; + 4 │ @decorator @decorator2 + +-- +decorator_class_declaration.js:4:6 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Decorators are not valid here. + + 2 │ @decorator + 3 │ let a; + > 4 │ @decorator @decorator2 + │ ^^^^^^^^^^^^^^^^^^^^^^ + 5 │ function Foo() { } + 6 │ } + +-- +function bar() { + @decorator + let a; + @decorator @decorator2 + function Foo() { } +} diff --git a/crates/rome_js_parser/test_data/inline/err/decorator_class_declaration_top_level.js b/crates/rome_js_parser/test_data/inline/err/decorator_class_declaration_top_level.js new file mode 100644 index 00000000000..372c89a45c3 --- /dev/null +++ b/crates/rome_js_parser/test_data/inline/err/decorator_class_declaration_top_level.js @@ -0,0 +1,4 @@ +@decorator +let a; +@decorator1 @decorator2 +function Foo() { } diff --git a/crates/rome_js_parser/test_data/inline/err/decorator_class_declaration_top_level.rast b/crates/rome_js_parser/test_data/inline/err/decorator_class_declaration_top_level.rast new file mode 100644 index 00000000000..2c7b9b9bfff --- /dev/null +++ b/crates/rome_js_parser/test_data/inline/err/decorator_class_declaration_top_level.rast @@ -0,0 +1,152 @@ +JsModule { + interpreter_token: missing (optional), + directives: JsDirectiveList [], + items: JsModuleItemList [ + JsBogusStatement { + items: [ + JsDecorator { + at_token: AT@0..1 "@" [] [], + expression: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@1..10 "decorator" [] [], + }, + }, + }, + ], + }, + JsVariableStatement { + declaration: JsVariableDeclaration { + kind: LET_KW@10..15 "let" [Newline("\n")] [Whitespace(" ")], + declarators: JsVariableDeclaratorList [ + JsVariableDeclarator { + id: JsIdentifierBinding { + name_token: IDENT@15..16 "a" [] [], + }, + variable_annotation: missing (optional), + initializer: missing (optional), + }, + ], + }, + semicolon_token: SEMICOLON@16..17 ";" [] [], + }, + JsBogusStatement { + items: [ + JsDecorator { + at_token: AT@17..19 "@" [Newline("\n")] [], + expression: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@19..30 "decorator1" [] [Whitespace(" ")], + }, + }, + }, + JsDecorator { + at_token: AT@30..31 "@" [] [], + expression: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@31..41 "decorator2" [] [], + }, + }, + }, + ], + }, + JsFunctionDeclaration { + async_token: missing (optional), + function_token: FUNCTION_KW@41..51 "function" [Newline("\n")] [Whitespace(" ")], + star_token: missing (optional), + id: JsIdentifierBinding { + name_token: IDENT@51..54 "Foo" [] [], + }, + type_parameters: missing (optional), + parameters: JsParameters { + l_paren_token: L_PAREN@54..55 "(" [] [], + items: JsParameterList [], + r_paren_token: R_PAREN@55..57 ")" [] [Whitespace(" ")], + }, + return_type_annotation: missing (optional), + body: JsFunctionBody { + l_curly_token: L_CURLY@57..59 "{" [] [Whitespace(" ")], + directives: JsDirectiveList [], + statements: JsStatementList [], + r_curly_token: R_CURLY@59..60 "}" [] [], + }, + }, + ], + eof_token: EOF@60..61 "" [Newline("\n")] [], +} + +0: JS_MODULE@0..61 + 0: (empty) + 1: JS_DIRECTIVE_LIST@0..0 + 2: JS_MODULE_ITEM_LIST@0..60 + 0: JS_BOGUS_STATEMENT@0..10 + 0: JS_DECORATOR@0..10 + 0: AT@0..1 "@" [] [] + 1: JS_IDENTIFIER_EXPRESSION@1..10 + 0: JS_REFERENCE_IDENTIFIER@1..10 + 0: IDENT@1..10 "decorator" [] [] + 1: JS_VARIABLE_STATEMENT@10..17 + 0: JS_VARIABLE_DECLARATION@10..16 + 0: LET_KW@10..15 "let" [Newline("\n")] [Whitespace(" ")] + 1: JS_VARIABLE_DECLARATOR_LIST@15..16 + 0: JS_VARIABLE_DECLARATOR@15..16 + 0: JS_IDENTIFIER_BINDING@15..16 + 0: IDENT@15..16 "a" [] [] + 1: (empty) + 2: (empty) + 1: SEMICOLON@16..17 ";" [] [] + 2: JS_BOGUS_STATEMENT@17..41 + 0: JS_DECORATOR@17..30 + 0: AT@17..19 "@" [Newline("\n")] [] + 1: JS_IDENTIFIER_EXPRESSION@19..30 + 0: JS_REFERENCE_IDENTIFIER@19..30 + 0: IDENT@19..30 "decorator1" [] [Whitespace(" ")] + 1: JS_DECORATOR@30..41 + 0: AT@30..31 "@" [] [] + 1: JS_IDENTIFIER_EXPRESSION@31..41 + 0: JS_REFERENCE_IDENTIFIER@31..41 + 0: IDENT@31..41 "decorator2" [] [] + 3: JS_FUNCTION_DECLARATION@41..60 + 0: (empty) + 1: FUNCTION_KW@41..51 "function" [Newline("\n")] [Whitespace(" ")] + 2: (empty) + 3: JS_IDENTIFIER_BINDING@51..54 + 0: IDENT@51..54 "Foo" [] [] + 4: (empty) + 5: JS_PARAMETERS@54..57 + 0: L_PAREN@54..55 "(" [] [] + 1: JS_PARAMETER_LIST@55..55 + 2: R_PAREN@55..57 ")" [] [Whitespace(" ")] + 6: (empty) + 7: JS_FUNCTION_BODY@57..60 + 0: L_CURLY@57..59 "{" [] [Whitespace(" ")] + 1: JS_DIRECTIVE_LIST@59..59 + 2: JS_STATEMENT_LIST@59..59 + 3: R_CURLY@59..60 "}" [] [] + 3: EOF@60..61 "" [Newline("\n")] [] +-- +decorator_class_declaration_top_level.js:1:1 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Decorators are not valid here. + + > 1 │ @decorator + │ ^^^^^^^^^^ + 2 │ let a; + 3 │ @decorator1 @decorator2 + +-- +decorator_class_declaration_top_level.js:3:1 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Decorators are not valid here. + + 1 │ @decorator + 2 │ let a; + > 3 │ @decorator1 @decorator2 + │ ^^^^^^^^^^^^^^^^^^^^^^^ + 4 │ function Foo() { } + 5 │ + +-- +@decorator +let a; +@decorator1 @decorator2 +function Foo() { } diff --git a/crates/rome_js_parser/test_data/inline/err/decorator_export_class_clause.js b/crates/rome_js_parser/test_data/inline/err/decorator_export_class_clause.js new file mode 100644 index 00000000000..e0e7f0ab582 --- /dev/null +++ b/crates/rome_js_parser/test_data/inline/err/decorator_export_class_clause.js @@ -0,0 +1,4 @@ +@decorator +export let a; +@decorator1 @decorator2 +export function Foo() { } diff --git a/crates/rome_js_parser/test_data/inline/err/decorator_export_class_clause.rast b/crates/rome_js_parser/test_data/inline/err/decorator_export_class_clause.rast new file mode 100644 index 00000000000..0a1f2c7513b --- /dev/null +++ b/crates/rome_js_parser/test_data/inline/err/decorator_export_class_clause.rast @@ -0,0 +1,162 @@ +JsModule { + interpreter_token: missing (optional), + directives: JsDirectiveList [], + items: JsModuleItemList [ + JsBogusStatement { + items: [ + JsDecorator { + at_token: AT@0..1 "@" [] [], + expression: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@1..10 "decorator" [] [], + }, + }, + }, + ], + }, + JsExport { + export_token: EXPORT_KW@10..18 "export" [Newline("\n")] [Whitespace(" ")], + export_clause: JsVariableDeclarationClause { + declaration: JsVariableDeclaration { + kind: LET_KW@18..22 "let" [] [Whitespace(" ")], + declarators: JsVariableDeclaratorList [ + JsVariableDeclarator { + id: JsIdentifierBinding { + name_token: IDENT@22..23 "a" [] [], + }, + variable_annotation: missing (optional), + initializer: missing (optional), + }, + ], + }, + semicolon_token: SEMICOLON@23..24 ";" [] [], + }, + }, + JsBogusStatement { + items: [ + JsDecorator { + at_token: AT@24..26 "@" [Newline("\n")] [], + expression: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@26..37 "decorator1" [] [Whitespace(" ")], + }, + }, + }, + JsDecorator { + at_token: AT@37..38 "@" [] [], + expression: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@38..48 "decorator2" [] [], + }, + }, + }, + ], + }, + JsExport { + export_token: EXPORT_KW@48..56 "export" [Newline("\n")] [Whitespace(" ")], + export_clause: JsFunctionDeclaration { + async_token: missing (optional), + function_token: FUNCTION_KW@56..65 "function" [] [Whitespace(" ")], + star_token: missing (optional), + id: JsIdentifierBinding { + name_token: IDENT@65..68 "Foo" [] [], + }, + type_parameters: missing (optional), + parameters: JsParameters { + l_paren_token: L_PAREN@68..69 "(" [] [], + items: JsParameterList [], + r_paren_token: R_PAREN@69..71 ")" [] [Whitespace(" ")], + }, + return_type_annotation: missing (optional), + body: JsFunctionBody { + l_curly_token: L_CURLY@71..73 "{" [] [Whitespace(" ")], + directives: JsDirectiveList [], + statements: JsStatementList [], + r_curly_token: R_CURLY@73..74 "}" [] [], + }, + }, + }, + ], + eof_token: EOF@74..75 "" [Newline("\n")] [], +} + +0: JS_MODULE@0..75 + 0: (empty) + 1: JS_DIRECTIVE_LIST@0..0 + 2: JS_MODULE_ITEM_LIST@0..74 + 0: JS_BOGUS_STATEMENT@0..10 + 0: JS_DECORATOR@0..10 + 0: AT@0..1 "@" [] [] + 1: JS_IDENTIFIER_EXPRESSION@1..10 + 0: JS_REFERENCE_IDENTIFIER@1..10 + 0: IDENT@1..10 "decorator" [] [] + 1: JS_EXPORT@10..24 + 0: EXPORT_KW@10..18 "export" [Newline("\n")] [Whitespace(" ")] + 1: JS_VARIABLE_DECLARATION_CLAUSE@18..24 + 0: JS_VARIABLE_DECLARATION@18..23 + 0: LET_KW@18..22 "let" [] [Whitespace(" ")] + 1: JS_VARIABLE_DECLARATOR_LIST@22..23 + 0: JS_VARIABLE_DECLARATOR@22..23 + 0: JS_IDENTIFIER_BINDING@22..23 + 0: IDENT@22..23 "a" [] [] + 1: (empty) + 2: (empty) + 1: SEMICOLON@23..24 ";" [] [] + 2: JS_BOGUS_STATEMENT@24..48 + 0: JS_DECORATOR@24..37 + 0: AT@24..26 "@" [Newline("\n")] [] + 1: JS_IDENTIFIER_EXPRESSION@26..37 + 0: JS_REFERENCE_IDENTIFIER@26..37 + 0: IDENT@26..37 "decorator1" [] [Whitespace(" ")] + 1: JS_DECORATOR@37..48 + 0: AT@37..38 "@" [] [] + 1: JS_IDENTIFIER_EXPRESSION@38..48 + 0: JS_REFERENCE_IDENTIFIER@38..48 + 0: IDENT@38..48 "decorator2" [] [] + 3: JS_EXPORT@48..74 + 0: EXPORT_KW@48..56 "export" [Newline("\n")] [Whitespace(" ")] + 1: JS_FUNCTION_DECLARATION@56..74 + 0: (empty) + 1: FUNCTION_KW@56..65 "function" [] [Whitespace(" ")] + 2: (empty) + 3: JS_IDENTIFIER_BINDING@65..68 + 0: IDENT@65..68 "Foo" [] [] + 4: (empty) + 5: JS_PARAMETERS@68..71 + 0: L_PAREN@68..69 "(" [] [] + 1: JS_PARAMETER_LIST@69..69 + 2: R_PAREN@69..71 ")" [] [Whitespace(" ")] + 6: (empty) + 7: JS_FUNCTION_BODY@71..74 + 0: L_CURLY@71..73 "{" [] [Whitespace(" ")] + 1: JS_DIRECTIVE_LIST@73..73 + 2: JS_STATEMENT_LIST@73..73 + 3: R_CURLY@73..74 "}" [] [] + 3: EOF@74..75 "" [Newline("\n")] [] +-- +decorator_export_class_clause.js:1:1 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Decorators are not valid here. + + > 1 │ @decorator + │ ^^^^^^^^^^ + 2 │ export let a; + 3 │ @decorator1 @decorator2 + +-- +decorator_export_class_clause.js:3:1 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Decorators are not valid here. + + 1 │ @decorator + 2 │ export let a; + > 3 │ @decorator1 @decorator2 + │ ^^^^^^^^^^^^^^^^^^^^^^^ + 4 │ export function Foo() { } + 5 │ + +-- +@decorator +export let a; +@decorator1 @decorator2 +export function Foo() { } diff --git a/crates/rome_js_parser/test_data/inline/err/decorator_expression_class.js b/crates/rome_js_parser/test_data/inline/err/decorator_expression_class.js new file mode 100644 index 00000000000..b714579375d --- /dev/null +++ b/crates/rome_js_parser/test_data/inline/err/decorator_expression_class.js @@ -0,0 +1,3 @@ +let a = @decorator () => {}; +let b = @first @second function foo {} +let a = @decorator ( () => {} ) diff --git a/crates/rome_js_parser/test_data/inline/err/decorator_expression_class.rast b/crates/rome_js_parser/test_data/inline/err/decorator_expression_class.rast new file mode 100644 index 00000000000..0915406adc7 --- /dev/null +++ b/crates/rome_js_parser/test_data/inline/err/decorator_expression_class.rast @@ -0,0 +1,386 @@ +JsModule { + interpreter_token: missing (optional), + directives: JsDirectiveList [], + items: JsModuleItemList [ + JsBogusStatement { + items: [ + JsBogus { + items: [ + LET_KW@0..4 "let" [] [Whitespace(" ")], + JsBogus { + items: [ + JsBogus { + items: [ + JsIdentifierBinding { + name_token: IDENT@4..6 "a" [] [Whitespace(" ")], + }, + JsBogus { + items: [ + EQ@6..8 "=" [] [Whitespace(" ")], + JsBogusExpression { + items: [ + JsDecorator { + at_token: AT@8..9 "@" [] [], + expression: JsCallExpression { + callee: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@9..19 "decorator" [] [Whitespace(" ")], + }, + }, + optional_chain_token: missing (optional), + type_arguments: missing (optional), + arguments: JsCallArguments { + l_paren_token: L_PAREN@19..20 "(" [] [], + args: JsCallArgumentList [], + r_paren_token: R_PAREN@20..22 ")" [] [Whitespace(" ")], + }, + }, + }, + ], + }, + JsArrowFunctionExpression { + async_token: missing (optional), + type_parameters: missing (optional), + parameters: missing (required), + return_type_annotation: missing (optional), + fat_arrow_token: FAT_ARROW@22..25 "=>" [] [Whitespace(" ")], + body: JsFunctionBody { + l_curly_token: L_CURLY@25..26 "{" [] [], + directives: JsDirectiveList [], + statements: JsStatementList [], + r_curly_token: R_CURLY@26..27 "}" [] [], + }, + }, + ], + }, + ], + }, + ], + }, + ], + }, + SEMICOLON@27..28 ";" [] [], + ], + }, + JsBogusStatement { + items: [ + JsBogus { + items: [ + LET_KW@28..33 "let" [Newline("\n")] [Whitespace(" ")], + JsBogus { + items: [ + JsBogus { + items: [ + JsIdentifierBinding { + name_token: IDENT@33..35 "b" [] [Whitespace(" ")], + }, + JsBogus { + items: [ + EQ@35..37 "=" [] [Whitespace(" ")], + JsBogusExpression { + items: [ + JsDecorator { + at_token: AT@37..38 "@" [] [], + expression: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@38..44 "first" [] [Whitespace(" ")], + }, + }, + }, + JsDecorator { + at_token: AT@44..45 "@" [] [], + expression: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@45..52 "second" [] [Whitespace(" ")], + }, + }, + }, + ], + }, + JsFunctionExpression { + async_token: missing (optional), + function_token: FUNCTION_KW@52..61 "function" [] [Whitespace(" ")], + star_token: missing (optional), + id: JsIdentifierBinding { + name_token: IDENT@61..65 "foo" [] [Whitespace(" ")], + }, + type_parameters: missing (optional), + parameters: missing (required), + return_type_annotation: missing (optional), + body: JsFunctionBody { + l_curly_token: L_CURLY@65..66 "{" [] [], + directives: JsDirectiveList [], + statements: JsStatementList [], + r_curly_token: R_CURLY@66..67 "}" [] [], + }, + }, + ], + }, + ], + }, + ], + }, + ], + }, + ], + }, + JsVariableStatement { + declaration: JsVariableDeclaration { + kind: LET_KW@67..72 "let" [Newline("\n")] [Whitespace(" ")], + declarators: JsVariableDeclaratorList [ + JsVariableDeclarator { + id: JsIdentifierBinding { + name_token: IDENT@72..74 "a" [] [Whitespace(" ")], + }, + variable_annotation: missing (optional), + initializer: JsInitializerClause { + eq_token: EQ@74..76 "=" [] [Whitespace(" ")], + expression: JsBogusExpression { + items: [ + JsDecorator { + at_token: AT@76..77 "@" [] [], + expression: JsCallExpression { + callee: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@77..87 "decorator" [] [Whitespace(" ")], + }, + }, + optional_chain_token: missing (optional), + type_arguments: missing (optional), + arguments: JsCallArguments { + l_paren_token: L_PAREN@87..89 "(" [] [Whitespace(" ")], + args: JsCallArgumentList [ + JsArrowFunctionExpression { + async_token: missing (optional), + type_parameters: missing (optional), + parameters: JsParameters { + l_paren_token: L_PAREN@89..90 "(" [] [], + items: JsParameterList [], + r_paren_token: R_PAREN@90..92 ")" [] [Whitespace(" ")], + }, + return_type_annotation: missing (optional), + fat_arrow_token: FAT_ARROW@92..95 "=>" [] [Whitespace(" ")], + body: JsFunctionBody { + l_curly_token: L_CURLY@95..96 "{" [] [], + directives: JsDirectiveList [], + statements: JsStatementList [], + r_curly_token: R_CURLY@96..98 "}" [] [Whitespace(" ")], + }, + }, + ], + r_paren_token: R_PAREN@98..99 ")" [] [], + }, + }, + }, + ], + }, + }, + }, + ], + }, + semicolon_token: missing (optional), + }, + ], + eof_token: EOF@99..100 "" [Newline("\n")] [], +} + +0: JS_MODULE@0..100 + 0: (empty) + 1: JS_DIRECTIVE_LIST@0..0 + 2: JS_MODULE_ITEM_LIST@0..99 + 0: JS_BOGUS_STATEMENT@0..28 + 0: JS_BOGUS@0..27 + 0: LET_KW@0..4 "let" [] [Whitespace(" ")] + 1: JS_BOGUS@4..27 + 0: JS_BOGUS@4..27 + 0: JS_IDENTIFIER_BINDING@4..6 + 0: IDENT@4..6 "a" [] [Whitespace(" ")] + 1: JS_BOGUS@6..27 + 0: EQ@6..8 "=" [] [Whitespace(" ")] + 1: JS_BOGUS_EXPRESSION@8..22 + 0: JS_DECORATOR@8..22 + 0: AT@8..9 "@" [] [] + 1: JS_CALL_EXPRESSION@9..22 + 0: JS_IDENTIFIER_EXPRESSION@9..19 + 0: JS_REFERENCE_IDENTIFIER@9..19 + 0: IDENT@9..19 "decorator" [] [Whitespace(" ")] + 1: (empty) + 2: (empty) + 3: JS_CALL_ARGUMENTS@19..22 + 0: L_PAREN@19..20 "(" [] [] + 1: JS_CALL_ARGUMENT_LIST@20..20 + 2: R_PAREN@20..22 ")" [] [Whitespace(" ")] + 2: JS_ARROW_FUNCTION_EXPRESSION@22..27 + 0: (empty) + 1: (empty) + 2: (empty) + 3: (empty) + 4: FAT_ARROW@22..25 "=>" [] [Whitespace(" ")] + 5: JS_FUNCTION_BODY@25..27 + 0: L_CURLY@25..26 "{" [] [] + 1: JS_DIRECTIVE_LIST@26..26 + 2: JS_STATEMENT_LIST@26..26 + 3: R_CURLY@26..27 "}" [] [] + 1: SEMICOLON@27..28 ";" [] [] + 1: JS_BOGUS_STATEMENT@28..67 + 0: JS_BOGUS@28..67 + 0: LET_KW@28..33 "let" [Newline("\n")] [Whitespace(" ")] + 1: JS_BOGUS@33..67 + 0: JS_BOGUS@33..67 + 0: JS_IDENTIFIER_BINDING@33..35 + 0: IDENT@33..35 "b" [] [Whitespace(" ")] + 1: JS_BOGUS@35..67 + 0: EQ@35..37 "=" [] [Whitespace(" ")] + 1: JS_BOGUS_EXPRESSION@37..52 + 0: JS_DECORATOR@37..44 + 0: AT@37..38 "@" [] [] + 1: JS_IDENTIFIER_EXPRESSION@38..44 + 0: JS_REFERENCE_IDENTIFIER@38..44 + 0: IDENT@38..44 "first" [] [Whitespace(" ")] + 1: JS_DECORATOR@44..52 + 0: AT@44..45 "@" [] [] + 1: JS_IDENTIFIER_EXPRESSION@45..52 + 0: JS_REFERENCE_IDENTIFIER@45..52 + 0: IDENT@45..52 "second" [] [Whitespace(" ")] + 2: JS_FUNCTION_EXPRESSION@52..67 + 0: (empty) + 1: FUNCTION_KW@52..61 "function" [] [Whitespace(" ")] + 2: (empty) + 3: JS_IDENTIFIER_BINDING@61..65 + 0: IDENT@61..65 "foo" [] [Whitespace(" ")] + 4: (empty) + 5: (empty) + 6: (empty) + 7: JS_FUNCTION_BODY@65..67 + 0: L_CURLY@65..66 "{" [] [] + 1: JS_DIRECTIVE_LIST@66..66 + 2: JS_STATEMENT_LIST@66..66 + 3: R_CURLY@66..67 "}" [] [] + 2: JS_VARIABLE_STATEMENT@67..99 + 0: JS_VARIABLE_DECLARATION@67..99 + 0: LET_KW@67..72 "let" [Newline("\n")] [Whitespace(" ")] + 1: JS_VARIABLE_DECLARATOR_LIST@72..99 + 0: JS_VARIABLE_DECLARATOR@72..99 + 0: JS_IDENTIFIER_BINDING@72..74 + 0: IDENT@72..74 "a" [] [Whitespace(" ")] + 1: (empty) + 2: JS_INITIALIZER_CLAUSE@74..99 + 0: EQ@74..76 "=" [] [Whitespace(" ")] + 1: JS_BOGUS_EXPRESSION@76..99 + 0: JS_DECORATOR@76..99 + 0: AT@76..77 "@" [] [] + 1: JS_CALL_EXPRESSION@77..99 + 0: JS_IDENTIFIER_EXPRESSION@77..87 + 0: JS_REFERENCE_IDENTIFIER@77..87 + 0: IDENT@77..87 "decorator" [] [Whitespace(" ")] + 1: (empty) + 2: (empty) + 3: JS_CALL_ARGUMENTS@87..99 + 0: L_PAREN@87..89 "(" [] [Whitespace(" ")] + 1: JS_CALL_ARGUMENT_LIST@89..98 + 0: JS_ARROW_FUNCTION_EXPRESSION@89..98 + 0: (empty) + 1: (empty) + 2: JS_PARAMETERS@89..92 + 0: L_PAREN@89..90 "(" [] [] + 1: JS_PARAMETER_LIST@90..90 + 2: R_PAREN@90..92 ")" [] [Whitespace(" ")] + 3: (empty) + 4: FAT_ARROW@92..95 "=>" [] [Whitespace(" ")] + 5: JS_FUNCTION_BODY@95..98 + 0: L_CURLY@95..96 "{" [] [] + 1: JS_DIRECTIVE_LIST@96..96 + 2: JS_STATEMENT_LIST@96..96 + 3: R_CURLY@96..98 "}" [] [Whitespace(" ")] + 2: R_PAREN@98..99 ")" [] [] + 1: (empty) + 3: EOF@99..100 "" [Newline("\n")] [] +-- +decorator_expression_class.js:1:9 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Decorators are not valid here. + + > 1 │ let a = @decorator () => {}; + │ ^^^^^^^^^^^^^ + 2 │ let b = @first @second function foo {} + 3 │ let a = @decorator ( () => {} ) + +-- +decorator_expression_class.js:1:23 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × expected a parenthesis '(' but instead found '=>' + + > 1 │ let a = @decorator () => {}; + │ ^^ + 2 │ let b = @first @second function foo {} + 3 │ let a = @decorator ( () => {} ) + + i Expected a parenthesis '(' here + + > 1 │ let a = @decorator () => {}; + │ ^^ + 2 │ let b = @first @second function foo {} + 3 │ let a = @decorator ( () => {} ) + +-- +decorator_expression_class.js:2:9 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Decorators are not valid here. + + 1 │ let a = @decorator () => {}; + > 2 │ let b = @first @second function foo {} + │ ^^^^^^^^^^^^^^ + 3 │ let a = @decorator ( () => {} ) + 4 │ + +-- +decorator_expression_class.js:2:37 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × expected a parenthesis '(' but instead found '{' + + 1 │ let a = @decorator () => {}; + > 2 │ let b = @first @second function foo {} + │ ^ + 3 │ let a = @decorator ( () => {} ) + 4 │ + + i Expected a parenthesis '(' here + + 1 │ let a = @decorator () => {}; + > 2 │ let b = @first @second function foo {} + │ ^ + 3 │ let a = @decorator ( () => {} ) + 4 │ + +-- +decorator_expression_class.js:3:9 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Decorators are not valid here. + + 1 │ let a = @decorator () => {}; + 2 │ let b = @first @second function foo {} + > 3 │ let a = @decorator ( () => {} ) + │ ^^^^^^^^^^^^^^^^^^^^^^^ + 4 │ + +-- +decorator_expression_class.js:4:1 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × expected an expression, or an assignment but instead found the end of the file + + 2 │ let b = @first @second function foo {} + 3 │ let a = @decorator ( () => {} ) + > 4 │ + │ + + i Expected an expression, or an assignment here + + 2 │ let b = @first @second function foo {} + 3 │ let a = @decorator ( () => {} ) + > 4 │ + │ + +-- +let a = @decorator () => {}; +let b = @first @second function foo {} +let a = @decorator ( () => {} ) diff --git a/crates/rome_js_parser/test_data/inline/err/getter_class_no_body.rast b/crates/rome_js_parser/test_data/inline/err/getter_class_no_body.rast index 884da021050..728e6343cad 100644 --- a/crates/rome_js_parser/test_data/inline/err/getter_class_no_body.rast +++ b/crates/rome_js_parser/test_data/inline/err/getter_class_no_body.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@0..6 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -36,15 +37,16 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..29 0: JS_CLASS_DECLARATION@0..29 - 0: (empty) - 1: CLASS_KW@0..6 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@6..14 + 0: JS_DECORATOR_LIST@0..0 + 1: (empty) + 2: CLASS_KW@0..6 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@6..14 0: IDENT@6..14 "Getters" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@14..15 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@15..27 + 6: (empty) + 7: L_CURLY@14..15 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@15..27 0: JS_GETTER_CLASS_MEMBER@15..27 0: JS_METHOD_MODIFIER_LIST@15..15 1: GET_KW@15..22 "get" [Newline("\n"), Whitespace(" ")] [Whitespace(" ")] @@ -54,7 +56,7 @@ JsModule { 4: R_PAREN@26..27 ")" [] [] 5: (empty) 6: (empty) - 8: R_CURLY@27..29 "}" [Newline("\n")] [] + 9: R_CURLY@27..29 "}" [Newline("\n")] [] 3: EOF@29..30 "" [Newline("\n")] [] -- getter_class_no_body.js:3:1 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ diff --git a/crates/rome_js_parser/test_data/inline/err/index_signature_class_member_in_js.rast b/crates/rome_js_parser/test_data/inline/err/index_signature_class_member_in_js.rast index 19496d4c03d..a9352ef0808 100644 --- a/crates/rome_js_parser/test_data/inline/err/index_signature_class_member_in_js.rast +++ b/crates/rome_js_parser/test_data/inline/err/index_signature_class_member_in_js.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@0..6 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -49,15 +50,16 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..36 0: JS_CLASS_DECLARATION@0..36 - 0: (empty) - 1: CLASS_KW@0..6 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@6..8 + 0: JS_DECORATOR_LIST@0..0 + 1: (empty) + 2: CLASS_KW@0..6 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@6..8 0: IDENT@6..8 "A" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@8..9 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@9..34 + 6: (empty) + 7: L_CURLY@8..9 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@9..34 0: JS_BOGUS_MEMBER@9..34 0: L_BRACK@9..15 "[" [Newline("\n"), Whitespace(" ")] [] 1: TS_INDEX_SIGNATURE_PARAMETER@15..24 @@ -73,7 +75,7 @@ JsModule { 1: TS_STRING_TYPE@27..33 0: STRING_KW@27..33 "string" [] [] 4: SEMICOLON@33..34 ";" [] [] - 8: R_CURLY@34..36 "}" [Newline("\n")] [] + 9: R_CURLY@34..36 "}" [Newline("\n")] [] 3: EOF@36..37 "" [Newline("\n")] [] -- index_signature_class_member_in_js.js:2:5 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ diff --git a/crates/rome_js_parser/test_data/inline/err/invalid_method_recover.rast b/crates/rome_js_parser/test_data/inline/err/invalid_method_recover.rast index 2c3acf9b8ac..fddc0c65605 100644 --- a/crates/rome_js_parser/test_data/inline/err/invalid_method_recover.rast +++ b/crates/rome_js_parser/test_data/inline/err/invalid_method_recover.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@0..6 "class" [] [Whitespace(" ")], id: missing (required), @@ -83,14 +84,15 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..47 0: JS_CLASS_DECLARATION@0..46 - 0: (empty) - 1: CLASS_KW@0..6 "class" [] [Whitespace(" ")] - 2: (empty) + 0: JS_DECORATOR_LIST@0..0 + 1: (empty) + 2: CLASS_KW@0..6 "class" [] [Whitespace(" ")] 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@6..7 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@7..44 + 6: (empty) + 7: L_CURLY@6..7 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@7..44 0: JS_PROPERTY_CLASS_MEMBER@7..44 0: JS_PROPERTY_MODIFIER_LIST@7..7 1: JS_COMPUTED_MEMBER_NAME@7..18 @@ -132,7 +134,7 @@ JsModule { 1: SEMICOLON@38..39 ";" [] [] 3: R_CURLY@39..43 "}" [Newline("\n"), Whitespace(" ")] [] 4: SEMICOLON@43..44 ";" [] [] - 8: R_CURLY@44..46 "}" [Newline("\n")] [] + 9: R_CURLY@44..46 "}" [Newline("\n")] [] 1: JS_EMPTY_STATEMENT@46..47 0: SEMICOLON@46..47 ";" [] [] 3: EOF@47..48 "" [Newline("\n")] [] diff --git a/crates/rome_js_parser/test_data/inline/err/js_class_property_with_ts_annotation.rast b/crates/rome_js_parser/test_data/inline/err/js_class_property_with_ts_annotation.rast index 70644f1fd67..656e4b1abda 100644 --- a/crates/rome_js_parser/test_data/inline/err/js_class_property_with_ts_annotation.rast +++ b/crates/rome_js_parser/test_data/inline/err/js_class_property_with_ts_annotation.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@0..6 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -81,15 +82,16 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..48 0: JS_CLASS_DECLARATION@0..48 - 0: (empty) - 1: CLASS_KW@0..6 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@6..8 + 0: JS_DECORATOR_LIST@0..0 + 1: (empty) + 2: CLASS_KW@0..6 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@6..8 0: IDENT@6..8 "A" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@8..9 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@9..46 + 6: (empty) + 7: L_CURLY@8..9 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@9..46 0: JS_BOGUS_MEMBER@9..21 0: JS_PROPERTY_MODIFIER_LIST@9..9 1: JS_LITERAL_MEMBER_NAME@9..12 @@ -120,7 +122,7 @@ JsModule { 0: COLON@38..40 ":" [] [Whitespace(" ")] 1: TS_STRING_TYPE@40..46 0: STRING_KW@40..46 "string" [] [] - 8: R_CURLY@46..48 "}" [Newline("\n")] [] + 9: R_CURLY@46..48 "}" [Newline("\n")] [] 3: EOF@48..49 "" [Newline("\n")] [] -- js_class_property_with_ts_annotation.js:2:3 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ diff --git a/crates/rome_js_parser/test_data/inline/err/js_constructor_parameter_reserved_names.rast b/crates/rome_js_parser/test_data/inline/err/js_constructor_parameter_reserved_names.rast index 60775be0d36..e86318683ef 100644 --- a/crates/rome_js_parser/test_data/inline/err/js_constructor_parameter_reserved_names.rast +++ b/crates/rome_js_parser/test_data/inline/err/js_constructor_parameter_reserved_names.rast @@ -3,6 +3,7 @@ JsScript { directives: JsDirectiveList [], statements: JsStatementList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@0..16 "class" [Comments("// SCRIPT"), Newline("\n")] [Whitespace(" ")], id: JsIdentifierBinding { @@ -84,15 +85,16 @@ JsScript { 1: JS_DIRECTIVE_LIST@0..0 2: JS_STATEMENT_LIST@0..74 0: JS_CLASS_DECLARATION@0..74 - 0: (empty) - 1: CLASS_KW@0..16 "class" [Comments("// SCRIPT"), Newline("\n")] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@16..18 + 0: JS_DECORATOR_LIST@0..0 + 1: (empty) + 2: CLASS_KW@0..16 "class" [Comments("// SCRIPT"), Newline("\n")] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@16..18 0: IDENT@16..18 "A" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@18..20 "{" [] [Whitespace(" ")] - 7: JS_CLASS_MEMBER_LIST@20..73 + 6: (empty) + 7: L_CURLY@18..20 "{" [] [Whitespace(" ")] + 8: JS_CLASS_MEMBER_LIST@20..73 0: JS_CONSTRUCTOR_CLASS_MEMBER@20..73 0: JS_CONSTRUCTOR_MODIFIER_LIST@20..20 1: JS_LITERAL_MEMBER_NAME@20..31 @@ -133,7 +135,7 @@ JsScript { 1: JS_DIRECTIVE_LIST@71..71 2: JS_STATEMENT_LIST@71..71 3: R_CURLY@71..73 "}" [] [Whitespace(" ")] - 8: R_CURLY@73..74 "}" [] [] + 9: R_CURLY@73..74 "}" [] [] 3: EOF@74..75 "" [Newline("\n")] [] -- js_constructor_parameter_reserved_names.js:2:33 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ diff --git a/crates/rome_js_parser/test_data/inline/err/jsx_children_expressions_not_accepted.rast b/crates/rome_js_parser/test_data/inline/err/jsx_children_expressions_not_accepted.rast index eff527b00ca..fa328229ab4 100644 --- a/crates/rome_js_parser/test_data/inline/err/jsx_children_expressions_not_accepted.rast +++ b/crates/rome_js_parser/test_data/inline/err/jsx_children_expressions_not_accepted.rast @@ -36,6 +36,7 @@ JsModule { l_curly_token: L_CURLY@24..25 "{" [] [], expression: JsBogusExpression { items: [ + JsDecoratorList [], CLASS_KW@25..31 "class" [] [Whitespace(" ")], JsIdentifierBinding { name_token: IDENT@31..32 "A" [] [], @@ -131,12 +132,13 @@ JsModule { 3: JSX_EXPRESSION_CHILD@24..35 0: L_CURLY@24..25 "{" [] [] 1: JS_BOGUS_EXPRESSION@25..34 - 0: CLASS_KW@25..31 "class" [] [Whitespace(" ")] - 1: JS_IDENTIFIER_BINDING@31..32 + 0: JS_DECORATOR_LIST@25..25 + 1: CLASS_KW@25..31 "class" [] [Whitespace(" ")] + 2: JS_IDENTIFIER_BINDING@31..32 0: IDENT@31..32 "A" [] [] - 2: L_CURLY@32..33 "{" [] [] - 3: JS_CLASS_MEMBER_LIST@33..33 - 4: R_CURLY@33..34 "}" [] [] + 3: L_CURLY@32..33 "{" [] [] + 4: JS_CLASS_MEMBER_LIST@33..33 + 5: R_CURLY@33..34 "}" [] [] 2: R_CURLY@34..35 "}" [] [] 4: JSX_TEXT@35..38 0: JSX_TEXT_LITERAL@35..38 "\n " [] [] diff --git a/crates/rome_js_parser/test_data/inline/err/method_getter_err.rast b/crates/rome_js_parser/test_data/inline/err/method_getter_err.rast index 85aaa435835..3c842483d4a 100644 --- a/crates/rome_js_parser/test_data/inline/err/method_getter_err.rast +++ b/crates/rome_js_parser/test_data/inline/err/method_getter_err.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@0..6 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -44,15 +45,16 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..21 0: JS_CLASS_DECLARATION@0..19 - 0: (empty) - 1: CLASS_KW@0..6 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@6..10 + 0: JS_DECORATOR_LIST@0..0 + 1: (empty) + 2: CLASS_KW@0..6 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@6..10 0: IDENT@6..10 "foo" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@10..11 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@11..18 + 6: (empty) + 7: L_CURLY@10..11 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@11..18 0: JS_PROPERTY_CLASS_MEMBER@11..17 0: JS_PROPERTY_MODIFIER_LIST@11..11 1: JS_LITERAL_MEMBER_NAME@11..17 @@ -62,7 +64,7 @@ JsModule { 4: (empty) 1: JS_BOGUS_MEMBER@17..18 0: L_CURLY@17..18 "{" [] [] - 8: R_CURLY@18..19 "}" [] [] + 9: R_CURLY@18..19 "}" [] [] 1: JS_BOGUS_STATEMENT@19..21 0: R_CURLY@19..21 "}" [Newline("\n")] [] 3: EOF@21..22 "" [Newline("\n")] [] diff --git a/crates/rome_js_parser/test_data/inline/err/multiple_default_exports_err.rast b/crates/rome_js_parser/test_data/inline/err/multiple_default_exports_err.rast index 71c5ce8da8d..1c00c34a83d 100644 --- a/crates/rome_js_parser/test_data/inline/err/multiple_default_exports_err.rast +++ b/crates/rome_js_parser/test_data/inline/err/multiple_default_exports_err.rast @@ -9,6 +9,7 @@ JsModule { expression: JsParenthesizedExpression { l_paren_token: L_PAREN@15..16 "(" [] [], expression: JsClassExpression { + decorators: JsDecoratorList [], class_token: CLASS_KW@16..22 "class" [] [Whitespace(" ")], id: missing (optional), type_parameters: missing (optional), @@ -97,14 +98,15 @@ JsModule { 1: JS_PARENTHESIZED_EXPRESSION@15..25 0: L_PAREN@15..16 "(" [] [] 1: JS_CLASS_EXPRESSION@16..24 - 0: CLASS_KW@16..22 "class" [] [Whitespace(" ")] - 1: (empty) + 0: JS_DECORATOR_LIST@16..16 + 1: CLASS_KW@16..22 "class" [] [Whitespace(" ")] 2: (empty) 3: (empty) 4: (empty) - 5: L_CURLY@22..23 "{" [] [] - 6: JS_CLASS_MEMBER_LIST@23..23 - 7: R_CURLY@23..24 "}" [] [] + 5: (empty) + 6: L_CURLY@22..23 "{" [] [] + 7: JS_CLASS_MEMBER_LIST@23..23 + 8: R_CURLY@23..24 "}" [] [] 2: R_PAREN@24..25 ")" [] [] 2: (empty) 1: JS_BOGUS_STATEMENT@25..47 diff --git a/crates/rome_js_parser/test_data/inline/err/optional_member.rast b/crates/rome_js_parser/test_data/inline/err/optional_member.rast index 41d7f7f416f..40eb71049d5 100644 --- a/crates/rome_js_parser/test_data/inline/err/optional_member.rast +++ b/crates/rome_js_parser/test_data/inline/err/optional_member.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@0..6 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -39,15 +40,16 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..17 0: JS_CLASS_DECLARATION@0..17 - 0: (empty) - 1: CLASS_KW@0..6 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@6..8 + 0: JS_DECORATOR_LIST@0..0 + 1: (empty) + 2: CLASS_KW@0..6 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@6..8 0: IDENT@6..8 "B" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@8..10 "{" [] [Whitespace(" ")] - 7: JS_CLASS_MEMBER_LIST@10..16 + 6: (empty) + 7: L_CURLY@8..10 "{" [] [Whitespace(" ")] + 8: JS_CLASS_MEMBER_LIST@10..16 0: JS_BOGUS_MEMBER@10..16 0: JS_PROPERTY_MODIFIER_LIST@10..10 1: JS_LITERAL_MEMBER_NAME@10..13 @@ -55,7 +57,7 @@ JsModule { 2: JS_BOGUS@13..14 0: QUESTION@13..14 "?" [] [] 3: SEMICOLON@14..16 ";" [] [Whitespace(" ")] - 8: R_CURLY@16..17 "}" [] [] + 9: R_CURLY@16..17 "}" [] [] 3: EOF@17..18 "" [Newline("\n")] [] -- optional_member.js:1:14 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ diff --git a/crates/rome_js_parser/test_data/inline/err/private_name_presence_check_recursive.rast b/crates/rome_js_parser/test_data/inline/err/private_name_presence_check_recursive.rast index 3e4177980d9..838bbec5cbc 100644 --- a/crates/rome_js_parser/test_data/inline/err/private_name_presence_check_recursive.rast +++ b/crates/rome_js_parser/test_data/inline/err/private_name_presence_check_recursive.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@0..6 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -119,15 +120,16 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..96 0: JS_CLASS_DECLARATION@0..96 - 0: (empty) - 1: CLASS_KW@0..6 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@6..8 + 0: JS_DECORATOR_LIST@0..0 + 1: (empty) + 2: CLASS_KW@0..6 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@6..8 0: IDENT@6..8 "A" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@8..9 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@9..94 + 6: (empty) + 7: L_CURLY@8..9 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@9..94 0: JS_PROPERTY_CLASS_MEMBER@9..17 0: JS_PROPERTY_MODIFIER_LIST@9..9 1: JS_PRIVATE_CLASS_MEMBER_NAME@9..16 @@ -191,7 +193,7 @@ JsModule { 0: JS_NUMBER_LITERAL@89..90 "5" [] [] 1: SEMICOLON@90..91 ";" [] [] 3: R_CURLY@91..94 "}" [Newline("\n"), Whitespace(" ")] [] - 8: R_CURLY@94..96 "}" [Newline("\n")] [] + 9: R_CURLY@94..96 "}" [Newline("\n")] [] 3: EOF@96..97 "" [Newline("\n")] [] -- private_name_presence_check_recursive.js:4:13 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ diff --git a/crates/rome_js_parser/test_data/inline/err/private_name_with_space.rast b/crates/rome_js_parser/test_data/inline/err/private_name_with_space.rast index 7840842f179..327bcb7afc1 100644 --- a/crates/rome_js_parser/test_data/inline/err/private_name_with_space.rast +++ b/crates/rome_js_parser/test_data/inline/err/private_name_with_space.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@0..6 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -44,15 +45,16 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..20 0: JS_CLASS_DECLARATION@0..20 - 0: (empty) - 1: CLASS_KW@0..6 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@6..8 + 0: JS_DECORATOR_LIST@0..0 + 1: (empty) + 2: CLASS_KW@0..6 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@6..8 0: IDENT@6..8 "A" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@8..9 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@9..18 + 6: (empty) + 7: L_CURLY@8..9 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@9..18 0: JS_PROPERTY_CLASS_MEMBER@9..13 0: JS_PROPERTY_MODIFIER_LIST@9..9 1: JS_PRIVATE_CLASS_MEMBER_NAME@9..13 @@ -68,7 +70,7 @@ JsModule { 2: (empty) 3: (empty) 4: SEMICOLON@17..18 ";" [] [] - 8: R_CURLY@18..20 "}" [Newline("\n")] [] + 9: R_CURLY@18..20 "}" [Newline("\n")] [] 3: EOF@20..21 "" [Newline("\n")] [] -- private_name_with_space.js:2:3 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ diff --git a/crates/rome_js_parser/test_data/inline/err/setter_class_member.rast b/crates/rome_js_parser/test_data/inline/err/setter_class_member.rast index 306c4c5613e..96877752bf9 100644 --- a/crates/rome_js_parser/test_data/inline/err/setter_class_member.rast +++ b/crates/rome_js_parser/test_data/inline/err/setter_class_member.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@0..6 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -41,15 +42,16 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..32 0: JS_CLASS_DECLARATION@0..32 - 0: (empty) - 1: CLASS_KW@0..6 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@6..14 + 0: JS_DECORATOR_LIST@0..0 + 1: (empty) + 2: CLASS_KW@0..6 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@6..14 0: IDENT@6..14 "Setters" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@14..15 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@15..30 + 6: (empty) + 7: L_CURLY@14..15 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@15..30 0: JS_SETTER_CLASS_MEMBER@15..30 0: JS_METHOD_MODIFIER_LIST@15..15 1: SET_KW@15..22 "set" [Newline("\n"), Whitespace(" ")] [Whitespace(" ")] @@ -63,7 +65,7 @@ JsModule { 1: JS_DIRECTIVE_LIST@29..29 2: JS_STATEMENT_LIST@29..29 3: R_CURLY@29..30 "}" [] [] - 8: R_CURLY@30..32 "}" [Newline("\n")] [] + 9: R_CURLY@30..32 "}" [Newline("\n")] [] 3: EOF@32..33 "" [Newline("\n")] [] -- setter_class_member.js:2:11 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ diff --git a/crates/rome_js_parser/test_data/inline/err/setter_class_no_body.rast b/crates/rome_js_parser/test_data/inline/err/setter_class_no_body.rast index a655d6bb9f9..edf1cb1a75d 100644 --- a/crates/rome_js_parser/test_data/inline/err/setter_class_no_body.rast +++ b/crates/rome_js_parser/test_data/inline/err/setter_class_no_body.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@0..6 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -43,15 +44,16 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..30 0: JS_CLASS_DECLARATION@0..30 - 0: (empty) - 1: CLASS_KW@0..6 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@6..14 + 0: JS_DECORATOR_LIST@0..0 + 1: (empty) + 2: CLASS_KW@0..6 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@6..14 0: IDENT@6..14 "Setters" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@14..15 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@15..28 + 6: (empty) + 7: L_CURLY@14..15 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@15..28 0: JS_SETTER_CLASS_MEMBER@15..28 0: JS_METHOD_MODIFIER_LIST@15..15 1: SET_KW@15..22 "set" [Newline("\n"), Whitespace(" ")] [Whitespace(" ")] @@ -66,7 +68,7 @@ JsModule { 3: (empty) 5: R_PAREN@27..28 ")" [] [] 6: (empty) - 8: R_CURLY@28..30 "}" [Newline("\n")] [] + 9: R_CURLY@28..30 "}" [Newline("\n")] [] 3: EOF@30..31 "" [Newline("\n")] [] -- setter_class_no_body.js:3:1 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ diff --git a/crates/rome_js_parser/test_data/inline/err/super_expression_err.rast b/crates/rome_js_parser/test_data/inline/err/super_expression_err.rast index d0cdc8e602f..9fd7a15e479 100644 --- a/crates/rome_js_parser/test_data/inline/err/super_expression_err.rast +++ b/crates/rome_js_parser/test_data/inline/err/super_expression_err.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@0..6 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -113,20 +114,21 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..80 0: JS_CLASS_DECLARATION@0..71 - 0: (empty) - 1: CLASS_KW@0..6 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@6..11 + 0: JS_DECORATOR_LIST@0..0 + 1: (empty) + 2: CLASS_KW@0..6 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@6..11 0: IDENT@6..11 "Test" [] [Whitespace(" ")] - 3: (empty) - 4: JS_EXTENDS_CLAUSE@11..21 + 4: (empty) + 5: JS_EXTENDS_CLAUSE@11..21 0: EXTENDS_KW@11..19 "extends" [] [Whitespace(" ")] 1: JS_IDENTIFIER_EXPRESSION@19..21 0: JS_REFERENCE_IDENTIFIER@19..21 0: IDENT@19..21 "B" [] [Whitespace(" ")] 2: (empty) - 5: (empty) - 6: L_CURLY@21..22 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@22..69 + 6: (empty) + 7: L_CURLY@21..22 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@22..69 0: JS_METHOD_CLASS_MEMBER@22..69 0: JS_METHOD_MODIFIER_LIST@22..22 1: (empty) @@ -171,7 +173,7 @@ JsModule { 2: R_PAREN@63..64 ")" [] [] 1: SEMICOLON@64..65 ";" [] [] 3: R_CURLY@65..69 "}" [Newline("\n"), Whitespace(" ")] [] - 8: R_CURLY@69..71 "}" [Newline("\n")] [] + 9: R_CURLY@69..71 "}" [Newline("\n")] [] 1: JS_EXPRESSION_STATEMENT@71..80 0: JS_CALL_EXPRESSION@71..79 0: JS_BOGUS_EXPRESSION@71..77 diff --git a/crates/rome_js_parser/test_data/inline/err/super_expression_in_constructor_parameter_list.rast b/crates/rome_js_parser/test_data/inline/err/super_expression_in_constructor_parameter_list.rast index 962947a085c..f154d9edf9b 100644 --- a/crates/rome_js_parser/test_data/inline/err/super_expression_in_constructor_parameter_list.rast +++ b/crates/rome_js_parser/test_data/inline/err/super_expression_in_constructor_parameter_list.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@0..6 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -63,20 +64,21 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..45 0: JS_CLASS_DECLARATION@0..44 - 0: (empty) - 1: CLASS_KW@0..6 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@6..8 + 0: JS_DECORATOR_LIST@0..0 + 1: (empty) + 2: CLASS_KW@0..6 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@6..8 0: IDENT@6..8 "A" [] [Whitespace(" ")] - 3: (empty) - 4: JS_EXTENDS_CLAUSE@8..18 + 4: (empty) + 5: JS_EXTENDS_CLAUSE@8..18 0: EXTENDS_KW@8..16 "extends" [] [Whitespace(" ")] 1: JS_IDENTIFIER_EXPRESSION@16..18 0: JS_REFERENCE_IDENTIFIER@16..18 0: IDENT@16..18 "B" [] [Whitespace(" ")] 2: (empty) - 5: (empty) - 6: L_CURLY@18..20 "{" [] [Whitespace(" ")] - 7: JS_CLASS_MEMBER_LIST@20..42 + 6: (empty) + 7: L_CURLY@18..20 "{" [] [Whitespace(" ")] + 8: JS_CLASS_MEMBER_LIST@20..42 0: JS_CONSTRUCTOR_CLASS_MEMBER@20..39 0: JS_CONSTRUCTOR_MODIFIER_LIST@20..20 1: JS_LITERAL_MEMBER_NAME@20..31 @@ -92,7 +94,7 @@ JsModule { 1: JS_BOGUS_MEMBER@39..42 0: R_PAREN@39..41 ")" [] [Whitespace(" ")] 1: L_CURLY@41..42 "{" [] [] - 8: R_CURLY@42..44 "}" [] [Whitespace(" ")] + 9: R_CURLY@42..44 "}" [] [Whitespace(" ")] 1: JS_BOGUS_STATEMENT@44..45 0: R_CURLY@44..45 "}" [] [] 3: EOF@45..46 "" [Newline("\n")] [] diff --git a/crates/rome_js_parser/test_data/inline/err/ts_abstract_member_ansi.rast b/crates/rome_js_parser/test_data/inline/err/ts_abstract_member_ansi.rast index b39df8e65d4..64bff86c4a2 100644 --- a/crates/rome_js_parser/test_data/inline/err/ts_abstract_member_ansi.rast +++ b/crates/rome_js_parser/test_data/inline/err/ts_abstract_member_ansi.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: ABSTRACT_KW@0..9 "abstract" [] [Whitespace(" ")], class_token: CLASS_KW@9..15 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -113,15 +114,16 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..124 0: JS_CLASS_DECLARATION@0..124 - 0: ABSTRACT_KW@0..9 "abstract" [] [Whitespace(" ")] - 1: CLASS_KW@9..15 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@15..17 + 0: JS_DECORATOR_LIST@0..0 + 1: ABSTRACT_KW@0..9 "abstract" [] [Whitespace(" ")] + 2: CLASS_KW@9..15 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@15..17 0: IDENT@15..17 "A" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@17..19 "{" [] [Whitespace(" ")] - 7: JS_CLASS_MEMBER_LIST@19..123 + 6: (empty) + 7: L_CURLY@17..19 "{" [] [Whitespace(" ")] + 8: JS_CLASS_MEMBER_LIST@19..123 0: JS_BOGUS_MEMBER@19..42 0: JS_BOGUS@19..28 0: TS_ABSTRACT_MODIFIER@19..28 @@ -182,7 +184,7 @@ JsModule { 0: IDENT@118..123 "prop" [] [Whitespace(" ")] 2: (empty) 3: (empty) - 8: R_CURLY@123..124 "}" [] [] + 9: R_CURLY@123..124 "}" [] [] 3: EOF@124..125 "" [Newline("\n")] [] -- ts_abstract_member_ansi.ts:1:43 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ diff --git a/crates/rome_js_parser/test_data/inline/err/ts_abstract_property_cannot_be_definite.rast b/crates/rome_js_parser/test_data/inline/err/ts_abstract_property_cannot_be_definite.rast index cfc54ceac16..6b5e3d697c1 100644 --- a/crates/rome_js_parser/test_data/inline/err/ts_abstract_property_cannot_be_definite.rast +++ b/crates/rome_js_parser/test_data/inline/err/ts_abstract_property_cannot_be_definite.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: ABSTRACT_KW@0..9 "abstract" [] [Whitespace(" ")], class_token: CLASS_KW@9..15 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -49,15 +50,16 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..49 0: JS_CLASS_DECLARATION@0..49 - 0: ABSTRACT_KW@0..9 "abstract" [] [Whitespace(" ")] - 1: CLASS_KW@9..15 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@15..17 + 0: JS_DECORATOR_LIST@0..0 + 1: ABSTRACT_KW@0..9 "abstract" [] [Whitespace(" ")] + 2: CLASS_KW@9..15 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@15..17 0: IDENT@15..17 "A" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@17..18 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@18..47 + 6: (empty) + 7: L_CURLY@17..18 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@18..47 0: JS_BOGUS_MEMBER@18..47 0: TS_PROPERTY_SIGNATURE_MODIFIER_LIST@18..33 0: TS_ABSTRACT_MODIFIER@18..33 @@ -71,7 +73,7 @@ JsModule { 1: TS_STRING_TYPE@40..46 0: STRING_KW@40..46 "string" [] [] 3: SEMICOLON@46..47 ";" [] [] - 8: R_CURLY@47..49 "}" [Newline("\n")] [] + 9: R_CURLY@47..49 "}" [Newline("\n")] [] 3: EOF@49..50 "" [Newline("\n")] [] -- ts_abstract_property_cannot_be_definite.ts:2:19 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ diff --git a/crates/rome_js_parser/test_data/inline/err/ts_abstract_property_cannot_have_initiliazers.rast b/crates/rome_js_parser/test_data/inline/err/ts_abstract_property_cannot_have_initiliazers.rast index 01f104fd5c2..82a984c4e9e 100644 --- a/crates/rome_js_parser/test_data/inline/err/ts_abstract_property_cannot_have_initiliazers.rast +++ b/crates/rome_js_parser/test_data/inline/err/ts_abstract_property_cannot_have_initiliazers.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: ABSTRACT_KW@0..9 "abstract" [] [Whitespace(" ")], class_token: CLASS_KW@9..15 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -50,15 +51,16 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..52 0: JS_CLASS_DECLARATION@0..52 - 0: ABSTRACT_KW@0..9 "abstract" [] [Whitespace(" ")] - 1: CLASS_KW@9..15 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@15..17 + 0: JS_DECORATOR_LIST@0..0 + 1: ABSTRACT_KW@0..9 "abstract" [] [Whitespace(" ")] + 2: CLASS_KW@9..15 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@15..17 0: IDENT@15..17 "A" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@17..18 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@18..50 + 6: (empty) + 7: L_CURLY@17..18 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@18..50 0: JS_BOGUS_MEMBER@18..50 0: TS_PROPERTY_SIGNATURE_MODIFIER_LIST@18..32 0: TS_ABSTRACT_MODIFIER@18..32 @@ -74,7 +76,7 @@ JsModule { 1: JS_STRING_LITERAL_EXPRESSION@47..49 0: JS_STRING_LITERAL@47..49 "\"\"" [] [] 4: SEMICOLON@49..50 ";" [] [] - 8: R_CURLY@50..52 "}" [Newline("\n")] [] + 9: R_CURLY@50..52 "}" [Newline("\n")] [] 3: EOF@52..53 "" [Newline("\n")] [] -- ts_abstract_property_cannot_have_initiliazers.ts:2:27 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ diff --git a/crates/rome_js_parser/test_data/inline/err/ts_ambient_async_method.rast b/crates/rome_js_parser/test_data/inline/err/ts_ambient_async_method.rast index 6fd7344b9c9..ecae323d812 100644 --- a/crates/rome_js_parser/test_data/inline/err/ts_ambient_async_method.rast +++ b/crates/rome_js_parser/test_data/inline/err/ts_ambient_async_method.rast @@ -5,6 +5,7 @@ JsModule { TsDeclareStatement { declare_token: DECLARE_KW@0..8 "declare" [] [Whitespace(" ")], declaration: JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@8..14 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -44,15 +45,16 @@ JsModule { 0: TS_DECLARE_STATEMENT@0..35 0: DECLARE_KW@0..8 "declare" [] [Whitespace(" ")] 1: JS_CLASS_DECLARATION@8..35 - 0: (empty) - 1: CLASS_KW@8..14 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@14..16 + 0: JS_DECORATOR_LIST@8..8 + 1: (empty) + 2: CLASS_KW@8..14 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@14..16 0: IDENT@14..16 "A" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@16..18 "{" [] [Whitespace(" ")] - 7: JS_CLASS_MEMBER_LIST@18..34 + 6: (empty) + 7: L_CURLY@16..18 "{" [] [Whitespace(" ")] + 8: JS_CLASS_MEMBER_LIST@18..34 0: JS_BOGUS_MEMBER@18..34 0: ASYNC_KW@18..24 "async" [] [Whitespace(" ")] 1: JS_LITERAL_MEMBER_NAME@24..30 @@ -62,7 +64,7 @@ JsModule { 1: JS_PARAMETER_LIST@31..31 2: R_PAREN@31..32 ")" [] [] 3: SEMICOLON@32..34 ";" [] [Whitespace(" ")] - 8: R_CURLY@34..35 "}" [] [] + 9: R_CURLY@34..35 "}" [] [] 3: EOF@35..36 "" [Newline("\n")] [] -- ts_ambient_async_method.ts:1:19 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ diff --git a/crates/rome_js_parser/test_data/inline/err/ts_ambient_context_semi.rast b/crates/rome_js_parser/test_data/inline/err/ts_ambient_context_semi.rast index 60a588b9bb3..34f28b5c0eb 100644 --- a/crates/rome_js_parser/test_data/inline/err/ts_ambient_context_semi.rast +++ b/crates/rome_js_parser/test_data/inline/err/ts_ambient_context_semi.rast @@ -5,6 +5,7 @@ JsModule { TsDeclareStatement { declare_token: DECLARE_KW@0..8 "declare" [] [Whitespace(" ")], declaration: JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@8..14 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -78,15 +79,16 @@ JsModule { 0: TS_DECLARE_STATEMENT@0..48 0: DECLARE_KW@0..8 "declare" [] [Whitespace(" ")] 1: JS_CLASS_DECLARATION@8..48 - 0: (empty) - 1: CLASS_KW@8..14 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@14..16 + 0: JS_DECORATOR_LIST@8..8 + 1: (empty) + 2: CLASS_KW@8..14 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@14..16 0: IDENT@14..16 "A" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@16..18 "{" [] [Whitespace(" ")] - 7: JS_CLASS_MEMBER_LIST@18..47 + 6: (empty) + 7: L_CURLY@16..18 "{" [] [Whitespace(" ")] + 8: JS_CLASS_MEMBER_LIST@18..47 0: TS_METHOD_SIGNATURE_CLASS_MEMBER@18..27 0: TS_METHOD_SIGNATURE_MODIFIER_LIST@18..18 1: (empty) @@ -126,7 +128,7 @@ JsModule { 2: R_PAREN@45..47 ")" [] [Whitespace(" ")] 6: (empty) 7: (empty) - 8: R_CURLY@47..48 "}" [] [] + 9: R_CURLY@47..48 "}" [] [] 3: EOF@48..49 "" [Newline("\n")] [] -- ts_ambient_context_semi.ts:1:19 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ diff --git a/crates/rome_js_parser/test_data/inline/err/ts_annotated_property_initializer_ambient_context.rast b/crates/rome_js_parser/test_data/inline/err/ts_annotated_property_initializer_ambient_context.rast index fb702b85ac9..d078d35b321 100644 --- a/crates/rome_js_parser/test_data/inline/err/ts_annotated_property_initializer_ambient_context.rast +++ b/crates/rome_js_parser/test_data/inline/err/ts_annotated_property_initializer_ambient_context.rast @@ -5,6 +5,7 @@ JsModule { TsDeclareStatement { declare_token: DECLARE_KW@0..8 "declare" [] [Whitespace(" ")], declaration: JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@8..14 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -45,6 +46,7 @@ JsModule { }, }, JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@48..55 "class" [Newline("\n")] [Whitespace(" ")], id: JsIdentifierBinding { @@ -97,15 +99,16 @@ JsModule { 0: TS_DECLARE_STATEMENT@0..48 0: DECLARE_KW@0..8 "declare" [] [Whitespace(" ")] 1: JS_CLASS_DECLARATION@8..48 - 0: (empty) - 1: CLASS_KW@8..14 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@14..16 + 0: JS_DECORATOR_LIST@8..8 + 1: (empty) + 2: CLASS_KW@8..14 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@14..16 0: IDENT@14..16 "T" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@16..18 "{" [] [Whitespace(" ")] - 7: JS_CLASS_MEMBER_LIST@18..47 + 6: (empty) + 7: L_CURLY@16..18 "{" [] [Whitespace(" ")] + 8: JS_CLASS_MEMBER_LIST@18..47 0: JS_BOGUS_MEMBER@18..47 0: TS_PROPERTY_SIGNATURE_MODIFIER_LIST@18..27 0: TS_READONLY_MODIFIER@18..27 @@ -121,17 +124,18 @@ JsModule { 1: JS_STRING_LITERAL_EXPRESSION@39..45 0: JS_STRING_LITERAL@39..45 "\"test\"" [] [] 4: SEMICOLON@45..47 ";" [] [Whitespace(" ")] - 8: R_CURLY@47..48 "}" [] [] + 9: R_CURLY@47..48 "}" [] [] 1: JS_CLASS_DECLARATION@48..97 - 0: (empty) - 1: CLASS_KW@48..55 "class" [Newline("\n")] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@55..57 + 0: JS_DECORATOR_LIST@48..48 + 1: (empty) + 2: CLASS_KW@48..55 "class" [Newline("\n")] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@55..57 0: IDENT@55..57 "T" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@57..59 "{" [] [Whitespace(" ")] - 7: JS_CLASS_MEMBER_LIST@59..96 + 6: (empty) + 7: L_CURLY@57..59 "{" [] [Whitespace(" ")] + 8: JS_CLASS_MEMBER_LIST@59..96 0: JS_BOGUS_MEMBER@59..96 0: TS_PROPERTY_SIGNATURE_MODIFIER_LIST@59..76 0: TS_DECLARE_MODIFIER@59..67 @@ -149,7 +153,7 @@ JsModule { 1: JS_STRING_LITERAL_EXPRESSION@88..94 0: JS_STRING_LITERAL@88..94 "\"test\"" [] [] 4: SEMICOLON@94..96 ";" [] [Whitespace(" ")] - 8: R_CURLY@96..97 "}" [] [] + 9: R_CURLY@96..97 "}" [] [] 3: EOF@97..98 "" [Newline("\n")] [] -- ts_annotated_property_initializer_ambient_context.ts:1:38 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ diff --git a/crates/rome_js_parser/test_data/inline/err/ts_class_declare_modifier_error.rast b/crates/rome_js_parser/test_data/inline/err/ts_class_declare_modifier_error.rast index b0f612959f3..a0137b74484 100644 --- a/crates/rome_js_parser/test_data/inline/err/ts_class_declare_modifier_error.rast +++ b/crates/rome_js_parser/test_data/inline/err/ts_class_declare_modifier_error.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@0..6 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -219,15 +220,16 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..241 0: JS_CLASS_DECLARATION@0..241 - 0: (empty) - 1: CLASS_KW@0..6 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@6..11 + 0: JS_DECORATOR_LIST@0..0 + 1: (empty) + 2: CLASS_KW@0..6 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@6..11 0: IDENT@6..11 "Test" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@11..12 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@12..239 + 6: (empty) + 7: L_CURLY@11..12 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@12..239 0: JS_BOGUS_MEMBER@12..42 0: JS_BOGUS@12..25 0: TS_DECLARE_MODIFIER@12..25 @@ -343,7 +345,7 @@ JsModule { 1: TS_STRING_TYPE@232..238 0: STRING_KW@232..238 "string" [] [] 3: SEMICOLON@238..239 ";" [] [] - 8: R_CURLY@239..241 "}" [Newline("\n")] [] + 9: R_CURLY@239..241 "}" [Newline("\n")] [] 3: EOF@241..242 "" [Newline("\n")] [] -- ts_class_declare_modifier_error.ts:2:5 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ diff --git a/crates/rome_js_parser/test_data/inline/err/ts_class_heritage_clause_errors.rast b/crates/rome_js_parser/test_data/inline/err/ts_class_heritage_clause_errors.rast index 5039c48888e..4718fa4ae71 100644 --- a/crates/rome_js_parser/test_data/inline/err/ts_class_heritage_clause_errors.rast +++ b/crates/rome_js_parser/test_data/inline/err/ts_class_heritage_clause_errors.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@0..6 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -28,6 +29,7 @@ JsModule { }, JsBogusStatement { items: [ + JsDecoratorList [], CLASS_KW@27..34 "class" [Newline("\n")] [Whitespace(" ")], JsIdentifierBinding { name_token: IDENT@34..36 "B" [] [Whitespace(" ")], @@ -59,6 +61,7 @@ JsModule { }, JsBogusStatement { items: [ + JsDecoratorList [], CLASS_KW@63..70 "class" [Newline("\n")] [Whitespace(" ")], JsIdentifierBinding { name_token: IDENT@70..72 "C" [] [Whitespace(" ")], @@ -91,6 +94,7 @@ JsModule { ], }, JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@104..111 "class" [Newline("\n")] [Whitespace(" ")], id: JsIdentifierBinding { @@ -107,6 +111,7 @@ JsModule { r_curly_token: R_CURLY@125..126 "}" [] [], }, JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@126..133 "class" [Newline("\n")] [Whitespace(" ")], id: JsIdentifierBinding { @@ -125,6 +130,7 @@ JsModule { }, JsBogusStatement { items: [ + JsDecoratorList [], CLASS_KW@145..152 "class" [Newline("\n")] [Whitespace(" ")], JsIdentifierBinding { name_token: IDENT@152..154 "F" [] [Whitespace(" ")], @@ -154,16 +160,17 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..167 0: JS_CLASS_DECLARATION@0..10 - 0: (empty) - 1: CLASS_KW@0..6 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@6..8 + 0: JS_DECORATOR_LIST@0..0 + 1: (empty) + 2: CLASS_KW@0..6 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@6..8 0: IDENT@6..8 "A" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@8..9 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@9..9 - 8: R_CURLY@9..10 "}" [] [] + 6: (empty) + 7: L_CURLY@8..9 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@9..9 + 9: R_CURLY@9..10 "}" [] [] 1: TS_INTERFACE_DECLARATION@10..27 0: INTERFACE_KW@10..21 "interface" [Newline("\n")] [Whitespace(" ")] 1: TS_IDENTIFIER_BINDING@21..25 @@ -174,86 +181,91 @@ JsModule { 5: TS_TYPE_MEMBER_LIST@26..26 6: R_CURLY@26..27 "}" [] [] 2: JS_BOGUS_STATEMENT@27..63 - 0: CLASS_KW@27..34 "class" [Newline("\n")] [Whitespace(" ")] - 1: JS_IDENTIFIER_BINDING@34..36 + 0: JS_DECORATOR_LIST@27..27 + 1: CLASS_KW@27..34 "class" [Newline("\n")] [Whitespace(" ")] + 2: JS_IDENTIFIER_BINDING@34..36 0: IDENT@34..36 "B" [] [Whitespace(" ")] - 2: TS_IMPLEMENTS_CLAUSE@36..51 + 3: TS_IMPLEMENTS_CLAUSE@36..51 0: IMPLEMENTS_KW@36..47 "implements" [] [Whitespace(" ")] 1: TS_TYPE_LIST@47..51 0: TS_NAME_WITH_TYPE_ARGUMENTS@47..51 0: JS_REFERENCE_IDENTIFIER@47..51 0: IDENT@47..51 "Int" [] [Whitespace(" ")] 1: (empty) - 3: JS_EXTENDS_CLAUSE@51..61 + 4: JS_EXTENDS_CLAUSE@51..61 0: EXTENDS_KW@51..59 "extends" [] [Whitespace(" ")] 1: JS_IDENTIFIER_EXPRESSION@59..61 0: JS_REFERENCE_IDENTIFIER@59..61 0: IDENT@59..61 "A" [] [Whitespace(" ")] 2: (empty) - 4: L_CURLY@61..62 "{" [] [] - 5: JS_CLASS_MEMBER_LIST@62..62 - 6: R_CURLY@62..63 "}" [] [] + 5: L_CURLY@61..62 "{" [] [] + 6: JS_CLASS_MEMBER_LIST@62..62 + 7: R_CURLY@62..63 "}" [] [] 3: JS_BOGUS_STATEMENT@63..104 - 0: CLASS_KW@63..70 "class" [Newline("\n")] [Whitespace(" ")] - 1: JS_IDENTIFIER_BINDING@70..72 + 0: JS_DECORATOR_LIST@63..63 + 1: CLASS_KW@63..70 "class" [Newline("\n")] [Whitespace(" ")] + 2: JS_IDENTIFIER_BINDING@70..72 0: IDENT@70..72 "C" [] [Whitespace(" ")] - 2: TS_IMPLEMENTS_CLAUSE@72..87 + 3: TS_IMPLEMENTS_CLAUSE@72..87 0: IMPLEMENTS_KW@72..83 "implements" [] [Whitespace(" ")] 1: TS_TYPE_LIST@83..87 0: TS_NAME_WITH_TYPE_ARGUMENTS@83..87 0: JS_REFERENCE_IDENTIFIER@83..87 0: IDENT@83..87 "Int" [] [Whitespace(" ")] 1: (empty) - 3: TS_IMPLEMENTS_CLAUSE@87..102 + 4: TS_IMPLEMENTS_CLAUSE@87..102 0: IMPLEMENTS_KW@87..98 "implements" [] [Whitespace(" ")] 1: TS_TYPE_LIST@98..102 0: TS_NAME_WITH_TYPE_ARGUMENTS@98..102 0: JS_REFERENCE_IDENTIFIER@98..102 0: IDENT@98..102 "Int" [] [Whitespace(" ")] 1: (empty) - 4: L_CURLY@102..103 "{" [] [] - 5: JS_CLASS_MEMBER_LIST@103..103 - 6: R_CURLY@103..104 "}" [] [] + 5: L_CURLY@102..103 "{" [] [] + 6: JS_CLASS_MEMBER_LIST@103..103 + 7: R_CURLY@103..104 "}" [] [] 4: JS_CLASS_DECLARATION@104..126 - 0: (empty) - 1: CLASS_KW@104..111 "class" [Newline("\n")] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@111..113 + 0: JS_DECORATOR_LIST@104..104 + 1: (empty) + 2: CLASS_KW@104..111 "class" [Newline("\n")] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@111..113 0: IDENT@111..113 "D" [] [Whitespace(" ")] - 3: (empty) 4: (empty) - 5: TS_IMPLEMENTS_CLAUSE@113..124 + 5: (empty) + 6: TS_IMPLEMENTS_CLAUSE@113..124 0: IMPLEMENTS_KW@113..124 "implements" [] [Whitespace(" ")] 1: TS_TYPE_LIST@124..124 - 6: L_CURLY@124..125 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@125..125 - 8: R_CURLY@125..126 "}" [] [] + 7: L_CURLY@124..125 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@125..125 + 9: R_CURLY@125..126 "}" [] [] 5: JS_CLASS_DECLARATION@126..145 - 0: (empty) - 1: CLASS_KW@126..133 "class" [Newline("\n")] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@133..135 + 0: JS_DECORATOR_LIST@126..126 + 1: (empty) + 2: CLASS_KW@126..133 "class" [Newline("\n")] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@133..135 0: IDENT@133..135 "E" [] [Whitespace(" ")] - 3: (empty) - 4: JS_EXTENDS_CLAUSE@135..143 + 4: (empty) + 5: JS_EXTENDS_CLAUSE@135..143 0: EXTENDS_KW@135..143 "extends" [] [Whitespace(" ")] 1: (empty) 2: (empty) - 5: (empty) - 6: L_CURLY@143..144 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@144..144 - 8: R_CURLY@144..145 "}" [] [] + 6: (empty) + 7: L_CURLY@143..144 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@144..144 + 9: R_CURLY@144..145 "}" [] [] 6: JS_BOGUS_STATEMENT@145..167 - 0: CLASS_KW@145..152 "class" [Newline("\n")] [Whitespace(" ")] - 1: JS_IDENTIFIER_BINDING@152..154 + 0: JS_DECORATOR_LIST@145..145 + 1: CLASS_KW@145..152 "class" [Newline("\n")] [Whitespace(" ")] + 2: JS_IDENTIFIER_BINDING@152..154 0: IDENT@152..154 "F" [] [Whitespace(" ")] - 2: JS_BOGUS@154..165 + 3: JS_BOGUS@154..165 0: EXTENDS_KW@154..162 "extends" [] [Whitespace(" ")] 1: JS_IDENTIFIER_EXPRESSION@162..163 0: JS_REFERENCE_IDENTIFIER@162..163 0: IDENT@162..163 "E" [] [] 2: COMMA@163..165 "," [] [Whitespace(" ")] - 3: L_CURLY@165..166 "{" [] [] - 4: JS_CLASS_MEMBER_LIST@166..166 - 5: R_CURLY@166..167 "}" [] [] + 4: L_CURLY@165..166 "{" [] [] + 5: JS_CLASS_MEMBER_LIST@166..166 + 6: R_CURLY@166..167 "}" [] [] 3: EOF@167..168 "" [Newline("\n")] [] -- ts_class_heritage_clause_errors.ts:3:24 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ diff --git a/crates/rome_js_parser/test_data/inline/err/ts_class_initializer_with_modifiers.rast b/crates/rome_js_parser/test_data/inline/err/ts_class_initializer_with_modifiers.rast index f6757ed631b..2fdbe6a1314 100644 --- a/crates/rome_js_parser/test_data/inline/err/ts_class_initializer_with_modifiers.rast +++ b/crates/rome_js_parser/test_data/inline/err/ts_class_initializer_with_modifiers.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@0..6 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -36,15 +37,16 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..31 0: JS_CLASS_DECLARATION@0..31 - 0: (empty) - 1: CLASS_KW@0..6 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@6..8 + 0: JS_DECORATOR_LIST@0..0 + 1: (empty) + 2: CLASS_KW@0..6 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@6..8 0: IDENT@6..8 "A" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@8..9 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@9..29 + 6: (empty) + 7: L_CURLY@8..9 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@9..29 0: JS_BOGUS_MEMBER@9..29 0: TS_ACCESSIBILITY_MODIFIER@9..19 0: PUBLIC_KW@9..19 "public" [Newline("\n"), Whitespace(" ")] [Whitespace(" ")] @@ -52,7 +54,7 @@ JsModule { 2: L_CURLY@26..28 "{" [] [Whitespace(" ")] 3: JS_STATEMENT_LIST@28..28 4: R_CURLY@28..29 "}" [] [] - 8: R_CURLY@29..31 "}" [Newline("\n")] [] + 9: R_CURLY@29..31 "}" [Newline("\n")] [] 3: EOF@31..32 "" [Newline("\n")] [] -- ts_class_initializer_with_modifiers.ts:2:3 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ diff --git a/crates/rome_js_parser/test_data/inline/err/ts_class_invalid_modifier_combinations.rast b/crates/rome_js_parser/test_data/inline/err/ts_class_invalid_modifier_combinations.rast index 351fe6b39b8..764fd153af4 100644 --- a/crates/rome_js_parser/test_data/inline/err/ts_class_invalid_modifier_combinations.rast +++ b/crates/rome_js_parser/test_data/inline/err/ts_class_invalid_modifier_combinations.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@0..6 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -35,6 +36,7 @@ JsModule { r_curly_token: R_CURLY@27..28 "}" [] [], }, JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: ABSTRACT_KW@28..38 "abstract" [Newline("\n")] [Whitespace(" ")], class_token: CLASS_KW@38..44 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -358,15 +360,16 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..495 0: JS_CLASS_DECLARATION@0..28 - 0: (empty) - 1: CLASS_KW@0..6 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@6..11 + 0: JS_DECORATOR_LIST@0..0 + 1: (empty) + 2: CLASS_KW@0..6 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@6..11 0: IDENT@6..11 "Base" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@11..13 "{" [] [Whitespace(" ")] - 7: JS_CLASS_MEMBER_LIST@13..27 + 6: (empty) + 7: L_CURLY@11..13 "{" [] [Whitespace(" ")] + 8: JS_CLASS_MEMBER_LIST@13..27 0: JS_PROPERTY_CLASS_MEMBER@13..20 0: JS_PROPERTY_MODIFIER_LIST@13..13 1: JS_LITERAL_MEMBER_NAME@13..18 @@ -381,22 +384,23 @@ JsModule { 2: (empty) 3: (empty) 4: SEMICOLON@25..27 ";" [] [Whitespace(" ")] - 8: R_CURLY@27..28 "}" [] [] + 9: R_CURLY@27..28 "}" [] [] 1: JS_CLASS_DECLARATION@28..495 - 0: ABSTRACT_KW@28..38 "abstract" [Newline("\n")] [Whitespace(" ")] - 1: CLASS_KW@38..44 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@44..49 + 0: JS_DECORATOR_LIST@28..28 + 1: ABSTRACT_KW@28..38 "abstract" [Newline("\n")] [Whitespace(" ")] + 2: CLASS_KW@38..44 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@44..49 0: IDENT@44..49 "Test" [] [Whitespace(" ")] - 3: (empty) - 4: JS_EXTENDS_CLAUSE@49..62 + 4: (empty) + 5: JS_EXTENDS_CLAUSE@49..62 0: EXTENDS_KW@49..57 "extends" [] [Whitespace(" ")] 1: JS_IDENTIFIER_EXPRESSION@57..62 0: JS_REFERENCE_IDENTIFIER@57..62 0: IDENT@57..62 "Base" [] [Whitespace(" ")] 2: (empty) - 5: (empty) - 6: L_CURLY@62..63 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@63..493 + 6: (empty) + 7: L_CURLY@62..63 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@63..493 0: JS_BOGUS_MEMBER@63..92 0: JS_PROPERTY_MODIFIER_LIST@63..86 0: TS_OVERRIDE_MODIFIER@63..77 @@ -564,7 +568,7 @@ JsModule { 1: JS_LITERAL_MEMBER_NAME@491..492 0: IDENT@491..492 "r" [] [] 2: SEMICOLON@492..493 ";" [] [] - 8: R_CURLY@493..495 "}" [Newline("\n")] [] + 9: R_CURLY@493..495 "}" [Newline("\n")] [] 3: EOF@495..496 "" [Newline("\n")] [] -- ts_class_invalid_modifier_combinations.ts:3:14 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ diff --git a/crates/rome_js_parser/test_data/inline/err/ts_class_member_accessor_readonly_precedence.rast b/crates/rome_js_parser/test_data/inline/err/ts_class_member_accessor_readonly_precedence.rast index c3fd6e7917b..116ef2e7d4a 100644 --- a/crates/rome_js_parser/test_data/inline/err/ts_class_member_accessor_readonly_precedence.rast +++ b/crates/rome_js_parser/test_data/inline/err/ts_class_member_accessor_readonly_precedence.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@0..6 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -53,15 +54,16 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..50 0: JS_CLASS_DECLARATION@0..50 - 0: (empty) - 1: CLASS_KW@0..6 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@6..8 + 0: JS_DECORATOR_LIST@0..0 + 1: (empty) + 2: CLASS_KW@0..6 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@6..8 0: IDENT@6..8 "A" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@8..9 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@9..48 + 6: (empty) + 7: L_CURLY@8..9 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@9..48 0: JS_BOGUS_MEMBER@9..48 0: JS_PROPERTY_MODIFIER_LIST@9..32 0: TS_READONLY_MODIFIER@9..23 @@ -79,7 +81,7 @@ JsModule { 1: JS_NUMBER_LITERAL_EXPRESSION@46..47 0: JS_NUMBER_LITERAL@46..47 "1" [] [] 4: SEMICOLON@47..48 ";" [] [] - 8: R_CURLY@48..50 "}" [Newline("\n")] [] + 9: R_CURLY@48..50 "}" [Newline("\n")] [] 3: EOF@50..51 "" [Newline("\n")] [] -- ts_class_member_accessor_readonly_precedence.ts:2:14 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ diff --git a/crates/rome_js_parser/test_data/inline/err/ts_class_modifier_precedence.rast b/crates/rome_js_parser/test_data/inline/err/ts_class_modifier_precedence.rast index 2e3c7766ff7..a0666deb8c2 100644 --- a/crates/rome_js_parser/test_data/inline/err/ts_class_modifier_precedence.rast +++ b/crates/rome_js_parser/test_data/inline/err/ts_class_modifier_precedence.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@0..6 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -53,6 +54,7 @@ JsModule { r_curly_token: R_CURLY@40..41 "}" [] [], }, JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: ABSTRACT_KW@41..51 "abstract" [Newline("\n")] [Whitespace(" ")], class_token: CLASS_KW@51..57 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -319,15 +321,16 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..524 0: JS_CLASS_DECLARATION@0..41 - 0: (empty) - 1: CLASS_KW@0..6 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@6..11 + 0: JS_DECORATOR_LIST@0..0 + 1: (empty) + 2: CLASS_KW@0..6 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@6..11 0: IDENT@6..11 "Base" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@11..13 "{" [] [Whitespace(" ")] - 7: JS_CLASS_MEMBER_LIST@13..40 + 6: (empty) + 7: L_CURLY@11..13 "{" [] [Whitespace(" ")] + 8: JS_CLASS_MEMBER_LIST@13..40 0: JS_PROPERTY_CLASS_MEMBER@13..20 0: JS_PROPERTY_MODIFIER_LIST@13..13 1: JS_LITERAL_MEMBER_NAME@13..18 @@ -356,22 +359,23 @@ JsModule { 2: (empty) 3: (empty) 4: SEMICOLON@39..40 ";" [] [] - 8: R_CURLY@40..41 "}" [] [] + 9: R_CURLY@40..41 "}" [] [] 1: JS_CLASS_DECLARATION@41..524 - 0: ABSTRACT_KW@41..51 "abstract" [Newline("\n")] [Whitespace(" ")] - 1: CLASS_KW@51..57 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@57..62 + 0: JS_DECORATOR_LIST@41..41 + 1: ABSTRACT_KW@41..51 "abstract" [Newline("\n")] [Whitespace(" ")] + 2: CLASS_KW@51..57 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@57..62 0: IDENT@57..62 "Test" [] [Whitespace(" ")] - 3: (empty) - 4: JS_EXTENDS_CLAUSE@62..75 + 4: (empty) + 5: JS_EXTENDS_CLAUSE@62..75 0: EXTENDS_KW@62..70 "extends" [] [Whitespace(" ")] 1: JS_IDENTIFIER_EXPRESSION@70..75 0: JS_REFERENCE_IDENTIFIER@70..75 0: IDENT@70..75 "Base" [] [Whitespace(" ")] 2: (empty) - 5: (empty) - 6: L_CURLY@75..76 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@76..522 + 6: (empty) + 7: L_CURLY@75..76 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@76..522 0: JS_BOGUS_MEMBER@76..129 0: JS_PROPERTY_MODIFIER_LIST@76..119 0: TS_READONLY_MODIFIER@76..111 @@ -511,7 +515,7 @@ JsModule { 1: TS_STRING_TYPE@515..521 0: STRING_KW@515..521 "string" [] [] 3: SEMICOLON@521..522 ";" [] [] - 8: R_CURLY@522..524 "}" [Newline("\n")] [] + 9: R_CURLY@522..524 "}" [Newline("\n")] [] 3: EOF@524..525 "" [Newline("\n")] [] -- ts_class_modifier_precedence.ts:4:14 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ diff --git a/crates/rome_js_parser/test_data/inline/err/ts_concrete_class_with_abstract_members.rast b/crates/rome_js_parser/test_data/inline/err/ts_concrete_class_with_abstract_members.rast index cfddd986559..67d4eeff33d 100644 --- a/crates/rome_js_parser/test_data/inline/err/ts_concrete_class_with_abstract_members.rast +++ b/crates/rome_js_parser/test_data/inline/err/ts_concrete_class_with_abstract_members.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@0..6 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -114,15 +115,16 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..122 0: JS_CLASS_DECLARATION@0..122 - 0: (empty) - 1: CLASS_KW@0..6 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@6..8 + 0: JS_DECORATOR_LIST@0..0 + 1: (empty) + 2: CLASS_KW@0..6 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@6..8 0: IDENT@6..8 "A" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@8..9 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@9..120 + 6: (empty) + 7: L_CURLY@8..9 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@9..120 0: JS_BOGUS_MEMBER@9..37 0: TS_PROPERTY_SIGNATURE_MODIFIER_LIST@9..22 0: TS_ABSTRACT_MODIFIER@9..22 @@ -179,7 +181,7 @@ JsModule { 3: (empty) 5: R_PAREN@118..119 ")" [] [] 6: SEMICOLON@119..120 ";" [] [] - 8: R_CURLY@120..122 "}" [Newline("\n")] [] + 9: R_CURLY@120..122 "}" [Newline("\n")] [] 3: EOF@122..123 "" [Newline("\n")] [] -- ts_concrete_class_with_abstract_members.ts:2:4 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ diff --git a/crates/rome_js_parser/test_data/inline/err/ts_constructor_this_parameter.rast b/crates/rome_js_parser/test_data/inline/err/ts_constructor_this_parameter.rast index 8c303962ea5..23faa93c931 100644 --- a/crates/rome_js_parser/test_data/inline/err/ts_constructor_this_parameter.rast +++ b/crates/rome_js_parser/test_data/inline/err/ts_constructor_this_parameter.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@0..6 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -48,15 +49,16 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..32 0: JS_CLASS_DECLARATION@0..32 - 0: (empty) - 1: CLASS_KW@0..6 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@6..8 + 0: JS_DECORATOR_LIST@0..0 + 1: (empty) + 2: CLASS_KW@0..6 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@6..8 0: IDENT@6..8 "C" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@8..10 "{" [] [Whitespace(" ")] - 7: JS_CLASS_MEMBER_LIST@10..31 + 6: (empty) + 7: L_CURLY@8..10 "{" [] [Whitespace(" ")] + 8: JS_CLASS_MEMBER_LIST@10..31 0: JS_CONSTRUCTOR_CLASS_MEMBER@10..31 0: JS_CONSTRUCTOR_MODIFIER_LIST@10..10 1: JS_LITERAL_MEMBER_NAME@10..21 @@ -72,7 +74,7 @@ JsModule { 1: JS_DIRECTIVE_LIST@29..29 2: JS_STATEMENT_LIST@29..29 3: R_CURLY@29..31 "}" [] [Whitespace(" ")] - 8: R_CURLY@31..32 "}" [] [] + 9: R_CURLY@31..32 "}" [] [] 3: EOF@32..33 "" [Newline("\n")] [] -- ts_constructor_this_parameter.ts:1:23 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ diff --git a/crates/rome_js_parser/test_data/inline/err/ts_constructor_type_parameters.rast b/crates/rome_js_parser/test_data/inline/err/ts_constructor_type_parameters.rast index 22d91a10f34..2afeece89b0 100644 --- a/crates/rome_js_parser/test_data/inline/err/ts_constructor_type_parameters.rast +++ b/crates/rome_js_parser/test_data/inline/err/ts_constructor_type_parameters.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@0..6 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -67,15 +68,16 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..32 0: JS_CLASS_DECLARATION@0..32 - 0: (empty) - 1: CLASS_KW@0..6 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@6..8 + 0: JS_DECORATOR_LIST@0..0 + 1: (empty) + 2: CLASS_KW@0..6 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@6..8 0: IDENT@6..8 "A" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@8..10 "{" [] [Whitespace(" ")] - 7: JS_CLASS_MEMBER_LIST@10..31 + 6: (empty) + 7: L_CURLY@8..10 "{" [] [Whitespace(" ")] + 8: JS_CLASS_MEMBER_LIST@10..31 0: JS_BOGUS_MEMBER@10..31 0: JS_CONSTRUCTOR_MODIFIER_LIST@10..10 1: JS_LITERAL_MEMBER_NAME@10..21 @@ -105,7 +107,7 @@ JsModule { 1: JS_DIRECTIVE_LIST@29..29 2: JS_STATEMENT_LIST@29..29 3: R_CURLY@29..31 "}" [] [Whitespace(" ")] - 8: R_CURLY@31..32 "}" [] [] + 9: R_CURLY@31..32 "}" [] [] 3: EOF@32..33 "" [Newline("\n")] [] -- ts_constructor_type_parameters.ts:1:22 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ diff --git a/crates/rome_js_parser/test_data/inline/err/ts_declare_const_initializer.rast b/crates/rome_js_parser/test_data/inline/err/ts_declare_const_initializer.rast new file mode 100644 index 00000000000..f3661725601 --- /dev/null +++ b/crates/rome_js_parser/test_data/inline/err/ts_declare_const_initializer.rast @@ -0,0 +1,138 @@ +JsModule { + interpreter_token: missing (optional), + directives: JsDirectiveList [], + items: JsModuleItemList [ + JsBogusStatement { + items: [ + DECLARE_KW@0..8 "declare" [] [Whitespace(" ")], + JsBogusStatement { + items: [ + JsDecorator { + at_token: AT@8..9 "@" [] [], + expression: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@9..19 "decorator" [] [Whitespace(" ")], + }, + }, + }, + ], + }, + JsClassDeclaration { + decorators: JsDecoratorList [], + abstract_token: missing (optional), + class_token: CLASS_KW@19..25 "class" [] [Whitespace(" ")], + id: JsIdentifierBinding { + name_token: IDENT@25..27 "D" [] [Whitespace(" ")], + }, + type_parameters: missing (optional), + extends_clause: missing (optional), + implements_clause: missing (optional), + l_curly_token: L_CURLY@27..28 "{" [] [], + members: JsClassMemberList [], + r_curly_token: R_CURLY@28..29 "}" [] [], + }, + ], + }, + JsBogusStatement { + items: [ + DECLARE_KW@29..38 "declare" [Newline("\n")] [Whitespace(" ")], + JsBogusStatement { + items: [ + JsDecorator { + at_token: AT@38..39 "@" [] [], + expression: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@39..49 "decorator" [] [Whitespace(" ")], + }, + }, + }, + ], + }, + JsClassDeclaration { + decorators: JsDecoratorList [], + abstract_token: ABSTRACT_KW@49..58 "abstract" [] [Whitespace(" ")], + class_token: CLASS_KW@58..64 "class" [] [Whitespace(" ")], + id: JsIdentifierBinding { + name_token: IDENT@64..66 "D" [] [Whitespace(" ")], + }, + type_parameters: missing (optional), + extends_clause: missing (optional), + implements_clause: missing (optional), + l_curly_token: L_CURLY@66..67 "{" [] [], + members: JsClassMemberList [], + r_curly_token: R_CURLY@67..68 "}" [] [], + }, + ], + }, + ], + eof_token: EOF@68..69 "" [Newline("\n")] [], +} + +0: JS_MODULE@0..69 + 0: (empty) + 1: JS_DIRECTIVE_LIST@0..0 + 2: JS_MODULE_ITEM_LIST@0..68 + 0: JS_BOGUS_STATEMENT@0..29 + 0: DECLARE_KW@0..8 "declare" [] [Whitespace(" ")] + 1: JS_BOGUS_STATEMENT@8..19 + 0: JS_DECORATOR@8..19 + 0: AT@8..9 "@" [] [] + 1: JS_IDENTIFIER_EXPRESSION@9..19 + 0: JS_REFERENCE_IDENTIFIER@9..19 + 0: IDENT@9..19 "decorator" [] [Whitespace(" ")] + 2: JS_CLASS_DECLARATION@19..29 + 0: JS_DECORATOR_LIST@19..19 + 1: (empty) + 2: CLASS_KW@19..25 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@25..27 + 0: IDENT@25..27 "D" [] [Whitespace(" ")] + 4: (empty) + 5: (empty) + 6: (empty) + 7: L_CURLY@27..28 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@28..28 + 9: R_CURLY@28..29 "}" [] [] + 1: JS_BOGUS_STATEMENT@29..68 + 0: DECLARE_KW@29..38 "declare" [Newline("\n")] [Whitespace(" ")] + 1: JS_BOGUS_STATEMENT@38..49 + 0: JS_DECORATOR@38..49 + 0: AT@38..39 "@" [] [] + 1: JS_IDENTIFIER_EXPRESSION@39..49 + 0: JS_REFERENCE_IDENTIFIER@39..49 + 0: IDENT@39..49 "decorator" [] [Whitespace(" ")] + 2: JS_CLASS_DECLARATION@49..68 + 0: JS_DECORATOR_LIST@49..49 + 1: ABSTRACT_KW@49..58 "abstract" [] [Whitespace(" ")] + 2: CLASS_KW@58..64 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@64..66 + 0: IDENT@64..66 "D" [] [Whitespace(" ")] + 4: (empty) + 5: (empty) + 6: (empty) + 7: L_CURLY@66..67 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@67..67 + 9: R_CURLY@67..68 "}" [] [] + 3: EOF@68..69 "" [Newline("\n")] [] +-- +ts_declare_const_initializer.ts:1:9 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Decorators are not valid here. + + > 1 │ declare @decorator class D {} + │ ^^^^^^^^^^ + 2 │ declare @decorator abstract class D {} + 3 │ + +-- +ts_declare_const_initializer.ts:2:9 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Decorators are not valid here. + + 1 │ declare @decorator class D {} + > 2 │ declare @decorator abstract class D {} + │ ^^^^^^^^^^ + 3 │ + +-- +declare @decorator class D {} +declare @decorator abstract class D {} diff --git a/crates/rome_js_parser/test_data/inline/err/ts_declare_const_initializer.ts b/crates/rome_js_parser/test_data/inline/err/ts_declare_const_initializer.ts new file mode 100644 index 00000000000..3ae06da3e75 --- /dev/null +++ b/crates/rome_js_parser/test_data/inline/err/ts_declare_const_initializer.ts @@ -0,0 +1,2 @@ +declare @decorator class D {} +declare @decorator abstract class D {} diff --git a/crates/rome_js_parser/test_data/inline/err/ts_declare_property_private_name.rast b/crates/rome_js_parser/test_data/inline/err/ts_declare_property_private_name.rast index c86f84f917d..23fd772eb76 100644 --- a/crates/rome_js_parser/test_data/inline/err/ts_declare_property_private_name.rast +++ b/crates/rome_js_parser/test_data/inline/err/ts_declare_property_private_name.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@0..6 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -49,15 +50,16 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..29 0: JS_CLASS_DECLARATION@0..28 - 0: (empty) - 1: CLASS_KW@0..6 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@6..8 + 0: JS_DECORATOR_LIST@0..0 + 1: (empty) + 2: CLASS_KW@0..6 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@6..8 0: IDENT@6..8 "A" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@8..10 "{" [] [Whitespace(" ")] - 7: JS_CLASS_MEMBER_LIST@10..27 + 6: (empty) + 7: L_CURLY@8..10 "{" [] [Whitespace(" ")] + 8: JS_CLASS_MEMBER_LIST@10..27 0: JS_BOGUS_MEMBER@10..27 0: JS_BOGUS@10..18 0: TS_DECLARE_MODIFIER@10..18 @@ -70,7 +72,7 @@ JsModule { 1: JS_PARAMETER_LIST@24..24 2: R_PAREN@24..25 ")" [] [] 3: SEMICOLON@25..27 ";" [] [Whitespace(" ")] - 8: R_CURLY@27..28 "}" [] [] + 9: R_CURLY@27..28 "}" [] [] 1: JS_EMPTY_STATEMENT@28..29 0: SEMICOLON@28..29 ";" [] [] 3: EOF@29..30 "" [Newline("\n")] [] diff --git a/crates/rome_js_parser/test_data/inline/err/ts_definite_assignment_in_ambient_context.rast b/crates/rome_js_parser/test_data/inline/err/ts_definite_assignment_in_ambient_context.rast index 49b5e049d0a..23cfd9c4105 100644 --- a/crates/rome_js_parser/test_data/inline/err/ts_definite_assignment_in_ambient_context.rast +++ b/crates/rome_js_parser/test_data/inline/err/ts_definite_assignment_in_ambient_context.rast @@ -5,6 +5,7 @@ JsModule { TsDeclareStatement { declare_token: DECLARE_KW@0..8 "declare" [] [Whitespace(" ")], declaration: JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@8..14 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -37,6 +38,7 @@ JsModule { }, }, JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@33..40 "class" [Newline("\n")] [Whitespace(" ")], id: JsIdentifierBinding { @@ -82,15 +84,16 @@ JsModule { 0: TS_DECLARE_STATEMENT@0..33 0: DECLARE_KW@0..8 "declare" [] [Whitespace(" ")] 1: JS_CLASS_DECLARATION@8..33 - 0: (empty) - 1: CLASS_KW@8..14 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@14..16 + 0: JS_DECORATOR_LIST@8..8 + 1: (empty) + 2: CLASS_KW@8..14 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@14..16 0: IDENT@14..16 "A" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@16..18 "{" [] [Whitespace(" ")] - 7: JS_CLASS_MEMBER_LIST@18..32 + 6: (empty) + 7: L_CURLY@16..18 "{" [] [Whitespace(" ")] + 8: JS_CLASS_MEMBER_LIST@18..32 0: JS_BOGUS_MEMBER@18..32 0: TS_PROPERTY_SIGNATURE_MODIFIER_LIST@18..18 1: JS_LITERAL_MEMBER_NAME@18..22 @@ -101,17 +104,18 @@ JsModule { 0: COLON@23..25 ":" [] [Whitespace(" ")] 1: TS_STRING_TYPE@25..32 0: STRING_KW@25..32 "string" [] [Whitespace(" ")] - 8: R_CURLY@32..33 "}" [] [] + 9: R_CURLY@32..33 "}" [] [] 1: JS_CLASS_DECLARATION@33..67 - 0: (empty) - 1: CLASS_KW@33..40 "class" [Newline("\n")] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@40..42 + 0: JS_DECORATOR_LIST@33..33 + 1: (empty) + 2: CLASS_KW@33..40 "class" [Newline("\n")] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@40..42 0: IDENT@40..42 "B" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@42..44 "{" [] [Whitespace(" ")] - 7: JS_CLASS_MEMBER_LIST@44..66 + 6: (empty) + 7: L_CURLY@42..44 "{" [] [Whitespace(" ")] + 8: JS_CLASS_MEMBER_LIST@44..66 0: JS_BOGUS_MEMBER@44..66 0: TS_PROPERTY_SIGNATURE_MODIFIER_LIST@44..52 0: TS_DECLARE_MODIFIER@44..52 @@ -124,7 +128,7 @@ JsModule { 0: COLON@57..59 ":" [] [Whitespace(" ")] 1: TS_STRING_TYPE@59..66 0: STRING_KW@59..66 "string" [] [Whitespace(" ")] - 8: R_CURLY@66..67 "}" [] [] + 9: R_CURLY@66..67 "}" [] [] 3: EOF@67..68 "" [Newline("\n")] [] -- ts_definite_assignment_in_ambient_context.ts:1:23 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ diff --git a/crates/rome_js_parser/test_data/inline/err/ts_export_declare.rast b/crates/rome_js_parser/test_data/inline/err/ts_export_declare.rast new file mode 100644 index 00000000000..65b780b1145 --- /dev/null +++ b/crates/rome_js_parser/test_data/inline/err/ts_export_declare.rast @@ -0,0 +1,152 @@ +JsModule { + interpreter_token: missing (optional), + directives: JsDirectiveList [], + items: JsModuleItemList [ + JsBogusStatement { + items: [ + EXPORT_KW@0..7 "export" [] [Whitespace(" ")], + JsBogus { + items: [ + DECLARE_KW@7..15 "declare" [] [Whitespace(" ")], + JsBogusStatement { + items: [ + JsDecorator { + at_token: AT@15..16 "@" [] [], + expression: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@16..26 "decorator" [] [Whitespace(" ")], + }, + }, + }, + ], + }, + JsClassDeclaration { + decorators: JsDecoratorList [], + abstract_token: missing (optional), + class_token: CLASS_KW@26..32 "class" [] [Whitespace(" ")], + id: JsIdentifierBinding { + name_token: IDENT@32..34 "D" [] [Whitespace(" ")], + }, + type_parameters: missing (optional), + extends_clause: missing (optional), + implements_clause: missing (optional), + l_curly_token: L_CURLY@34..35 "{" [] [], + members: JsClassMemberList [], + r_curly_token: R_CURLY@35..36 "}" [] [], + }, + ], + }, + ], + }, + JsBogusStatement { + items: [ + EXPORT_KW@36..44 "export" [Newline("\n")] [Whitespace(" ")], + JsBogus { + items: [ + DECLARE_KW@44..52 "declare" [] [Whitespace(" ")], + JsBogusStatement { + items: [ + JsDecorator { + at_token: AT@52..53 "@" [] [], + expression: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@53..63 "decorator" [] [Whitespace(" ")], + }, + }, + }, + ], + }, + JsClassDeclaration { + decorators: JsDecoratorList [], + abstract_token: ABSTRACT_KW@63..72 "abstract" [] [Whitespace(" ")], + class_token: CLASS_KW@72..78 "class" [] [Whitespace(" ")], + id: JsIdentifierBinding { + name_token: IDENT@78..80 "D" [] [Whitespace(" ")], + }, + type_parameters: missing (optional), + extends_clause: missing (optional), + implements_clause: missing (optional), + l_curly_token: L_CURLY@80..81 "{" [] [], + members: JsClassMemberList [], + r_curly_token: R_CURLY@81..82 "}" [] [], + }, + ], + }, + ], + }, + ], + eof_token: EOF@82..83 "" [Newline("\n")] [], +} + +0: JS_MODULE@0..83 + 0: (empty) + 1: JS_DIRECTIVE_LIST@0..0 + 2: JS_MODULE_ITEM_LIST@0..82 + 0: JS_BOGUS_STATEMENT@0..36 + 0: EXPORT_KW@0..7 "export" [] [Whitespace(" ")] + 1: JS_BOGUS@7..36 + 0: DECLARE_KW@7..15 "declare" [] [Whitespace(" ")] + 1: JS_BOGUS_STATEMENT@15..26 + 0: JS_DECORATOR@15..26 + 0: AT@15..16 "@" [] [] + 1: JS_IDENTIFIER_EXPRESSION@16..26 + 0: JS_REFERENCE_IDENTIFIER@16..26 + 0: IDENT@16..26 "decorator" [] [Whitespace(" ")] + 2: JS_CLASS_DECLARATION@26..36 + 0: JS_DECORATOR_LIST@26..26 + 1: (empty) + 2: CLASS_KW@26..32 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@32..34 + 0: IDENT@32..34 "D" [] [Whitespace(" ")] + 4: (empty) + 5: (empty) + 6: (empty) + 7: L_CURLY@34..35 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@35..35 + 9: R_CURLY@35..36 "}" [] [] + 1: JS_BOGUS_STATEMENT@36..82 + 0: EXPORT_KW@36..44 "export" [Newline("\n")] [Whitespace(" ")] + 1: JS_BOGUS@44..82 + 0: DECLARE_KW@44..52 "declare" [] [Whitespace(" ")] + 1: JS_BOGUS_STATEMENT@52..63 + 0: JS_DECORATOR@52..63 + 0: AT@52..53 "@" [] [] + 1: JS_IDENTIFIER_EXPRESSION@53..63 + 0: JS_REFERENCE_IDENTIFIER@53..63 + 0: IDENT@53..63 "decorator" [] [Whitespace(" ")] + 2: JS_CLASS_DECLARATION@63..82 + 0: JS_DECORATOR_LIST@63..63 + 1: ABSTRACT_KW@63..72 "abstract" [] [Whitespace(" ")] + 2: CLASS_KW@72..78 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@78..80 + 0: IDENT@78..80 "D" [] [Whitespace(" ")] + 4: (empty) + 5: (empty) + 6: (empty) + 7: L_CURLY@80..81 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@81..81 + 9: R_CURLY@81..82 "}" [] [] + 3: EOF@82..83 "" [Newline("\n")] [] +-- +ts_export_declare.ts:1:16 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Decorators are not valid here. + + > 1 │ export declare @decorator class D {} + │ ^^^^^^^^^^ + 2 │ export declare @decorator abstract class D {} + 3 │ + +-- +ts_export_declare.ts:2:16 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Decorators are not valid here. + + 1 │ export declare @decorator class D {} + > 2 │ export declare @decorator abstract class D {} + │ ^^^^^^^^^^ + 3 │ + +-- +export declare @decorator class D {} +export declare @decorator abstract class D {} diff --git a/crates/rome_js_parser/test_data/inline/err/ts_export_declare.ts b/crates/rome_js_parser/test_data/inline/err/ts_export_declare.ts new file mode 100644 index 00000000000..dd32692d7dd --- /dev/null +++ b/crates/rome_js_parser/test_data/inline/err/ts_export_declare.ts @@ -0,0 +1,2 @@ +export declare @decorator class D {} +export declare @decorator abstract class D {} diff --git a/crates/rome_js_parser/test_data/inline/err/ts_getter_setter_type_parameters.rast b/crates/rome_js_parser/test_data/inline/err/ts_getter_setter_type_parameters.rast index f4614d06b9a..b0d9485adcd 100644 --- a/crates/rome_js_parser/test_data/inline/err/ts_getter_setter_type_parameters.rast +++ b/crates/rome_js_parser/test_data/inline/err/ts_getter_setter_type_parameters.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@0..6 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -112,15 +113,16 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..55 0: JS_CLASS_DECLARATION@0..55 - 0: (empty) - 1: CLASS_KW@0..6 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@6..11 + 0: JS_DECORATOR_LIST@0..0 + 1: (empty) + 2: CLASS_KW@0..6 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@6..11 0: IDENT@6..11 "Test" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@11..12 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@12..53 + 6: (empty) + 7: L_CURLY@11..12 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@12..53 0: JS_BOGUS_MEMBER@12..30 0: JS_METHOD_MODIFIER_LIST@12..12 1: GET_KW@12..18 "get" [Newline("\n"), Whitespace(" ")] [Whitespace(" ")] @@ -182,7 +184,7 @@ JsModule { 1: JS_DIRECTIVE_LIST@52..52 2: JS_STATEMENT_LIST@52..52 3: R_CURLY@52..53 "}" [] [] - 8: R_CURLY@53..55 "}" [Newline("\n")] [] + 9: R_CURLY@53..55 "}" [Newline("\n")] [] 3: EOF@55..56 "" [Newline("\n")] [] -- ts_getter_setter_type_parameters.ts:2:7 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ diff --git a/crates/rome_js_parser/test_data/inline/err/ts_index_signature_class_member_cannot_be_abstract.rast b/crates/rome_js_parser/test_data/inline/err/ts_index_signature_class_member_cannot_be_abstract.rast index 73d74b8bd32..9a00b72b03c 100644 --- a/crates/rome_js_parser/test_data/inline/err/ts_index_signature_class_member_cannot_be_abstract.rast +++ b/crates/rome_js_parser/test_data/inline/err/ts_index_signature_class_member_cannot_be_abstract.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: ABSTRACT_KW@0..9 "abstract" [] [Whitespace(" ")], class_token: CLASS_KW@9..15 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -56,15 +57,16 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..54 0: JS_CLASS_DECLARATION@0..54 - 0: ABSTRACT_KW@0..9 "abstract" [] [Whitespace(" ")] - 1: CLASS_KW@9..15 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@15..17 + 0: JS_DECORATOR_LIST@0..0 + 1: ABSTRACT_KW@0..9 "abstract" [] [Whitespace(" ")] + 2: CLASS_KW@9..15 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@15..17 0: IDENT@15..17 "A" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@17..18 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@18..52 + 6: (empty) + 7: L_CURLY@17..18 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@18..52 0: JS_BOGUS_MEMBER@18..52 0: JS_BOGUS@18..32 0: TS_ABSTRACT_MODIFIER@18..32 @@ -83,7 +85,7 @@ JsModule { 1: TS_STRING_TYPE@45..51 0: STRING_KW@45..51 "string" [] [] 5: SEMICOLON@51..52 ";" [] [] - 8: R_CURLY@52..54 "}" [Newline("\n")] [] + 9: R_CURLY@52..54 "}" [Newline("\n")] [] 3: EOF@54..55 "" [Newline("\n")] [] -- ts_index_signature_class_member_cannot_be_abstract.ts:2:5 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ diff --git a/crates/rome_js_parser/test_data/inline/err/ts_index_signature_class_member_cannot_be_accessor.rast b/crates/rome_js_parser/test_data/inline/err/ts_index_signature_class_member_cannot_be_accessor.rast index a060086c0d4..6517f046542 100644 --- a/crates/rome_js_parser/test_data/inline/err/ts_index_signature_class_member_cannot_be_accessor.rast +++ b/crates/rome_js_parser/test_data/inline/err/ts_index_signature_class_member_cannot_be_accessor.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: ABSTRACT_KW@0..9 "abstract" [] [Whitespace(" ")], class_token: CLASS_KW@9..15 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -56,15 +57,16 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..54 0: JS_CLASS_DECLARATION@0..54 - 0: ABSTRACT_KW@0..9 "abstract" [] [Whitespace(" ")] - 1: CLASS_KW@9..15 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@15..17 + 0: JS_DECORATOR_LIST@0..0 + 1: ABSTRACT_KW@0..9 "abstract" [] [Whitespace(" ")] + 2: CLASS_KW@9..15 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@15..17 0: IDENT@15..17 "A" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@17..18 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@18..52 + 6: (empty) + 7: L_CURLY@17..18 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@18..52 0: JS_BOGUS_MEMBER@18..52 0: JS_BOGUS@18..32 0: JS_ACCESSOR_MODIFIER@18..32 @@ -83,7 +85,7 @@ JsModule { 1: TS_STRING_TYPE@45..51 0: STRING_KW@45..51 "string" [] [] 5: SEMICOLON@51..52 ";" [] [] - 8: R_CURLY@52..54 "}" [Newline("\n")] [] + 9: R_CURLY@52..54 "}" [Newline("\n")] [] 3: EOF@54..55 "" [Newline("\n")] [] -- ts_index_signature_class_member_cannot_be_accessor.ts:2:5 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ diff --git a/crates/rome_js_parser/test_data/inline/err/ts_index_signature_class_member_cannot_have_visibility_modifiers.rast b/crates/rome_js_parser/test_data/inline/err/ts_index_signature_class_member_cannot_have_visibility_modifiers.rast index f945462a240..a0dfc94f293 100644 --- a/crates/rome_js_parser/test_data/inline/err/ts_index_signature_class_member_cannot_have_visibility_modifiers.rast +++ b/crates/rome_js_parser/test_data/inline/err/ts_index_signature_class_member_cannot_have_visibility_modifiers.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@0..6 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -48,6 +49,7 @@ JsModule { r_curly_token: R_CURLY@42..44 "}" [Newline("\n")] [], }, JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@44..51 "class" [Newline("\n")] [Whitespace(" ")], id: JsIdentifierBinding { @@ -93,6 +95,7 @@ JsModule { r_curly_token: R_CURLY@88..90 "}" [Newline("\n")] [], }, JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@90..97 "class" [Newline("\n")] [Whitespace(" ")], id: JsIdentifierBinding { @@ -146,15 +149,16 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..138 0: JS_CLASS_DECLARATION@0..44 - 0: (empty) - 1: CLASS_KW@0..6 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@6..8 + 0: JS_DECORATOR_LIST@0..0 + 1: (empty) + 2: CLASS_KW@0..6 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@6..8 0: IDENT@6..8 "A" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@8..9 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@9..42 + 6: (empty) + 7: L_CURLY@8..9 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@9..42 0: JS_BOGUS_MEMBER@9..42 0: JS_BOGUS@9..22 0: TS_ACCESSIBILITY_MODIFIER@9..22 @@ -173,17 +177,18 @@ JsModule { 1: TS_STRING_TYPE@35..41 0: STRING_KW@35..41 "string" [] [] 5: SEMICOLON@41..42 ";" [] [] - 8: R_CURLY@42..44 "}" [Newline("\n")] [] + 9: R_CURLY@42..44 "}" [Newline("\n")] [] 1: JS_CLASS_DECLARATION@44..90 - 0: (empty) - 1: CLASS_KW@44..51 "class" [Newline("\n")] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@51..53 + 0: JS_DECORATOR_LIST@44..44 + 1: (empty) + 2: CLASS_KW@44..51 "class" [Newline("\n")] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@51..53 0: IDENT@51..53 "B" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@53..54 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@54..88 + 6: (empty) + 7: L_CURLY@53..54 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@54..88 0: JS_BOGUS_MEMBER@54..88 0: JS_BOGUS@54..68 0: TS_ACCESSIBILITY_MODIFIER@54..68 @@ -202,17 +207,18 @@ JsModule { 1: TS_STRING_TYPE@81..87 0: STRING_KW@81..87 "string" [] [] 5: SEMICOLON@87..88 ";" [] [] - 8: R_CURLY@88..90 "}" [Newline("\n")] [] + 9: R_CURLY@88..90 "}" [Newline("\n")] [] 2: JS_CLASS_DECLARATION@90..138 - 0: (empty) - 1: CLASS_KW@90..97 "class" [Newline("\n")] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@97..99 + 0: JS_DECORATOR_LIST@90..90 + 1: (empty) + 2: CLASS_KW@90..97 "class" [Newline("\n")] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@97..99 0: IDENT@97..99 "C" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@99..100 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@100..136 + 6: (empty) + 7: L_CURLY@99..100 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@100..136 0: JS_BOGUS_MEMBER@100..136 0: JS_BOGUS@100..116 0: TS_ACCESSIBILITY_MODIFIER@100..116 @@ -231,7 +237,7 @@ JsModule { 1: TS_STRING_TYPE@129..135 0: STRING_KW@129..135 "string" [] [] 5: SEMICOLON@135..136 ";" [] [] - 8: R_CURLY@136..138 "}" [Newline("\n")] [] + 9: R_CURLY@136..138 "}" [Newline("\n")] [] 3: EOF@138..139 "" [Newline("\n")] [] -- ts_index_signature_class_member_cannot_have_visibility_modifiers.ts:2:5 parse ━━━━━━━━━━━━━━━━━━━━━━ diff --git a/crates/rome_js_parser/test_data/inline/err/ts_index_signature_class_member_static_readonly_precedence.rast b/crates/rome_js_parser/test_data/inline/err/ts_index_signature_class_member_static_readonly_precedence.rast index 7e25c19de5a..365cec5fc6c 100644 --- a/crates/rome_js_parser/test_data/inline/err/ts_index_signature_class_member_static_readonly_precedence.rast +++ b/crates/rome_js_parser/test_data/inline/err/ts_index_signature_class_member_static_readonly_precedence.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@0..6 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -57,15 +58,16 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..52 0: JS_CLASS_DECLARATION@0..52 - 0: (empty) - 1: CLASS_KW@0..6 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@6..8 + 0: JS_DECORATOR_LIST@0..0 + 1: (empty) + 2: CLASS_KW@0..6 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@6..8 0: IDENT@6..8 "A" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@8..9 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@9..50 + 6: (empty) + 7: L_CURLY@8..9 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@9..50 0: JS_BOGUS_MEMBER@9..50 0: TS_INDEX_SIGNATURE_MODIFIER_LIST@9..30 0: TS_READONLY_MODIFIER@9..23 @@ -86,7 +88,7 @@ JsModule { 1: TS_STRING_TYPE@43..49 0: STRING_KW@43..49 "string" [] [] 5: SEMICOLON@49..50 ";" [] [] - 8: R_CURLY@50..52 "}" [Newline("\n")] [] + 9: R_CURLY@50..52 "}" [Newline("\n")] [] 3: EOF@52..53 "" [Newline("\n")] [] -- ts_index_signature_class_member_static_readonly_precedence.ts:2:14 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━ diff --git a/crates/rome_js_parser/test_data/inline/err/ts_instantiation_expressions_1.rast b/crates/rome_js_parser/test_data/inline/err/ts_instantiation_expressions_1.rast index dcd65f3a578..440ac59a6a7 100644 --- a/crates/rome_js_parser/test_data/inline/err/ts_instantiation_expressions_1.rast +++ b/crates/rome_js_parser/test_data/inline/err/ts_instantiation_expressions_1.rast @@ -644,6 +644,7 @@ JsModule { semicolon_token: SEMICOLON@299..300 ";" [] [], }, JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@300..307 "class" [Newline("\n")] [Whitespace(" ")], id: JsIdentifierBinding { @@ -1173,15 +1174,16 @@ JsModule { 24: JS_EMPTY_STATEMENT@299..300 0: SEMICOLON@299..300 ";" [] [] 25: JS_CLASS_DECLARATION@300..361 - 0: (empty) - 1: CLASS_KW@300..307 "class" [Newline("\n")] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@307..310 + 0: JS_DECORATOR_LIST@300..300 + 1: (empty) + 2: CLASS_KW@300..307 "class" [Newline("\n")] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@307..310 0: IDENT@307..310 "C5" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@310..311 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@311..359 + 6: (empty) + 7: L_CURLY@310..311 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@311..359 0: JS_PROPERTY_CLASS_MEMBER@311..359 0: JS_PROPERTY_MODIFIER_LIST@311..326 0: TS_ACCESSIBILITY_MODIFIER@311..326 @@ -1209,7 +1211,7 @@ JsModule { 2: JS_NUMBER_LITERAL_EXPRESSION@356..359 0: JS_NUMBER_LITERAL@356..359 "123" [] [] 4: (empty) - 8: R_CURLY@359..361 "}" [Newline("\n")] [] + 9: R_CURLY@359..361 "}" [Newline("\n")] [] 26: JS_FOR_IN_STATEMENT@361..401 0: FOR_KW@361..366 "for" [Newline("\n")] [Whitespace(" ")] 1: L_PAREN@366..367 "(" [] [] diff --git a/crates/rome_js_parser/test_data/inline/err/ts_invalid_decorated_class_members.rast b/crates/rome_js_parser/test_data/inline/err/ts_invalid_decorated_class_members.rast index 3cf47e0f9f9..59b8ea7430c 100644 --- a/crates/rome_js_parser/test_data/inline/err/ts_invalid_decorated_class_members.rast +++ b/crates/rome_js_parser/test_data/inline/err/ts_invalid_decorated_class_members.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: ABSTRACT_KW@0..9 "abstract" [] [Whitespace(" ")], class_token: CLASS_KW@9..15 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -114,15 +115,16 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..164 0: JS_CLASS_DECLARATION@0..164 - 0: ABSTRACT_KW@0..9 "abstract" [] [Whitespace(" ")] - 1: CLASS_KW@9..15 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@15..20 + 0: JS_DECORATOR_LIST@0..0 + 1: ABSTRACT_KW@0..9 "abstract" [] [Whitespace(" ")] + 2: CLASS_KW@9..15 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@15..20 0: IDENT@15..20 "Test" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@20..21 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@21..162 + 6: (empty) + 7: L_CURLY@20..21 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@21..162 0: TS_METHOD_SIGNATURE_CLASS_MEMBER@21..39 0: TS_METHOD_SIGNATURE_MODIFIER_LIST@21..21 1: (empty) @@ -189,7 +191,7 @@ JsModule { 4: (empty) 5: R_PAREN@160..161 ")" [] [] 6: SEMICOLON@161..162 ";" [] [] - 8: R_CURLY@162..164 "}" [Newline("\n")] [] + 9: R_CURLY@162..164 "}" [Newline("\n")] [] 3: EOF@164..165 "" [Newline("\n")] [] -- ts_invalid_decorated_class_members.ts:6:29 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ diff --git a/crates/rome_js_parser/test_data/inline/err/ts_method_members_with_missing_body.rast b/crates/rome_js_parser/test_data/inline/err/ts_method_members_with_missing_body.rast index cadafefbc7b..02cc700e079 100644 --- a/crates/rome_js_parser/test_data/inline/err/ts_method_members_with_missing_body.rast +++ b/crates/rome_js_parser/test_data/inline/err/ts_method_members_with_missing_body.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@0..6 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -83,15 +84,16 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..74 0: JS_CLASS_DECLARATION@0..74 - 0: (empty) - 1: CLASS_KW@0..6 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@6..11 + 0: JS_DECORATOR_LIST@0..0 + 1: (empty) + 2: CLASS_KW@0..6 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@6..11 0: IDENT@6..11 "Test" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@11..12 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@12..72 + 6: (empty) + 7: L_CURLY@11..12 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@12..72 0: JS_CONSTRUCTOR_CLASS_MEMBER@12..32 0: JS_CONSTRUCTOR_MODIFIER_LIST@12..12 1: JS_LITERAL_MEMBER_NAME@12..29 @@ -138,7 +140,7 @@ JsModule { 3: (empty) 5: R_PAREN@71..72 ")" [] [] 6: (empty) - 8: R_CURLY@72..74 "}" [Newline("\n")] [] + 9: R_CURLY@72..74 "}" [Newline("\n")] [] 3: EOF@74..75 "" [Newline("\n")] [] -- ts_method_members_with_missing_body.ts:2:20 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ diff --git a/crates/rome_js_parser/test_data/inline/err/ts_method_signature_generator.rast b/crates/rome_js_parser/test_data/inline/err/ts_method_signature_generator.rast index 50f7390557a..1f9dab798e9 100644 --- a/crates/rome_js_parser/test_data/inline/err/ts_method_signature_generator.rast +++ b/crates/rome_js_parser/test_data/inline/err/ts_method_signature_generator.rast @@ -5,6 +5,7 @@ JsModule { TsDeclareStatement { declare_token: DECLARE_KW@0..8 "declare" [] [Whitespace(" ")], declaration: JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@8..14 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -35,6 +36,7 @@ JsModule { }, }, JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: ABSTRACT_KW@31..41 "abstract" [Newline("\n")] [Whitespace(" ")], class_token: CLASS_KW@41..47 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -68,6 +70,7 @@ JsModule { r_curly_token: R_CURLY@72..73 "}" [] [], }, JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@73..80 "class" [Newline("\n")] [Whitespace(" ")], id: JsIdentifierBinding { @@ -129,15 +132,16 @@ JsModule { 0: TS_DECLARE_STATEMENT@0..31 0: DECLARE_KW@0..8 "declare" [] [Whitespace(" ")] 1: JS_CLASS_DECLARATION@8..31 - 0: (empty) - 1: CLASS_KW@8..14 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@14..16 + 0: JS_DECORATOR_LIST@8..8 + 1: (empty) + 2: CLASS_KW@8..14 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@14..16 0: IDENT@14..16 "A" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@16..18 "{" [] [Whitespace(" ")] - 7: JS_CLASS_MEMBER_LIST@18..30 + 6: (empty) + 7: L_CURLY@16..18 "{" [] [Whitespace(" ")] + 8: JS_CLASS_MEMBER_LIST@18..30 0: JS_BOGUS_MEMBER@18..30 0: TS_METHOD_SIGNATURE_MODIFIER_LIST@18..18 1: STAR@18..20 "*" [] [Whitespace(" ")] @@ -148,17 +152,18 @@ JsModule { 1: JS_PARAMETER_LIST@27..27 2: R_PAREN@27..28 ")" [] [] 4: SEMICOLON@28..30 ";" [] [Whitespace(" ")] - 8: R_CURLY@30..31 "}" [] [] + 9: R_CURLY@30..31 "}" [] [] 1: JS_CLASS_DECLARATION@31..73 - 0: ABSTRACT_KW@31..41 "abstract" [Newline("\n")] [Whitespace(" ")] - 1: CLASS_KW@41..47 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@47..49 + 0: JS_DECORATOR_LIST@31..31 + 1: ABSTRACT_KW@31..41 "abstract" [Newline("\n")] [Whitespace(" ")] + 2: CLASS_KW@41..47 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@47..49 0: IDENT@47..49 "B" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@49..51 "{" [] [Whitespace(" ")] - 7: JS_CLASS_MEMBER_LIST@51..72 + 6: (empty) + 7: L_CURLY@49..51 "{" [] [Whitespace(" ")] + 8: JS_CLASS_MEMBER_LIST@51..72 0: JS_BOGUS_MEMBER@51..72 0: TS_METHOD_SIGNATURE_MODIFIER_LIST@51..60 0: TS_ABSTRACT_MODIFIER@51..60 @@ -171,17 +176,18 @@ JsModule { 1: JS_PARAMETER_LIST@69..69 2: R_PAREN@69..70 ")" [] [] 4: SEMICOLON@70..72 ";" [] [Whitespace(" ")] - 8: R_CURLY@72..73 "}" [] [] + 9: R_CURLY@72..73 "}" [] [] 2: JS_CLASS_DECLARATION@73..125 - 0: (empty) - 1: CLASS_KW@73..80 "class" [Newline("\n")] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@80..82 + 0: JS_DECORATOR_LIST@73..73 + 1: (empty) + 2: CLASS_KW@73..80 "class" [Newline("\n")] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@80..82 0: IDENT@80..82 "C" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@82..83 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@83..123 + 6: (empty) + 7: L_CURLY@82..83 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@83..123 0: JS_BOGUS_MEMBER@83..102 0: TS_METHOD_SIGNATURE_MODIFIER_LIST@83..83 1: STAR@83..91 "*" [Newline("\n"), Whitespace(" ")] [Whitespace(" ")] @@ -210,7 +216,7 @@ JsModule { 1: JS_DIRECTIVE_LIST@122..122 2: JS_STATEMENT_LIST@122..122 3: R_CURLY@122..123 "}" [] [] - 8: R_CURLY@123..125 "}" [Newline("\n")] [] + 9: R_CURLY@123..125 "}" [Newline("\n")] [] 3: EOF@125..126 "" [Newline("\n")] [] -- ts_method_signature_generator.ts:1:19 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ diff --git a/crates/rome_js_parser/test_data/inline/err/ts_property_initializer_ambient_context.rast b/crates/rome_js_parser/test_data/inline/err/ts_property_initializer_ambient_context.rast index 9a00d4758ee..8e4cf74a806 100644 --- a/crates/rome_js_parser/test_data/inline/err/ts_property_initializer_ambient_context.rast +++ b/crates/rome_js_parser/test_data/inline/err/ts_property_initializer_ambient_context.rast @@ -5,6 +5,7 @@ JsModule { TsDeclareStatement { declare_token: DECLARE_KW@0..8 "declare" [] [Whitespace(" ")], declaration: JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@8..14 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -34,6 +35,7 @@ JsModule { }, }, JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@34..41 "class" [Newline("\n")] [Whitespace(" ")], id: JsIdentifierBinding { @@ -76,15 +78,16 @@ JsModule { 0: TS_DECLARE_STATEMENT@0..34 0: DECLARE_KW@0..8 "declare" [] [Whitespace(" ")] 1: JS_CLASS_DECLARATION@8..34 - 0: (empty) - 1: CLASS_KW@8..14 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@14..16 + 0: JS_DECORATOR_LIST@8..8 + 1: (empty) + 2: CLASS_KW@8..14 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@14..16 0: IDENT@14..16 "A" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@16..18 "{" [] [Whitespace(" ")] - 7: JS_CLASS_MEMBER_LIST@18..33 + 6: (empty) + 7: L_CURLY@16..18 "{" [] [Whitespace(" ")] + 8: JS_CLASS_MEMBER_LIST@18..33 0: TS_INITIALIZED_PROPERTY_SIGNATURE_CLASS_MEMBER@18..33 0: TS_PROPERTY_SIGNATURE_MODIFIER_LIST@18..18 1: JS_LITERAL_MEMBER_NAME@18..23 @@ -95,17 +98,18 @@ JsModule { 1: JS_STRING_LITERAL_EXPRESSION@25..31 0: JS_STRING_LITERAL@25..31 "\"test\"" [] [] 4: SEMICOLON@31..33 ";" [] [Whitespace(" ")] - 8: R_CURLY@33..34 "}" [] [] + 9: R_CURLY@33..34 "}" [] [] 1: JS_CLASS_DECLARATION@34..69 - 0: (empty) - 1: CLASS_KW@34..41 "class" [Newline("\n")] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@41..43 + 0: JS_DECORATOR_LIST@34..34 + 1: (empty) + 2: CLASS_KW@34..41 "class" [Newline("\n")] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@41..43 0: IDENT@41..43 "B" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@43..45 "{" [] [Whitespace(" ")] - 7: JS_CLASS_MEMBER_LIST@45..68 + 6: (empty) + 7: L_CURLY@43..45 "{" [] [Whitespace(" ")] + 8: JS_CLASS_MEMBER_LIST@45..68 0: TS_INITIALIZED_PROPERTY_SIGNATURE_CLASS_MEMBER@45..68 0: TS_PROPERTY_SIGNATURE_MODIFIER_LIST@45..53 0: TS_DECLARE_MODIFIER@45..53 @@ -118,7 +122,7 @@ JsModule { 1: JS_STRING_LITERAL_EXPRESSION@60..66 0: JS_STRING_LITERAL@60..66 "\"test\"" [] [] 4: SEMICOLON@66..68 ";" [] [Whitespace(" ")] - 8: R_CURLY@68..69 "}" [] [] + 9: R_CURLY@68..69 "}" [] [] 3: EOF@69..70 "" [Newline("\n")] [] -- ts_property_initializer_ambient_context.ts:1:24 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ diff --git a/crates/rome_js_parser/test_data/inline/err/ts_property_parameter_pattern.rast b/crates/rome_js_parser/test_data/inline/err/ts_property_parameter_pattern.rast index c1842b2a9f4..5fc4b9e13a6 100644 --- a/crates/rome_js_parser/test_data/inline/err/ts_property_parameter_pattern.rast +++ b/crates/rome_js_parser/test_data/inline/err/ts_property_parameter_pattern.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@0..6 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -98,15 +99,16 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..62 0: JS_CLASS_DECLARATION@0..62 - 0: (empty) - 1: CLASS_KW@0..6 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@6..8 + 0: JS_DECORATOR_LIST@0..0 + 1: (empty) + 2: CLASS_KW@0..6 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@6..8 0: IDENT@6..8 "A" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@8..10 "{" [] [Whitespace(" ")] - 7: JS_CLASS_MEMBER_LIST@10..61 + 6: (empty) + 7: L_CURLY@8..10 "{" [] [Whitespace(" ")] + 8: JS_CLASS_MEMBER_LIST@10..61 0: JS_CONSTRUCTOR_CLASS_MEMBER@10..61 0: JS_CONSTRUCTOR_MODIFIER_LIST@10..10 1: JS_LITERAL_MEMBER_NAME@10..21 @@ -153,7 +155,7 @@ JsModule { 1: JS_DIRECTIVE_LIST@59..59 2: JS_STATEMENT_LIST@59..59 3: R_CURLY@59..61 "}" [] [Whitespace(" ")] - 8: R_CURLY@61..62 "}" [] [] + 9: R_CURLY@61..62 "}" [] [] 3: EOF@62..63 "" [Newline("\n")] [] -- ts_property_parameter_pattern.ts:1:31 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ diff --git a/crates/rome_js_parser/test_data/inline/err/ts_readonly_modifier_non_class_or_indexer.rast b/crates/rome_js_parser/test_data/inline/err/ts_readonly_modifier_non_class_or_indexer.rast index afefcd72fbd..da617ad6ed4 100644 --- a/crates/rome_js_parser/test_data/inline/err/ts_readonly_modifier_non_class_or_indexer.rast +++ b/crates/rome_js_parser/test_data/inline/err/ts_readonly_modifier_non_class_or_indexer.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@0..6 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -142,15 +143,16 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..141 0: JS_CLASS_DECLARATION@0..141 - 0: (empty) - 1: CLASS_KW@0..6 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@6..11 + 0: JS_DECORATOR_LIST@0..0 + 1: (empty) + 2: CLASS_KW@0..6 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@6..11 0: IDENT@6..11 "Test" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@11..12 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@12..139 + 6: (empty) + 7: L_CURLY@11..12 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@12..139 0: JS_BOGUS_MEMBER@12..40 0: JS_BOGUS@12..24 0: TS_READONLY_MODIFIER@12..24 @@ -223,7 +225,7 @@ JsModule { 1: JS_DIRECTIVE_LIST@138..138 2: JS_STATEMENT_LIST@138..138 3: R_CURLY@138..139 "}" [] [] - 8: R_CURLY@139..141 "}" [Newline("\n")] [] + 9: R_CURLY@139..141 "}" [Newline("\n")] [] 3: EOF@141..142 "" [Newline("\n")] [] -- ts_readonly_modifier_non_class_or_indexer.ts:2:3 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ diff --git a/crates/rome_js_parser/test_data/inline/err/ts_setter_return_type_annotation.rast b/crates/rome_js_parser/test_data/inline/err/ts_setter_return_type_annotation.rast index ea63c823448..cda945771bd 100644 --- a/crates/rome_js_parser/test_data/inline/err/ts_setter_return_type_annotation.rast +++ b/crates/rome_js_parser/test_data/inline/err/ts_setter_return_type_annotation.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@0..6 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -61,15 +62,16 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..48 0: JS_CLASS_DECLARATION@0..48 - 0: (empty) - 1: CLASS_KW@0..6 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@6..11 + 0: JS_DECORATOR_LIST@0..0 + 1: (empty) + 2: CLASS_KW@0..6 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@6..11 0: IDENT@6..11 "Test" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@11..12 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@12..46 + 6: (empty) + 7: L_CURLY@11..12 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@12..46 0: JS_BOGUS_MEMBER@12..46 0: JS_METHOD_MODIFIER_LIST@12..12 1: SET_KW@12..21 "set" [Newline("\n"), Whitespace(" ")] [Whitespace(" ")] @@ -95,7 +97,7 @@ JsModule { 1: JS_DIRECTIVE_LIST@45..45 2: JS_STATEMENT_LIST@45..45 3: R_CURLY@45..46 "}" [] [] - 8: R_CURLY@46..48 "}" [Newline("\n")] [] + 9: R_CURLY@46..48 "}" [Newline("\n")] [] 3: EOF@48..49 "" [Newline("\n")] [] -- ts_setter_return_type_annotation.ts:2:25 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ diff --git a/crates/rome_js_parser/test_data/inline/err/type_parameter_modifier.rast b/crates/rome_js_parser/test_data/inline/err/type_parameter_modifier.rast index 8e75faf4e72..c8b5213cdaa 100644 --- a/crates/rome_js_parser/test_data/inline/err/type_parameter_modifier.rast +++ b/crates/rome_js_parser/test_data/inline/err/type_parameter_modifier.rast @@ -536,6 +536,7 @@ JsModule { semicolon_token: missing (optional), }, JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@343..350 "class" [Newline("\n")] [Whitespace(" ")], id: JsIdentifierBinding { @@ -600,6 +601,7 @@ JsModule { r_curly_token: R_CURLY@374..375 "}" [] [], }, JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@375..382 "class" [Newline("\n")] [Whitespace(" ")], id: JsIdentifierBinding { @@ -2299,15 +2301,16 @@ JsModule { 3: R_CURLY@342..343 "}" [] [] 1: (empty) 12: JS_CLASS_DECLARATION@343..375 - 0: (empty) - 1: CLASS_KW@343..350 "class" [Newline("\n")] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@350..354 + 0: JS_DECORATOR_LIST@343..343 + 1: (empty) + 2: CLASS_KW@343..350 "class" [Newline("\n")] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@350..354 0: IDENT@350..354 "Foo" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@354..356 "{" [] [Whitespace(" ")] - 7: JS_CLASS_MEMBER_LIST@356..374 + 6: (empty) + 7: L_CURLY@354..356 "{" [] [Whitespace(" ")] + 8: JS_CLASS_MEMBER_LIST@356..374 0: JS_BOGUS_MEMBER@356..374 0: JS_METHOD_MODIFIER_LIST@356..356 1: JS_LITERAL_MEMBER_NAME@356..359 @@ -2336,17 +2339,18 @@ JsModule { 1: JS_DIRECTIVE_LIST@372..372 2: JS_STATEMENT_LIST@372..372 3: R_CURLY@372..374 "}" [] [Whitespace(" ")] - 8: R_CURLY@374..375 "}" [] [] + 9: R_CURLY@374..375 "}" [] [] 13: JS_CLASS_DECLARATION@375..408 - 0: (empty) - 1: CLASS_KW@375..382 "class" [Newline("\n")] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@382..386 + 0: JS_DECORATOR_LIST@375..375 + 1: (empty) + 2: CLASS_KW@375..382 "class" [Newline("\n")] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@382..386 0: IDENT@382..386 "Foo" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@386..388 "{" [] [Whitespace(" ")] - 7: JS_CLASS_MEMBER_LIST@388..407 + 6: (empty) + 7: L_CURLY@386..388 "{" [] [Whitespace(" ")] + 8: JS_CLASS_MEMBER_LIST@388..407 0: JS_BOGUS_MEMBER@388..407 0: JS_METHOD_MODIFIER_LIST@388..388 1: JS_LITERAL_MEMBER_NAME@388..391 @@ -2375,7 +2379,7 @@ JsModule { 1: JS_DIRECTIVE_LIST@405..405 2: JS_STATEMENT_LIST@405..405 3: R_CURLY@405..407 "}" [] [Whitespace(" ")] - 8: R_CURLY@407..408 "}" [] [] + 9: R_CURLY@407..408 "}" [] [] 14: JS_EXPRESSION_STATEMENT@408..437 0: JS_ASSIGNMENT_EXPRESSION@408..436 0: JS_IDENTIFIER_ASSIGNMENT@408..413 diff --git a/crates/rome_js_parser/test_data/inline/err/typescript_abstract_class_member_should_not_have_body.rast b/crates/rome_js_parser/test_data/inline/err/typescript_abstract_class_member_should_not_have_body.rast index c8253b98bfa..b0158bef25d 100644 --- a/crates/rome_js_parser/test_data/inline/err/typescript_abstract_class_member_should_not_have_body.rast +++ b/crates/rome_js_parser/test_data/inline/err/typescript_abstract_class_member_should_not_have_body.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: ABSTRACT_KW@0..9 "abstract" [] [Whitespace(" ")], class_token: CLASS_KW@9..15 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -153,15 +154,16 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..197 0: JS_CLASS_DECLARATION@0..197 - 0: ABSTRACT_KW@0..9 "abstract" [] [Whitespace(" ")] - 1: CLASS_KW@9..15 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@15..31 + 0: JS_DECORATOR_LIST@0..0 + 1: ABSTRACT_KW@0..9 "abstract" [] [Whitespace(" ")] + 2: CLASS_KW@9..15 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@15..31 0: IDENT@15..31 "AbstractMembers" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@31..32 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@32..195 + 6: (empty) + 7: L_CURLY@31..32 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@32..195 0: JS_BOGUS_MEMBER@32..63 0: JS_BOGUS@32..46 0: TS_ABSTRACT_MODIFIER@32..46 @@ -246,7 +248,7 @@ JsModule { 1: JS_DIRECTIVE_LIST@194..194 2: JS_STATEMENT_LIST@194..194 3: R_CURLY@194..195 "}" [] [] - 8: R_CURLY@195..197 "}" [Newline("\n")] [] + 9: R_CURLY@195..197 "}" [Newline("\n")] [] 3: EOF@197..198 "" [Newline("\n")] [] -- typescript_abstract_class_member_should_not_have_body.ts:2:5 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ diff --git a/crates/rome_js_parser/test_data/inline/err/typescript_abstract_classes_abstract_accessor_precedence.rast b/crates/rome_js_parser/test_data/inline/err/typescript_abstract_classes_abstract_accessor_precedence.rast index c8b96d65b60..54bcb5e27e8 100644 --- a/crates/rome_js_parser/test_data/inline/err/typescript_abstract_classes_abstract_accessor_precedence.rast +++ b/crates/rome_js_parser/test_data/inline/err/typescript_abstract_classes_abstract_accessor_precedence.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: ABSTRACT_KW@0..9 "abstract" [] [Whitespace(" ")], class_token: CLASS_KW@9..15 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -47,15 +48,16 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..51 0: JS_CLASS_DECLARATION@0..51 - 0: ABSTRACT_KW@0..9 "abstract" [] [Whitespace(" ")] - 1: CLASS_KW@9..15 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@15..17 + 0: JS_DECORATOR_LIST@0..0 + 1: ABSTRACT_KW@0..9 "abstract" [] [Whitespace(" ")] + 2: CLASS_KW@9..15 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@15..17 0: IDENT@15..17 "A" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@17..19 "{" [] [Whitespace(" ")] - 7: JS_CLASS_MEMBER_LIST@19..50 + 6: (empty) + 7: L_CURLY@17..19 "{" [] [Whitespace(" ")] + 8: JS_CLASS_MEMBER_LIST@19..50 0: JS_BOGUS_MEMBER@19..50 0: TS_PROPERTY_SIGNATURE_MODIFIER_LIST@19..37 0: JS_ACCESSOR_MODIFIER@19..28 @@ -69,7 +71,7 @@ JsModule { 1: TS_NUMBER_TYPE@42..48 0: NUMBER_KW@42..48 "number" [] [] 3: SEMICOLON@48..50 ";" [] [Whitespace(" ")] - 8: R_CURLY@50..51 "}" [] [] + 9: R_CURLY@50..51 "}" [] [] 3: EOF@51..52 "" [Newline("\n")] [] -- typescript_abstract_classes_abstract_accessor_precedence.ts:1:29 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ diff --git a/crates/rome_js_parser/test_data/inline/err/typescript_abstract_classes_incomplete.rast b/crates/rome_js_parser/test_data/inline/err/typescript_abstract_classes_incomplete.rast index a8c7ad93f80..5db3519fbde 100644 --- a/crates/rome_js_parser/test_data/inline/err/typescript_abstract_classes_incomplete.rast +++ b/crates/rome_js_parser/test_data/inline/err/typescript_abstract_classes_incomplete.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: ABSTRACT_KW@0..9 "abstract" [] [Whitespace(" ")], class_token: CLASS_KW@9..15 "class" [] [Whitespace(" ")], id: missing (required), @@ -25,15 +26,16 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..18 0: JS_CLASS_DECLARATION@0..17 - 0: ABSTRACT_KW@0..9 "abstract" [] [Whitespace(" ")] - 1: CLASS_KW@9..15 "class" [] [Whitespace(" ")] - 2: (empty) + 0: JS_DECORATOR_LIST@0..0 + 1: ABSTRACT_KW@0..9 "abstract" [] [Whitespace(" ")] + 2: CLASS_KW@9..15 "class" [] [Whitespace(" ")] 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@15..16 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@16..16 - 8: R_CURLY@16..17 "}" [] [] + 6: (empty) + 7: L_CURLY@15..16 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@16..16 + 9: R_CURLY@16..17 "}" [] [] 1: JS_EMPTY_STATEMENT@17..18 0: SEMICOLON@17..18 ";" [] [] 3: EOF@18..19 "" [Newline("\n")] [] diff --git a/crates/rome_js_parser/test_data/inline/err/typescript_abstract_classes_invalid_abstract_async_member.rast b/crates/rome_js_parser/test_data/inline/err/typescript_abstract_classes_invalid_abstract_async_member.rast index 82cad5a761f..1b787b8c644 100644 --- a/crates/rome_js_parser/test_data/inline/err/typescript_abstract_classes_invalid_abstract_async_member.rast +++ b/crates/rome_js_parser/test_data/inline/err/typescript_abstract_classes_invalid_abstract_async_member.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: ABSTRACT_KW@0..9 "abstract" [] [Whitespace(" ")], class_token: CLASS_KW@9..15 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -42,15 +43,16 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..40 0: JS_CLASS_DECLARATION@0..40 - 0: ABSTRACT_KW@0..9 "abstract" [] [Whitespace(" ")] - 1: CLASS_KW@9..15 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@15..17 + 0: JS_DECORATOR_LIST@0..0 + 1: ABSTRACT_KW@0..9 "abstract" [] [Whitespace(" ")] + 2: CLASS_KW@9..15 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@15..17 0: IDENT@15..17 "B" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@17..19 "{" [] [Whitespace(" ")] - 7: JS_CLASS_MEMBER_LIST@19..39 + 6: (empty) + 7: L_CURLY@17..19 "{" [] [Whitespace(" ")] + 8: JS_CLASS_MEMBER_LIST@19..39 0: JS_BOGUS_MEMBER@19..39 0: TS_ABSTRACT_MODIFIER@19..28 0: ABSTRACT_KW@19..28 "abstract" [] [Whitespace(" ")] @@ -62,7 +64,7 @@ JsModule { 1: JS_PARAMETER_LIST@36..36 2: R_PAREN@36..37 ")" [] [] 4: SEMICOLON@37..39 ";" [] [Whitespace(" ")] - 8: R_CURLY@39..40 "}" [] [] + 9: R_CURLY@39..40 "}" [] [] 3: EOF@40..41 "" [Newline("\n")] [] -- typescript_abstract_classes_invalid_abstract_async_member.ts:1:20 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━ diff --git a/crates/rome_js_parser/test_data/inline/err/typescript_abstract_classes_invalid_abstract_constructor.rast b/crates/rome_js_parser/test_data/inline/err/typescript_abstract_classes_invalid_abstract_constructor.rast index bdb2532afb8..7836c04d643 100644 --- a/crates/rome_js_parser/test_data/inline/err/typescript_abstract_classes_invalid_abstract_constructor.rast +++ b/crates/rome_js_parser/test_data/inline/err/typescript_abstract_classes_invalid_abstract_constructor.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: ABSTRACT_KW@0..9 "abstract" [] [Whitespace(" ")], class_token: CLASS_KW@9..15 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -48,15 +49,16 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..44 0: JS_CLASS_DECLARATION@0..43 - 0: ABSTRACT_KW@0..9 "abstract" [] [Whitespace(" ")] - 1: CLASS_KW@9..15 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@15..17 + 0: JS_DECORATOR_LIST@0..0 + 1: ABSTRACT_KW@0..9 "abstract" [] [Whitespace(" ")] + 2: CLASS_KW@9..15 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@15..17 0: IDENT@15..17 "A" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@17..19 "{" [] [Whitespace(" ")] - 7: JS_CLASS_MEMBER_LIST@19..42 + 6: (empty) + 7: L_CURLY@17..19 "{" [] [Whitespace(" ")] + 8: JS_CLASS_MEMBER_LIST@19..42 0: JS_BOGUS_MEMBER@19..42 0: JS_BOGUS@19..28 0: TS_ABSTRACT_MODIFIER@19..28 @@ -68,7 +70,7 @@ JsModule { 1: JS_CONSTRUCTOR_PARAMETER_LIST@40..40 2: R_PAREN@40..41 ")" [] [] 3: SEMICOLON@41..42 ";" [] [] - 8: R_CURLY@42..43 "}" [] [] + 9: R_CURLY@42..43 "}" [] [] 1: JS_EMPTY_STATEMENT@43..44 0: SEMICOLON@43..44 ";" [] [] 3: EOF@44..45 "" [Newline("\n")] [] diff --git a/crates/rome_js_parser/test_data/inline/err/typescript_abstract_classes_invalid_abstract_private_member.rast b/crates/rome_js_parser/test_data/inline/err/typescript_abstract_classes_invalid_abstract_private_member.rast index 89e93deed5e..ab4fef03342 100644 --- a/crates/rome_js_parser/test_data/inline/err/typescript_abstract_classes_invalid_abstract_private_member.rast +++ b/crates/rome_js_parser/test_data/inline/err/typescript_abstract_classes_invalid_abstract_private_member.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: ABSTRACT_KW@0..9 "abstract" [] [Whitespace(" ")], class_token: CLASS_KW@9..15 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -47,15 +48,16 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..39 0: JS_CLASS_DECLARATION@0..38 - 0: ABSTRACT_KW@0..9 "abstract" [] [Whitespace(" ")] - 1: CLASS_KW@9..15 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@15..17 + 0: JS_DECORATOR_LIST@0..0 + 1: ABSTRACT_KW@0..9 "abstract" [] [Whitespace(" ")] + 2: CLASS_KW@9..15 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@15..17 0: IDENT@15..17 "A" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@17..19 "{" [] [Whitespace(" ")] - 7: JS_CLASS_MEMBER_LIST@19..37 + 6: (empty) + 7: L_CURLY@17..19 "{" [] [Whitespace(" ")] + 8: JS_CLASS_MEMBER_LIST@19..37 0: JS_BOGUS_MEMBER@19..37 0: TS_METHOD_SIGNATURE_MODIFIER_LIST@19..28 0: TS_ABSTRACT_MODIFIER@19..28 @@ -68,7 +70,7 @@ JsModule { 1: JS_PARAMETER_LIST@34..34 2: R_PAREN@34..35 ")" [] [] 3: SEMICOLON@35..37 ";" [] [Whitespace(" ")] - 8: R_CURLY@37..38 "}" [] [] + 9: R_CURLY@37..38 "}" [] [] 1: JS_EMPTY_STATEMENT@38..39 0: SEMICOLON@38..39 ";" [] [] 3: EOF@39..40 "" [Newline("\n")] [] diff --git a/crates/rome_js_parser/test_data/inline/err/typescript_abstract_classes_invalid_static_abstract_member.rast b/crates/rome_js_parser/test_data/inline/err/typescript_abstract_classes_invalid_static_abstract_member.rast index c782efb737d..361ee280259 100644 --- a/crates/rome_js_parser/test_data/inline/err/typescript_abstract_classes_invalid_static_abstract_member.rast +++ b/crates/rome_js_parser/test_data/inline/err/typescript_abstract_classes_invalid_static_abstract_member.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: ABSTRACT_KW@0..9 "abstract" [] [Whitespace(" ")], class_token: CLASS_KW@9..15 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -38,6 +39,7 @@ JsModule { r_curly_token: R_CURLY@42..43 "}" [] [], }, JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: ABSTRACT_KW@43..53 "abstract" [Newline("\n")] [Whitespace(" ")], class_token: CLASS_KW@53..59 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -81,15 +83,16 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..87 0: JS_CLASS_DECLARATION@0..43 - 0: ABSTRACT_KW@0..9 "abstract" [] [Whitespace(" ")] - 1: CLASS_KW@9..15 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@15..17 + 0: JS_DECORATOR_LIST@0..0 + 1: ABSTRACT_KW@0..9 "abstract" [] [Whitespace(" ")] + 2: CLASS_KW@9..15 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@15..17 0: IDENT@15..17 "A" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@17..19 "{" [] [Whitespace(" ")] - 7: JS_CLASS_MEMBER_LIST@19..42 + 6: (empty) + 7: L_CURLY@17..19 "{" [] [Whitespace(" ")] + 8: JS_CLASS_MEMBER_LIST@19..42 0: JS_BOGUS_MEMBER@19..42 0: TS_METHOD_SIGNATURE_MODIFIER_LIST@19..35 0: TS_ABSTRACT_MODIFIER@19..28 @@ -103,17 +106,18 @@ JsModule { 1: JS_PARAMETER_LIST@39..39 2: R_PAREN@39..40 ")" [] [] 3: SEMICOLON@40..42 ";" [] [Whitespace(" ")] - 8: R_CURLY@42..43 "}" [] [] + 9: R_CURLY@42..43 "}" [] [] 1: JS_CLASS_DECLARATION@43..87 - 0: ABSTRACT_KW@43..53 "abstract" [Newline("\n")] [Whitespace(" ")] - 1: CLASS_KW@53..59 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@59..61 + 0: JS_DECORATOR_LIST@43..43 + 1: ABSTRACT_KW@43..53 "abstract" [Newline("\n")] [Whitespace(" ")] + 2: CLASS_KW@53..59 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@59..61 0: IDENT@59..61 "B" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@61..63 "{" [] [Whitespace(" ")] - 7: JS_CLASS_MEMBER_LIST@63..86 + 6: (empty) + 7: L_CURLY@61..63 "{" [] [Whitespace(" ")] + 8: JS_CLASS_MEMBER_LIST@63..86 0: JS_BOGUS_MEMBER@63..86 0: TS_METHOD_SIGNATURE_MODIFIER_LIST@63..79 0: JS_STATIC_MODIFIER@63..70 @@ -127,7 +131,7 @@ JsModule { 1: JS_PARAMETER_LIST@83..83 2: R_PAREN@83..84 ")" [] [] 3: SEMICOLON@84..86 ";" [] [Whitespace(" ")] - 8: R_CURLY@86..87 "}" [] [] + 9: R_CURLY@86..87 "}" [] [] 3: EOF@87..88 "" [Newline("\n")] [] -- typescript_abstract_classes_invalid_static_abstract_member.ts:1:20 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━ diff --git a/crates/rome_js_parser/test_data/inline/err/typescript_classes_invalid_accessibility_modifier_private_member.rast b/crates/rome_js_parser/test_data/inline/err/typescript_classes_invalid_accessibility_modifier_private_member.rast index 0a2c6343f9d..deab98e1c4d 100644 --- a/crates/rome_js_parser/test_data/inline/err/typescript_classes_invalid_accessibility_modifier_private_member.rast +++ b/crates/rome_js_parser/test_data/inline/err/typescript_classes_invalid_accessibility_modifier_private_member.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@0..6 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -70,15 +71,16 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..58 0: JS_CLASS_DECLARATION@0..57 - 0: (empty) - 1: CLASS_KW@0..6 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@6..8 + 0: JS_DECORATOR_LIST@0..0 + 1: (empty) + 2: CLASS_KW@0..6 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@6..8 0: IDENT@6..8 "A" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@8..10 "{" [] [Whitespace(" ")] - 7: JS_CLASS_MEMBER_LIST@10..56 + 6: (empty) + 7: L_CURLY@8..10 "{" [] [Whitespace(" ")] + 8: JS_CLASS_MEMBER_LIST@10..56 0: JS_BOGUS_MEMBER@10..25 0: JS_PROPERTY_MODIFIER_LIST@10..18 0: TS_ACCESSIBILITY_MODIFIER@10..18 @@ -103,7 +105,7 @@ JsModule { 0: HASH@50..51 "#" [] [] 1: IDENT@51..54 "baz" [] [] 2: SEMICOLON@54..56 ";" [] [Whitespace(" ")] - 8: R_CURLY@56..57 "}" [] [] + 9: R_CURLY@56..57 "}" [] [] 1: JS_EMPTY_STATEMENT@57..58 0: SEMICOLON@57..58 ";" [] [] 3: EOF@58..59 "" [Newline("\n")] [] diff --git a/crates/rome_js_parser/test_data/inline/err/typescript_members_with_body_in_ambient_context_should_err.rast b/crates/rome_js_parser/test_data/inline/err/typescript_members_with_body_in_ambient_context_should_err.rast index 37ef77b5a2a..027371c93de 100644 --- a/crates/rome_js_parser/test_data/inline/err/typescript_members_with_body_in_ambient_context_should_err.rast +++ b/crates/rome_js_parser/test_data/inline/err/typescript_members_with_body_in_ambient_context_should_err.rast @@ -5,6 +5,7 @@ JsModule { TsDeclareStatement { declare_token: DECLARE_KW@0..8 "declare" [] [Whitespace(" ")], declaration: JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@8..14 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -124,6 +125,7 @@ JsModule { l_curly_token: L_CURLY@135..136 "{" [] [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@136..148 "class" [Newline("\n"), Whitespace(" ")] [Whitespace(" ")], id: JsIdentifierBinding { @@ -247,15 +249,16 @@ JsModule { 0: TS_DECLARE_STATEMENT@0..114 0: DECLARE_KW@0..8 "declare" [] [Whitespace(" ")] 1: JS_CLASS_DECLARATION@8..114 - 0: (empty) - 1: CLASS_KW@8..14 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@14..19 + 0: JS_DECORATOR_LIST@8..8 + 1: (empty) + 2: CLASS_KW@8..14 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@14..19 0: IDENT@14..19 "Test" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@19..20 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@20..112 + 6: (empty) + 7: L_CURLY@19..20 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@20..112 0: JS_BOGUS_MEMBER@20..41 0: JS_CONSTRUCTOR_MODIFIER_LIST@20..20 1: JS_LITERAL_MEMBER_NAME@20..36 @@ -321,7 +324,7 @@ JsModule { 1: JS_DIRECTIVE_LIST@111..111 2: JS_STATEMENT_LIST@111..111 3: R_CURLY@111..112 "}" [] [] - 8: R_CURLY@112..114 "}" [Newline("\n")] [] + 9: R_CURLY@112..114 "}" [Newline("\n")] [] 1: TS_DECLARE_STATEMENT@114..275 0: DECLARE_KW@114..123 "declare" [Newline("\n")] [Whitespace(" ")] 1: TS_MODULE_DECLARATION@123..275 @@ -332,15 +335,16 @@ JsModule { 0: L_CURLY@135..136 "{" [] [] 1: JS_MODULE_ITEM_LIST@136..273 0: JS_CLASS_DECLARATION@136..273 - 0: (empty) - 1: CLASS_KW@136..148 "class" [Newline("\n"), Whitespace(" ")] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@148..153 + 0: JS_DECORATOR_LIST@136..136 + 1: (empty) + 2: CLASS_KW@136..148 "class" [Newline("\n"), Whitespace(" ")] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@148..153 0: IDENT@148..153 "Test" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@153..154 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@154..266 + 6: (empty) + 7: L_CURLY@153..154 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@154..266 0: JS_BOGUS_MEMBER@154..180 0: JS_CONSTRUCTOR_MODIFIER_LIST@154..154 1: JS_LITERAL_MEMBER_NAME@154..175 @@ -406,7 +410,7 @@ JsModule { 1: JS_DIRECTIVE_LIST@265..265 2: JS_STATEMENT_LIST@265..265 3: R_CURLY@265..266 "}" [] [] - 8: R_CURLY@266..273 "}" [Newline("\n"), Whitespace(" ")] [] + 9: R_CURLY@266..273 "}" [Newline("\n"), Whitespace(" ")] [] 2: R_CURLY@273..275 "}" [Newline("\n")] [] 3: EOF@275..276 "" [Newline("\n")] [] -- diff --git a/crates/rome_js_parser/test_data/inline/ok/arrow_in_constructor.rast b/crates/rome_js_parser/test_data/inline/ok/arrow_in_constructor.rast index d90fc16a4aa..a22f869cd5c 100644 --- a/crates/rome_js_parser/test_data/inline/ok/arrow_in_constructor.rast +++ b/crates/rome_js_parser/test_data/inline/ok/arrow_in_constructor.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@0..6 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -105,15 +106,16 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..74 0: JS_CLASS_DECLARATION@0..74 - 0: (empty) - 1: CLASS_KW@0..6 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@6..8 + 0: JS_DECORATOR_LIST@0..0 + 1: (empty) + 2: CLASS_KW@0..6 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@6..8 0: IDENT@6..8 "A" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@8..9 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@9..72 + 6: (empty) + 7: L_CURLY@8..9 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@9..72 0: JS_CONSTRUCTOR_CLASS_MEMBER@9..72 0: JS_CONSTRUCTOR_MODIFIER_LIST@9..9 1: JS_LITERAL_MEMBER_NAME@9..23 @@ -174,5 +176,5 @@ JsModule { 2: R_PAREN@67..68 ")" [] [] 1: SEMICOLON@68..69 ";" [] [] 3: R_CURLY@69..72 "}" [Newline("\n"), Whitespace(" ")] [] - 8: R_CURLY@72..74 "}" [Newline("\n")] [] + 9: R_CURLY@72..74 "}" [Newline("\n")] [] 3: EOF@74..75 "" [Newline("\n")] [] diff --git a/crates/rome_js_parser/test_data/inline/ok/async_method.rast b/crates/rome_js_parser/test_data/inline/ok/async_method.rast index c15578c6fb2..12099852c7f 100644 --- a/crates/rome_js_parser/test_data/inline/ok/async_method.rast +++ b/crates/rome_js_parser/test_data/inline/ok/async_method.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@0..6 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -69,15 +70,16 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..46 0: JS_CLASS_DECLARATION@0..46 - 0: (empty) - 1: CLASS_KW@0..6 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@6..10 + 0: JS_DECORATOR_LIST@0..0 + 1: (empty) + 2: CLASS_KW@0..6 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@6..10 0: IDENT@6..10 "foo" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@10..11 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@11..44 + 6: (empty) + 7: L_CURLY@10..11 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@11..44 0: JS_METHOD_CLASS_MEMBER@11..27 0: JS_METHOD_MODIFIER_LIST@11..11 1: ASYNC_KW@11..19 "async" [Newline("\n"), Whitespace(" ")] [Whitespace(" ")] @@ -114,5 +116,5 @@ JsModule { 1: JS_DIRECTIVE_LIST@43..43 2: JS_STATEMENT_LIST@43..43 3: R_CURLY@43..44 "}" [] [] - 8: R_CURLY@44..46 "}" [Newline("\n")] [] + 9: R_CURLY@44..46 "}" [Newline("\n")] [] 3: EOF@46..47 "" [Newline("\n")] [] diff --git a/crates/rome_js_parser/test_data/inline/ok/binary_expressions.rast b/crates/rome_js_parser/test_data/inline/ok/binary_expressions.rast index de45ce1f1c1..f327d0310cb 100644 --- a/crates/rome_js_parser/test_data/inline/ok/binary_expressions.rast +++ b/crates/rome_js_parser/test_data/inline/ok/binary_expressions.rast @@ -226,6 +226,7 @@ JsModule { semicolon_token: missing (optional), }, JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@139..146 "class" [Newline("\n")] [Whitespace(" ")], id: JsIdentifierBinding { @@ -448,15 +449,16 @@ JsModule { 0: JS_NUMBER_LITERAL@138..139 "6" [] [] 1: (empty) 11: JS_CLASS_DECLARATION@139..192 - 0: (empty) - 1: CLASS_KW@139..146 "class" [Newline("\n")] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@146..151 + 0: JS_DECORATOR_LIST@139..139 + 1: (empty) + 2: CLASS_KW@139..146 "class" [Newline("\n")] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@146..151 0: IDENT@146..151 "Test" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@151..153 "{" [] [Whitespace(" ")] - 7: JS_CLASS_MEMBER_LIST@153..191 + 6: (empty) + 7: L_CURLY@151..153 "{" [] [Whitespace(" ")] + 8: JS_CLASS_MEMBER_LIST@153..191 0: JS_PROPERTY_CLASS_MEMBER@153..160 0: JS_PROPERTY_MODIFIER_LIST@153..153 1: JS_PRIVATE_CLASS_MEMBER_NAME@153..158 @@ -498,5 +500,5 @@ JsModule { 2: R_CURLY@187..189 "}" [] [Whitespace(" ")] 1: (empty) 3: R_CURLY@189..191 "}" [] [Whitespace(" ")] - 8: R_CURLY@191..192 "}" [] [] + 9: R_CURLY@191..192 "}" [] [] 3: EOF@192..193 "" [Newline("\n")] [] diff --git a/crates/rome_js_parser/test_data/inline/ok/class_await_property_initializer.rast b/crates/rome_js_parser/test_data/inline/ok/class_await_property_initializer.rast index 47f1a4d4d56..1e302b8a66c 100644 --- a/crates/rome_js_parser/test_data/inline/ok/class_await_property_initializer.rast +++ b/crates/rome_js_parser/test_data/inline/ok/class_await_property_initializer.rast @@ -21,6 +21,7 @@ JsScript { directives: JsDirectiveList [], statements: JsStatementList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@34..43 "class" [Newline("\n"), Whitespace(" ")] [Whitespace(" ")], id: JsIdentifierBinding { @@ -79,15 +80,16 @@ JsScript { 1: JS_DIRECTIVE_LIST@34..34 2: JS_STATEMENT_LIST@34..68 0: JS_CLASS_DECLARATION@34..68 - 0: (empty) - 1: CLASS_KW@34..43 "class" [Newline("\n"), Whitespace(" ")] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@43..45 + 0: JS_DECORATOR_LIST@34..34 + 1: (empty) + 2: CLASS_KW@34..43 "class" [Newline("\n"), Whitespace(" ")] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@43..45 0: IDENT@43..45 "A" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@45..46 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@46..64 + 6: (empty) + 7: L_CURLY@45..46 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@46..64 0: JS_PROPERTY_CLASS_MEMBER@46..64 0: JS_PROPERTY_MODIFIER_LIST@46..46 1: JS_LITERAL_MEMBER_NAME@46..56 @@ -99,6 +101,6 @@ JsScript { 0: JS_REFERENCE_IDENTIFIER@58..63 0: IDENT@58..63 "await" [] [] 4: SEMICOLON@63..64 ";" [] [] - 8: R_CURLY@64..68 "}" [Newline("\n"), Whitespace(" ")] [] + 9: R_CURLY@64..68 "}" [Newline("\n"), Whitespace(" ")] [] 3: R_CURLY@68..70 "}" [Newline("\n")] [] 3: EOF@70..71 "" [Newline("\n")] [] diff --git a/crates/rome_js_parser/test_data/inline/ok/class_constructor_parameter_modifiers.rast b/crates/rome_js_parser/test_data/inline/ok/class_constructor_parameter_modifiers.rast index d81eb8a8d00..860d9136125 100644 --- a/crates/rome_js_parser/test_data/inline/ok/class_constructor_parameter_modifiers.rast +++ b/crates/rome_js_parser/test_data/inline/ok/class_constructor_parameter_modifiers.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@0..6 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -51,6 +52,7 @@ JsModule { r_curly_token: R_CURLY@43..44 "}" [] [], }, JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@44..51 "class" [Newline("\n")] [Whitespace(" ")], id: JsIdentifierBinding { @@ -246,15 +248,16 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..258 0: JS_CLASS_DECLARATION@0..44 - 0: (empty) - 1: CLASS_KW@0..6 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@6..11 + 0: JS_DECORATOR_LIST@0..0 + 1: (empty) + 2: CLASS_KW@0..6 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@6..11 0: IDENT@6..11 "Base" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@11..13 "{" [] [Whitespace(" ")] - 7: JS_CLASS_MEMBER_LIST@13..43 + 6: (empty) + 7: L_CURLY@11..13 "{" [] [Whitespace(" ")] + 8: JS_CLASS_MEMBER_LIST@13..43 0: JS_PROPERTY_CLASS_MEMBER@13..28 0: JS_PROPERTY_MODIFIER_LIST@13..13 1: JS_LITERAL_MEMBER_NAME@13..17 @@ -279,22 +282,23 @@ JsModule { 0: STRING_KW@36..43 "string" [] [Whitespace(" ")] 3: (empty) 4: (empty) - 8: R_CURLY@43..44 "}" [] [] + 9: R_CURLY@43..44 "}" [] [] 1: JS_CLASS_DECLARATION@44..258 - 0: (empty) - 1: CLASS_KW@44..51 "class" [Newline("\n")] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@51..55 + 0: JS_DECORATOR_LIST@44..44 + 1: (empty) + 2: CLASS_KW@44..51 "class" [Newline("\n")] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@51..55 0: IDENT@51..55 "Sub" [] [Whitespace(" ")] - 3: (empty) - 4: JS_EXTENDS_CLAUSE@55..68 + 4: (empty) + 5: JS_EXTENDS_CLAUSE@55..68 0: EXTENDS_KW@55..63 "extends" [] [Whitespace(" ")] 1: JS_IDENTIFIER_EXPRESSION@63..68 0: JS_REFERENCE_IDENTIFIER@63..68 0: IDENT@63..68 "Base" [] [Whitespace(" ")] 2: (empty) - 5: (empty) - 6: L_CURLY@68..69 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@69..256 + 6: (empty) + 7: L_CURLY@68..69 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@69..256 0: JS_CONSTRUCTOR_CLASS_MEMBER@69..256 0: JS_CONSTRUCTOR_MODIFIER_LIST@69..69 1: JS_LITERAL_MEMBER_NAME@69..82 @@ -406,5 +410,5 @@ JsModule { 2: R_PAREN@251..252 ")" [] [] 1: SEMICOLON@252..253 ";" [] [] 3: R_CURLY@253..256 "}" [Newline("\n"), Whitespace(" ")] [] - 8: R_CURLY@256..258 "}" [Newline("\n")] [] + 9: R_CURLY@256..258 "}" [Newline("\n")] [] 3: EOF@258..259 "" [Newline("\n")] [] diff --git a/crates/rome_js_parser/test_data/inline/ok/class_declaration.rast b/crates/rome_js_parser/test_data/inline/ok/class_declaration.rast index 600f9ea2dc3..712c356aba3 100644 --- a/crates/rome_js_parser/test_data/inline/ok/class_declaration.rast +++ b/crates/rome_js_parser/test_data/inline/ok/class_declaration.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@0..6 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -16,6 +17,7 @@ JsModule { r_curly_token: R_CURLY@11..12 "}" [] [], }, JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@12..19 "class" [Newline("\n")] [Whitespace(" ")], id: JsIdentifierBinding { @@ -37,6 +39,7 @@ JsModule { r_curly_token: R_CURLY@36..37 "}" [] [], }, JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@37..44 "class" [Newline("\n")] [Whitespace(" ")], id: JsIdentifierBinding { @@ -72,39 +75,42 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..66 0: JS_CLASS_DECLARATION@0..12 - 0: (empty) - 1: CLASS_KW@0..6 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@6..10 + 0: JS_DECORATOR_LIST@0..0 + 1: (empty) + 2: CLASS_KW@0..6 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@6..10 0: IDENT@6..10 "foo" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@10..11 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@11..11 - 8: R_CURLY@11..12 "}" [] [] + 6: (empty) + 7: L_CURLY@10..11 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@11..11 + 9: R_CURLY@11..12 "}" [] [] 1: JS_CLASS_DECLARATION@12..37 - 0: (empty) - 1: CLASS_KW@12..19 "class" [Newline("\n")] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@19..23 + 0: JS_DECORATOR_LIST@12..12 + 1: (empty) + 2: CLASS_KW@12..19 "class" [Newline("\n")] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@19..23 0: IDENT@19..23 "foo" [] [Whitespace(" ")] - 3: (empty) - 4: JS_EXTENDS_CLAUSE@23..35 + 4: (empty) + 5: JS_EXTENDS_CLAUSE@23..35 0: EXTENDS_KW@23..31 "extends" [] [Whitespace(" ")] 1: JS_IDENTIFIER_EXPRESSION@31..35 0: JS_REFERENCE_IDENTIFIER@31..35 0: IDENT@31..35 "bar" [] [Whitespace(" ")] 2: (empty) - 5: (empty) - 6: L_CURLY@35..36 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@36..36 - 8: R_CURLY@36..37 "}" [] [] + 6: (empty) + 7: L_CURLY@35..36 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@36..36 + 9: R_CURLY@36..37 "}" [] [] 2: JS_CLASS_DECLARATION@37..66 - 0: (empty) - 1: CLASS_KW@37..44 "class" [Newline("\n")] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@44..48 + 0: JS_DECORATOR_LIST@37..37 + 1: (empty) + 2: CLASS_KW@37..44 "class" [Newline("\n")] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@44..48 0: IDENT@44..48 "foo" [] [Whitespace(" ")] - 3: (empty) - 4: JS_EXTENDS_CLAUSE@48..64 + 4: (empty) + 5: JS_EXTENDS_CLAUSE@48..64 0: EXTENDS_KW@48..56 "extends" [] [Whitespace(" ")] 1: JS_STATIC_MEMBER_EXPRESSION@56..64 0: JS_IDENTIFIER_EXPRESSION@56..59 @@ -114,8 +120,8 @@ JsModule { 2: JS_NAME@60..64 0: IDENT@60..64 "bar" [] [Whitespace(" ")] 2: (empty) - 5: (empty) - 6: L_CURLY@64..65 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@65..65 - 8: R_CURLY@65..66 "}" [] [] + 6: (empty) + 7: L_CURLY@64..65 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@65..65 + 9: R_CURLY@65..66 "}" [] [] 3: EOF@66..67 "" [Newline("\n")] [] diff --git a/crates/rome_js_parser/test_data/inline/ok/class_declare.rast b/crates/rome_js_parser/test_data/inline/ok/class_declare.rast index 2118c5625b0..e2459389aaf 100644 --- a/crates/rome_js_parser/test_data/inline/ok/class_declare.rast +++ b/crates/rome_js_parser/test_data/inline/ok/class_declare.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@0..6 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -39,6 +40,7 @@ JsModule { r_curly_token: R_CURLY@23..24 "}" [] [], }, JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@24..31 "class" [Newline("\n")] [Whitespace(" ")], id: JsIdentifierBinding { @@ -77,15 +79,16 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..50 0: JS_CLASS_DECLARATION@0..24 - 0: (empty) - 1: CLASS_KW@0..6 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@6..8 + 0: JS_DECORATOR_LIST@0..0 + 1: (empty) + 2: CLASS_KW@0..6 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@6..8 0: IDENT@6..8 "B" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@8..10 "{" [] [Whitespace(" ")] - 7: JS_CLASS_MEMBER_LIST@10..23 + 6: (empty) + 7: L_CURLY@8..10 "{" [] [Whitespace(" ")] + 8: JS_CLASS_MEMBER_LIST@10..23 0: JS_METHOD_CLASS_MEMBER@10..23 0: JS_METHOD_MODIFIER_LIST@10..10 1: (empty) @@ -104,17 +107,18 @@ JsModule { 1: JS_DIRECTIVE_LIST@21..21 2: JS_STATEMENT_LIST@21..21 3: R_CURLY@21..23 "}" [] [Whitespace(" ")] - 8: R_CURLY@23..24 "}" [] [] + 9: R_CURLY@23..24 "}" [] [] 1: JS_CLASS_DECLARATION@24..50 - 0: (empty) - 1: CLASS_KW@24..31 "class" [Newline("\n")] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@31..33 + 0: JS_DECORATOR_LIST@24..24 + 1: (empty) + 2: CLASS_KW@24..31 "class" [Newline("\n")] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@31..33 0: IDENT@31..33 "B" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@33..35 "{" [] [Whitespace(" ")] - 7: JS_CLASS_MEMBER_LIST@35..49 + 6: (empty) + 7: L_CURLY@33..35 "{" [] [Whitespace(" ")] + 8: JS_CLASS_MEMBER_LIST@35..49 0: JS_PROPERTY_CLASS_MEMBER@35..49 0: JS_PROPERTY_MODIFIER_LIST@35..35 1: JS_LITERAL_MEMBER_NAME@35..43 @@ -126,5 +130,5 @@ JsModule { 0: JS_REFERENCE_IDENTIFIER@45..49 0: IDENT@45..49 "foo" [] [Whitespace(" ")] 4: (empty) - 8: R_CURLY@49..50 "}" [] [] + 9: R_CURLY@49..50 "}" [] [] 3: EOF@50..51 "" [Newline("\n")] [] diff --git a/crates/rome_js_parser/test_data/inline/ok/class_decorator.js b/crates/rome_js_parser/test_data/inline/ok/class_decorator.js new file mode 100644 index 00000000000..c6e63e1371a --- /dev/null +++ b/crates/rome_js_parser/test_data/inline/ok/class_decorator.js @@ -0,0 +1,2 @@ +@decorator +class Foo { } diff --git a/crates/rome_js_parser/test_data/inline/ok/class_decorator.rast b/crates/rome_js_parser/test_data/inline/ok/class_decorator.rast new file mode 100644 index 00000000000..39d7c02fc51 --- /dev/null +++ b/crates/rome_js_parser/test_data/inline/ok/class_decorator.rast @@ -0,0 +1,53 @@ +JsModule { + interpreter_token: missing (optional), + directives: JsDirectiveList [], + items: JsModuleItemList [ + JsClassDeclaration { + decorators: JsDecoratorList [ + JsDecorator { + at_token: AT@0..1 "@" [] [], + expression: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@1..10 "decorator" [] [], + }, + }, + }, + ], + abstract_token: missing (optional), + class_token: CLASS_KW@10..17 "class" [Newline("\n")] [Whitespace(" ")], + id: JsIdentifierBinding { + name_token: IDENT@17..21 "Foo" [] [Whitespace(" ")], + }, + type_parameters: missing (optional), + extends_clause: missing (optional), + implements_clause: missing (optional), + l_curly_token: L_CURLY@21..23 "{" [] [Whitespace(" ")], + members: JsClassMemberList [], + r_curly_token: R_CURLY@23..24 "}" [] [], + }, + ], + eof_token: EOF@24..25 "" [Newline("\n")] [], +} + +0: JS_MODULE@0..25 + 0: (empty) + 1: JS_DIRECTIVE_LIST@0..0 + 2: JS_MODULE_ITEM_LIST@0..24 + 0: JS_CLASS_DECLARATION@0..24 + 0: JS_DECORATOR_LIST@0..10 + 0: JS_DECORATOR@0..10 + 0: AT@0..1 "@" [] [] + 1: JS_IDENTIFIER_EXPRESSION@1..10 + 0: JS_REFERENCE_IDENTIFIER@1..10 + 0: IDENT@1..10 "decorator" [] [] + 1: (empty) + 2: CLASS_KW@10..17 "class" [Newline("\n")] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@17..21 + 0: IDENT@17..21 "Foo" [] [Whitespace(" ")] + 4: (empty) + 5: (empty) + 6: (empty) + 7: L_CURLY@21..23 "{" [] [Whitespace(" ")] + 8: JS_CLASS_MEMBER_LIST@23..23 + 9: R_CURLY@23..24 "}" [] [] + 3: EOF@24..25 "" [Newline("\n")] [] diff --git a/crates/rome_js_parser/test_data/inline/ok/class_empty_element.rast b/crates/rome_js_parser/test_data/inline/ok/class_empty_element.rast index c33d6ede6aa..1268b888686 100644 --- a/crates/rome_js_parser/test_data/inline/ok/class_empty_element.rast +++ b/crates/rome_js_parser/test_data/inline/ok/class_empty_element.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@0..6 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -83,15 +84,16 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..40 0: JS_CLASS_DECLARATION@0..40 - 0: (empty) - 1: CLASS_KW@0..6 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@6..10 + 0: JS_DECORATOR_LIST@0..0 + 1: (empty) + 2: CLASS_KW@0..6 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@6..10 0: IDENT@6..10 "foo" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@10..12 "{" [] [Whitespace(" ")] - 7: JS_CLASS_MEMBER_LIST@12..39 + 6: (empty) + 7: L_CURLY@10..12 "{" [] [Whitespace(" ")] + 8: JS_CLASS_MEMBER_LIST@12..39 0: JS_EMPTY_CLASS_MEMBER@12..13 0: SEMICOLON@12..13 ";" [] [] 1: JS_EMPTY_CLASS_MEMBER@13..14 @@ -133,5 +135,5 @@ JsModule { 0: SEMICOLON@37..38 ";" [] [] 14: JS_EMPTY_CLASS_MEMBER@38..39 0: SEMICOLON@38..39 ";" [] [] - 8: R_CURLY@39..40 "}" [] [] + 9: R_CURLY@39..40 "}" [] [] 3: EOF@40..41 "" [Newline("\n")] [] diff --git a/crates/rome_js_parser/test_data/inline/ok/class_expr.rast b/crates/rome_js_parser/test_data/inline/ok/class_expr.rast index b41d1853e5d..61b294f0e2d 100644 --- a/crates/rome_js_parser/test_data/inline/ok/class_expr.rast +++ b/crates/rome_js_parser/test_data/inline/ok/class_expr.rast @@ -14,6 +14,7 @@ JsModule { initializer: JsInitializerClause { eq_token: EQ@6..8 "=" [] [Whitespace(" ")], expression: JsClassExpression { + decorators: JsDecoratorList [], class_token: CLASS_KW@8..14 "class" [] [Whitespace(" ")], id: missing (optional), type_parameters: missing (optional), @@ -41,6 +42,7 @@ JsModule { initializer: JsInitializerClause { eq_token: EQ@24..26 "=" [] [Whitespace(" ")], expression: JsClassExpression { + decorators: JsDecoratorList [], class_token: CLASS_KW@26..32 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { name_token: IDENT@32..36 "foo" [] [Whitespace(" ")], @@ -86,6 +88,7 @@ JsModule { optional_chain_token: missing (optional), l_brack_token: L_BRACK@61..62 "[" [] [], member: JsClassExpression { + decorators: JsDecoratorList [], class_token: CLASS_KW@62..68 "class" [] [Whitespace(" ")], id: missing (optional), type_parameters: missing (optional), @@ -118,14 +121,15 @@ JsModule { 2: JS_INITIALIZER_CLAUSE@6..16 0: EQ@6..8 "=" [] [Whitespace(" ")] 1: JS_CLASS_EXPRESSION@8..16 - 0: CLASS_KW@8..14 "class" [] [Whitespace(" ")] - 1: (empty) + 0: JS_DECORATOR_LIST@8..8 + 1: CLASS_KW@8..14 "class" [] [Whitespace(" ")] 2: (empty) 3: (empty) 4: (empty) - 5: L_CURLY@14..15 "{" [] [] - 6: JS_CLASS_MEMBER_LIST@15..15 - 7: R_CURLY@15..16 "}" [] [] + 5: (empty) + 6: L_CURLY@14..15 "{" [] [] + 7: JS_CLASS_MEMBER_LIST@15..15 + 8: R_CURLY@15..16 "}" [] [] 1: SEMICOLON@16..17 ";" [] [] 1: JS_VARIABLE_STATEMENT@17..57 0: JS_VARIABLE_DECLARATION@17..57 @@ -138,14 +142,15 @@ JsModule { 2: JS_INITIALIZER_CLAUSE@24..57 0: EQ@24..26 "=" [] [Whitespace(" ")] 1: JS_CLASS_EXPRESSION@26..57 - 0: CLASS_KW@26..32 "class" [] [Whitespace(" ")] - 1: JS_IDENTIFIER_BINDING@32..36 + 0: JS_DECORATOR_LIST@26..26 + 1: CLASS_KW@26..32 "class" [] [Whitespace(" ")] + 2: JS_IDENTIFIER_BINDING@32..36 0: IDENT@32..36 "foo" [] [Whitespace(" ")] - 2: (empty) 3: (empty) 4: (empty) - 5: L_CURLY@36..37 "{" [] [] - 6: JS_CLASS_MEMBER_LIST@37..55 + 5: (empty) + 6: L_CURLY@36..37 "{" [] [] + 7: JS_CLASS_MEMBER_LIST@37..55 0: JS_CONSTRUCTOR_CLASS_MEMBER@37..55 0: JS_CONSTRUCTOR_MODIFIER_LIST@37..37 1: JS_LITERAL_MEMBER_NAME@37..50 @@ -159,7 +164,7 @@ JsModule { 1: JS_DIRECTIVE_LIST@54..54 2: JS_STATEMENT_LIST@54..54 3: R_CURLY@54..55 "}" [] [] - 7: R_CURLY@55..57 "}" [Newline("\n")] [] + 8: R_CURLY@55..57 "}" [Newline("\n")] [] 1: (empty) 2: JS_EXPRESSION_STATEMENT@57..71 0: JS_COMPUTED_MEMBER_EXPRESSION@57..71 @@ -169,14 +174,15 @@ JsModule { 1: (empty) 2: L_BRACK@61..62 "[" [] [] 3: JS_CLASS_EXPRESSION@62..70 - 0: CLASS_KW@62..68 "class" [] [Whitespace(" ")] - 1: (empty) + 0: JS_DECORATOR_LIST@62..62 + 1: CLASS_KW@62..68 "class" [] [Whitespace(" ")] 2: (empty) 3: (empty) 4: (empty) - 5: L_CURLY@68..69 "{" [] [] - 6: JS_CLASS_MEMBER_LIST@69..69 - 7: R_CURLY@69..70 "}" [] [] + 5: (empty) + 6: L_CURLY@68..69 "{" [] [] + 7: JS_CLASS_MEMBER_LIST@69..69 + 8: R_CURLY@69..70 "}" [] [] 4: R_BRACK@70..71 "]" [] [] 1: (empty) 3: EOF@71..72 "" [Newline("\n")] [] diff --git a/crates/rome_js_parser/test_data/inline/ok/class_member_modifiers.rast b/crates/rome_js_parser/test_data/inline/ok/class_member_modifiers.rast index f3db9155498..e990092164c 100644 --- a/crates/rome_js_parser/test_data/inline/ok/class_member_modifiers.rast +++ b/crates/rome_js_parser/test_data/inline/ok/class_member_modifiers.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@0..6 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -39,6 +40,7 @@ JsModule { r_curly_token: R_CURLY@22..23 "}" [] [], }, JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@23..30 "class" [Newline("\n")] [Whitespace(" ")], id: JsIdentifierBinding { @@ -79,6 +81,7 @@ JsModule { r_curly_token: R_CURLY@56..57 "}" [] [], }, JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@57..64 "class" [Newline("\n")] [Whitespace(" ")], id: JsIdentifierBinding { @@ -110,15 +113,16 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..76 0: JS_CLASS_DECLARATION@0..23 - 0: (empty) - 1: CLASS_KW@0..6 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@6..8 + 0: JS_DECORATOR_LIST@0..0 + 1: (empty) + 2: CLASS_KW@0..6 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@6..8 0: IDENT@6..8 "A" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@8..10 "{" [] [Whitespace(" ")] - 7: JS_CLASS_MEMBER_LIST@10..22 + 6: (empty) + 7: L_CURLY@8..10 "{" [] [Whitespace(" ")] + 8: JS_CLASS_MEMBER_LIST@10..22 0: JS_METHOD_CLASS_MEMBER@10..22 0: JS_METHOD_MODIFIER_LIST@10..10 1: (empty) @@ -137,17 +141,18 @@ JsModule { 1: JS_DIRECTIVE_LIST@20..20 2: JS_STATEMENT_LIST@20..20 3: R_CURLY@20..22 "}" [] [Whitespace(" ")] - 8: R_CURLY@22..23 "}" [] [] + 9: R_CURLY@22..23 "}" [] [] 1: JS_CLASS_DECLARATION@23..57 - 0: (empty) - 1: CLASS_KW@23..30 "class" [Newline("\n")] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@30..32 + 0: JS_DECORATOR_LIST@23..23 + 1: (empty) + 2: CLASS_KW@23..30 "class" [Newline("\n")] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@30..32 0: IDENT@30..32 "A" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@32..34 "{" [] [Whitespace(" ")] - 7: JS_CLASS_MEMBER_LIST@34..56 + 6: (empty) + 7: L_CURLY@32..34 "{" [] [Whitespace(" ")] + 8: JS_CLASS_MEMBER_LIST@34..56 0: JS_METHOD_CLASS_MEMBER@34..56 0: JS_METHOD_MODIFIER_LIST@34..41 0: JS_STATIC_MODIFIER@34..41 @@ -168,17 +173,18 @@ JsModule { 1: JS_DIRECTIVE_LIST@54..54 2: JS_STATEMENT_LIST@54..54 3: R_CURLY@54..56 "}" [] [Whitespace(" ")] - 8: R_CURLY@56..57 "}" [] [] + 9: R_CURLY@56..57 "}" [] [] 2: JS_CLASS_DECLARATION@57..76 - 0: (empty) - 1: CLASS_KW@57..64 "class" [Newline("\n")] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@64..66 + 0: JS_DECORATOR_LIST@57..57 + 1: (empty) + 2: CLASS_KW@57..64 "class" [Newline("\n")] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@64..66 0: IDENT@64..66 "A" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@66..68 "{" [] [Whitespace(" ")] - 7: JS_CLASS_MEMBER_LIST@68..75 + 6: (empty) + 7: L_CURLY@66..68 "{" [] [Whitespace(" ")] + 8: JS_CLASS_MEMBER_LIST@68..75 0: JS_PROPERTY_CLASS_MEMBER@68..75 0: JS_PROPERTY_MODIFIER_LIST@68..68 1: JS_LITERAL_MEMBER_NAME@68..75 @@ -186,5 +192,5 @@ JsModule { 2: (empty) 3: (empty) 4: (empty) - 8: R_CURLY@75..76 "}" [] [] + 9: R_CURLY@75..76 "}" [] [] 3: EOF@76..77 "" [Newline("\n")] [] diff --git a/crates/rome_js_parser/test_data/inline/ok/class_named_abstract_is_valid_in_js.rast b/crates/rome_js_parser/test_data/inline/ok/class_named_abstract_is_valid_in_js.rast index 438e2cc9086..b8d6389abfb 100644 --- a/crates/rome_js_parser/test_data/inline/ok/class_named_abstract_is_valid_in_js.rast +++ b/crates/rome_js_parser/test_data/inline/ok/class_named_abstract_is_valid_in_js.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@0..6 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -24,14 +25,15 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..17 0: JS_CLASS_DECLARATION@0..17 - 0: (empty) - 1: CLASS_KW@0..6 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@6..15 + 0: JS_DECORATOR_LIST@0..0 + 1: (empty) + 2: CLASS_KW@0..6 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@6..15 0: IDENT@6..15 "abstract" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@15..16 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@16..16 - 8: R_CURLY@16..17 "}" [] [] + 6: (empty) + 7: L_CURLY@15..16 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@16..16 + 9: R_CURLY@16..17 "}" [] [] 3: EOF@17..18 "" [Newline("\n")] [] diff --git a/crates/rome_js_parser/test_data/inline/ok/class_static_constructor_method.rast b/crates/rome_js_parser/test_data/inline/ok/class_static_constructor_method.rast index 150ddc33ebf..96652dd91e5 100644 --- a/crates/rome_js_parser/test_data/inline/ok/class_static_constructor_method.rast +++ b/crates/rome_js_parser/test_data/inline/ok/class_static_constructor_method.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@0..6 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -51,15 +52,16 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..35 0: JS_CLASS_DECLARATION@0..35 - 0: (empty) - 1: CLASS_KW@0..6 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@6..8 + 0: JS_DECORATOR_LIST@0..0 + 1: (empty) + 2: CLASS_KW@0..6 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@6..8 0: IDENT@6..8 "B" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@8..10 "{" [] [Whitespace(" ")] - 7: JS_CLASS_MEMBER_LIST@10..34 + 6: (empty) + 7: L_CURLY@8..10 "{" [] [Whitespace(" ")] + 8: JS_CLASS_MEMBER_LIST@10..34 0: JS_METHOD_CLASS_MEMBER@10..34 0: JS_METHOD_MODIFIER_LIST@10..17 0: JS_STATIC_MODIFIER@10..17 @@ -80,5 +82,5 @@ JsModule { 1: JS_DIRECTIVE_LIST@32..32 2: JS_STATEMENT_LIST@32..32 3: R_CURLY@32..34 "}" [] [Whitespace(" ")] - 8: R_CURLY@34..35 "}" [] [] + 9: R_CURLY@34..35 "}" [] [] 3: EOF@35..36 "" [Newline("\n")] [] diff --git a/crates/rome_js_parser/test_data/inline/ok/constructor_class_member.rast b/crates/rome_js_parser/test_data/inline/ok/constructor_class_member.rast index ac6a6c1f00b..15664f4ed98 100644 --- a/crates/rome_js_parser/test_data/inline/ok/constructor_class_member.rast +++ b/crates/rome_js_parser/test_data/inline/ok/constructor_class_member.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@0..6 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -64,6 +65,7 @@ JsModule { r_curly_token: R_CURLY@50..52 "}" [Newline("\n")] [], }, JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@52..59 "class" [Newline("\n")] [Whitespace(" ")], id: JsIdentifierBinding { @@ -133,15 +135,16 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..107 0: JS_CLASS_DECLARATION@0..52 - 0: (empty) - 1: CLASS_KW@0..6 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@6..10 + 0: JS_DECORATOR_LIST@0..0 + 1: (empty) + 2: CLASS_KW@0..6 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@6..10 0: IDENT@6..10 "Foo" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@10..11 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@11..50 + 6: (empty) + 7: L_CURLY@10..11 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@11..50 0: JS_CONSTRUCTOR_CLASS_MEMBER@11..50 0: JS_CONSTRUCTOR_MODIFIER_LIST@11..11 1: JS_LITERAL_MEMBER_NAME@11..25 @@ -174,17 +177,18 @@ JsModule { 0: IDENT@44..45 "a" [] [] 1: SEMICOLON@45..46 ";" [] [] 3: R_CURLY@46..50 "}" [Newline("\n"), Whitespace(" ")] [] - 8: R_CURLY@50..52 "}" [Newline("\n")] [] + 9: R_CURLY@50..52 "}" [Newline("\n")] [] 1: JS_CLASS_DECLARATION@52..107 - 0: (empty) - 1: CLASS_KW@52..59 "class" [Newline("\n")] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@59..63 + 0: JS_DECORATOR_LIST@52..52 + 1: (empty) + 2: CLASS_KW@52..59 "class" [Newline("\n")] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@59..63 0: IDENT@59..63 "Bar" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@63..64 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@64..105 + 6: (empty) + 7: L_CURLY@63..64 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@64..105 0: JS_CONSTRUCTOR_CLASS_MEMBER@64..105 0: JS_CONSTRUCTOR_MODIFIER_LIST@64..64 1: JS_LITERAL_MEMBER_NAME@64..80 @@ -217,5 +221,5 @@ JsModule { 0: IDENT@99..100 "b" [] [] 1: SEMICOLON@100..101 ";" [] [] 3: R_CURLY@101..105 "}" [Newline("\n"), Whitespace(" ")] [] - 8: R_CURLY@105..107 "}" [Newline("\n")] [] + 9: R_CURLY@105..107 "}" [Newline("\n")] [] 3: EOF@107..108 "" [Newline("\n")] [] diff --git a/crates/rome_js_parser/test_data/inline/ok/decorator.rast b/crates/rome_js_parser/test_data/inline/ok/decorator.rast new file mode 100644 index 00000000000..59d5bb0fa02 --- /dev/null +++ b/crates/rome_js_parser/test_data/inline/ok/decorator.rast @@ -0,0 +1,858 @@ +JsModule { + interpreter_token: missing (optional), + directives: JsDirectiveList [], + items: JsModuleItemList [ + JsVariableStatement { + declaration: JsVariableDeclaration { + kind: LET_KW@0..25 "let" [Comments("// class expressions"), Newline("\n")] [Whitespace(" ")], + declarators: JsVariableDeclaratorList [ + JsVariableDeclarator { + id: JsIdentifierBinding { + name_token: IDENT@25..27 "a" [] [Whitespace(" ")], + }, + variable_annotation: missing (optional), + initializer: JsInitializerClause { + eq_token: EQ@27..29 "=" [] [Whitespace(" ")], + expression: JsClassExpression { + decorators: JsDecoratorList [ + JsDecorator { + at_token: AT@29..30 "@" [] [], + expression: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@30..40 "decorator" [] [Whitespace(" ")], + }, + }, + }, + ], + class_token: CLASS_KW@40..46 "class" [] [Whitespace(" ")], + id: missing (optional), + type_parameters: missing (optional), + extends_clause: missing (optional), + implements_clause: missing (optional), + l_curly_token: L_CURLY@46..47 "{" [] [], + members: JsClassMemberList [], + r_curly_token: R_CURLY@47..48 "}" [] [], + }, + }, + }, + ], + }, + semicolon_token: SEMICOLON@48..49 ";" [] [], + }, + JsVariableStatement { + declaration: JsVariableDeclaration { + kind: LET_KW@49..54 "let" [Newline("\n")] [Whitespace(" ")], + declarators: JsVariableDeclaratorList [ + JsVariableDeclarator { + id: JsIdentifierBinding { + name_token: IDENT@54..56 "b" [] [Whitespace(" ")], + }, + variable_annotation: missing (optional), + initializer: JsInitializerClause { + eq_token: EQ@56..58 "=" [] [Whitespace(" ")], + expression: JsClassExpression { + decorators: JsDecoratorList [ + JsDecorator { + at_token: AT@58..59 "@" [] [], + expression: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@59..69 "decorator" [] [Whitespace(" ")], + }, + }, + }, + JsDecorator { + at_token: AT@69..70 "@" [] [], + expression: JsCallExpression { + callee: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@70..87 "functionDecorator" [] [], + }, + }, + optional_chain_token: missing (optional), + type_arguments: missing (optional), + arguments: JsCallArguments { + l_paren_token: L_PAREN@87..88 "(" [] [], + args: JsCallArgumentList [ + JsNumberLiteralExpression { + value_token: JS_NUMBER_LITERAL@88..89 "1" [] [], + }, + COMMA@89..90 "," [] [], + JsNumberLiteralExpression { + value_token: JS_NUMBER_LITERAL@90..91 "2" [] [], + }, + COMMA@91..92 "," [] [], + JsNumberLiteralExpression { + value_token: JS_NUMBER_LITERAL@92..93 "3" [] [], + }, + ], + r_paren_token: R_PAREN@93..95 ")" [] [Whitespace(" ")], + }, + }, + }, + ], + class_token: CLASS_KW@95..101 "class" [] [Whitespace(" ")], + id: missing (optional), + type_parameters: missing (optional), + extends_clause: missing (optional), + implements_clause: missing (optional), + l_curly_token: L_CURLY@101..102 "{" [] [], + members: JsClassMemberList [], + r_curly_token: R_CURLY@102..103 "}" [] [], + }, + }, + }, + ], + }, + semicolon_token: SEMICOLON@103..104 ";" [] [], + }, + JsVariableStatement { + declaration: JsVariableDeclaration { + kind: LET_KW@104..109 "let" [Newline("\n")] [Whitespace(" ")], + declarators: JsVariableDeclaratorList [ + JsVariableDeclarator { + id: JsIdentifierBinding { + name_token: IDENT@109..111 "c" [] [Whitespace(" ")], + }, + variable_annotation: missing (optional), + initializer: JsInitializerClause { + eq_token: EQ@111..113 "=" [] [Whitespace(" ")], + expression: JsClassExpression { + decorators: JsDecoratorList [ + JsDecorator { + at_token: AT@113..114 "@" [] [], + expression: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@114..120 "first" [] [Whitespace(" ")], + }, + }, + }, + JsDecorator { + at_token: AT@120..121 "@" [] [], + expression: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@121..128 "second" [] [Whitespace(" ")], + }, + }, + }, + ], + class_token: CLASS_KW@128..134 "class" [] [Whitespace(" ")], + id: JsIdentifierBinding { + name_token: IDENT@134..138 "Foo" [] [Whitespace(" ")], + }, + type_parameters: missing (optional), + extends_clause: missing (optional), + implements_clause: missing (optional), + l_curly_token: L_CURLY@138..139 "{" [] [], + members: JsClassMemberList [], + r_curly_token: R_CURLY@139..140 "}" [] [], + }, + }, + }, + ], + }, + semicolon_token: missing (optional), + }, + JsClassDeclaration { + decorators: JsDecoratorList [ + JsDecorator { + at_token: AT@140..164 "@" [Newline("\n"), Comments("// class declarations"), Newline("\n")] [], + expression: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@164..174 "decorator" [] [Whitespace(" ")], + }, + }, + }, + ], + abstract_token: missing (optional), + class_token: CLASS_KW@174..180 "class" [] [Whitespace(" ")], + id: JsIdentifierBinding { + name_token: IDENT@180..184 "Foo" [] [Whitespace(" ")], + }, + type_parameters: missing (optional), + extends_clause: missing (optional), + implements_clause: missing (optional), + l_curly_token: L_CURLY@184..185 "{" [] [], + members: JsClassMemberList [], + r_curly_token: R_CURLY@185..186 "}" [] [], + }, + JsEmptyStatement { + semicolon_token: SEMICOLON@186..187 ";" [] [], + }, + JsClassDeclaration { + decorators: JsDecoratorList [ + JsDecorator { + at_token: AT@187..189 "@" [Newline("\n")] [], + expression: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@189..199 "decorator" [] [Whitespace(" ")], + }, + }, + }, + JsDecorator { + at_token: AT@199..200 "@" [] [], + expression: JsCallExpression { + callee: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@200..217 "functionDecorator" [] [], + }, + }, + optional_chain_token: missing (optional), + type_arguments: missing (optional), + arguments: JsCallArguments { + l_paren_token: L_PAREN@217..218 "(" [] [], + args: JsCallArgumentList [ + JsNumberLiteralExpression { + value_token: JS_NUMBER_LITERAL@218..219 "1" [] [], + }, + COMMA@219..220 "," [] [], + JsNumberLiteralExpression { + value_token: JS_NUMBER_LITERAL@220..221 "2" [] [], + }, + COMMA@221..222 "," [] [], + JsNumberLiteralExpression { + value_token: JS_NUMBER_LITERAL@222..223 "3" [] [], + }, + ], + r_paren_token: R_PAREN@223..225 ")" [] [Whitespace(" ")], + }, + }, + }, + ], + abstract_token: missing (optional), + class_token: CLASS_KW@225..231 "class" [] [Whitespace(" ")], + id: JsIdentifierBinding { + name_token: IDENT@231..235 "Bar" [] [Whitespace(" ")], + }, + type_parameters: missing (optional), + extends_clause: missing (optional), + implements_clause: missing (optional), + l_curly_token: L_CURLY@235..236 "{" [] [], + members: JsClassMemberList [], + r_curly_token: R_CURLY@236..237 "}" [] [], + }, + JsEmptyStatement { + semicolon_token: SEMICOLON@237..238 ";" [] [], + }, + JsClassDeclaration { + decorators: JsDecoratorList [ + JsDecorator { + at_token: AT@238..240 "@" [Newline("\n")] [], + expression: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@240..246 "first" [] [Whitespace(" ")], + }, + }, + }, + JsDecorator { + at_token: AT@246..247 "@" [] [], + expression: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@247..254 "second" [] [Whitespace(" ")], + }, + }, + }, + ], + abstract_token: missing (optional), + class_token: CLASS_KW@254..260 "class" [] [Whitespace(" ")], + id: JsIdentifierBinding { + name_token: IDENT@260..264 "Baz" [] [Whitespace(" ")], + }, + type_parameters: missing (optional), + extends_clause: missing (optional), + implements_clause: missing (optional), + l_curly_token: L_CURLY@264..265 "{" [] [], + members: JsClassMemberList [], + r_curly_token: R_CURLY@265..266 "}" [] [], + }, + JsClassDeclaration { + decorators: JsDecoratorList [ + JsDecorator { + at_token: AT@266..299 "@" [Newline("\n"), Comments("// abstract class dec ..."), Newline("\n")] [], + expression: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@299..309 "decorator" [] [Whitespace(" ")], + }, + }, + }, + ], + abstract_token: ABSTRACT_KW@309..318 "abstract" [] [Whitespace(" ")], + class_token: CLASS_KW@318..324 "class" [] [Whitespace(" ")], + id: JsIdentifierBinding { + name_token: IDENT@324..328 "Foo" [] [Whitespace(" ")], + }, + type_parameters: missing (optional), + extends_clause: missing (optional), + implements_clause: missing (optional), + l_curly_token: L_CURLY@328..329 "{" [] [], + members: JsClassMemberList [], + r_curly_token: R_CURLY@329..330 "}" [] [], + }, + JsEmptyStatement { + semicolon_token: SEMICOLON@330..331 ";" [] [], + }, + JsClassDeclaration { + decorators: JsDecoratorList [ + JsDecorator { + at_token: AT@331..333 "@" [Newline("\n")] [], + expression: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@333..343 "decorator" [] [Whitespace(" ")], + }, + }, + }, + JsDecorator { + at_token: AT@343..344 "@" [] [], + expression: JsCallExpression { + callee: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@344..361 "functionDecorator" [] [], + }, + }, + optional_chain_token: missing (optional), + type_arguments: missing (optional), + arguments: JsCallArguments { + l_paren_token: L_PAREN@361..362 "(" [] [], + args: JsCallArgumentList [ + JsNumberLiteralExpression { + value_token: JS_NUMBER_LITERAL@362..363 "1" [] [], + }, + COMMA@363..364 "," [] [], + JsNumberLiteralExpression { + value_token: JS_NUMBER_LITERAL@364..365 "2" [] [], + }, + COMMA@365..366 "," [] [], + JsNumberLiteralExpression { + value_token: JS_NUMBER_LITERAL@366..367 "3" [] [], + }, + ], + r_paren_token: R_PAREN@367..369 ")" [] [Whitespace(" ")], + }, + }, + }, + ], + abstract_token: ABSTRACT_KW@369..378 "abstract" [] [Whitespace(" ")], + class_token: CLASS_KW@378..384 "class" [] [Whitespace(" ")], + id: JsIdentifierBinding { + name_token: IDENT@384..388 "Bar" [] [Whitespace(" ")], + }, + type_parameters: missing (optional), + extends_clause: missing (optional), + implements_clause: missing (optional), + l_curly_token: L_CURLY@388..389 "{" [] [], + members: JsClassMemberList [], + r_curly_token: R_CURLY@389..390 "}" [] [], + }, + JsEmptyStatement { + semicolon_token: SEMICOLON@390..391 ";" [] [], + }, + JsClassDeclaration { + decorators: JsDecoratorList [ + JsDecorator { + at_token: AT@391..393 "@" [Newline("\n")] [], + expression: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@393..399 "first" [] [Whitespace(" ")], + }, + }, + }, + JsDecorator { + at_token: AT@399..400 "@" [] [], + expression: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@400..407 "second" [] [Whitespace(" ")], + }, + }, + }, + ], + abstract_token: ABSTRACT_KW@407..416 "abstract" [] [Whitespace(" ")], + class_token: CLASS_KW@416..422 "class" [] [Whitespace(" ")], + id: JsIdentifierBinding { + name_token: IDENT@422..426 "Baz" [] [Whitespace(" ")], + }, + type_parameters: missing (optional), + extends_clause: missing (optional), + implements_clause: missing (optional), + l_curly_token: L_CURLY@426..427 "{" [] [], + members: JsClassMemberList [], + r_curly_token: R_CURLY@427..428 "}" [] [], + }, + JsExport { + export_token: EXPORT_KW@428..467 "export" [Newline("\n"), Comments("// exported class dec ..."), Newline("\n")] [Whitespace(" ")], + export_clause: JsClassDeclaration { + decorators: JsDecoratorList [ + JsDecorator { + at_token: AT@467..468 "@" [] [], + expression: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@468..478 "decorator" [] [Whitespace(" ")], + }, + }, + }, + ], + abstract_token: missing (optional), + class_token: CLASS_KW@478..484 "class" [] [Whitespace(" ")], + id: JsIdentifierBinding { + name_token: IDENT@484..488 "Foo" [] [Whitespace(" ")], + }, + type_parameters: missing (optional), + extends_clause: missing (optional), + implements_clause: missing (optional), + l_curly_token: L_CURLY@488..489 "{" [] [], + members: JsClassMemberList [], + r_curly_token: R_CURLY@489..490 "}" [] [], + }, + }, + JsEmptyStatement { + semicolon_token: SEMICOLON@490..491 ";" [] [], + }, + JsExport { + export_token: EXPORT_KW@491..499 "export" [Newline("\n")] [Whitespace(" ")], + export_clause: JsClassDeclaration { + decorators: JsDecoratorList [ + JsDecorator { + at_token: AT@499..500 "@" [] [], + expression: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@500..510 "decorator" [] [Whitespace(" ")], + }, + }, + }, + JsDecorator { + at_token: AT@510..511 "@" [] [], + expression: JsCallExpression { + callee: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@511..528 "functionDecorator" [] [], + }, + }, + optional_chain_token: missing (optional), + type_arguments: missing (optional), + arguments: JsCallArguments { + l_paren_token: L_PAREN@528..529 "(" [] [], + args: JsCallArgumentList [ + JsNumberLiteralExpression { + value_token: JS_NUMBER_LITERAL@529..530 "1" [] [], + }, + COMMA@530..531 "," [] [], + JsNumberLiteralExpression { + value_token: JS_NUMBER_LITERAL@531..532 "2" [] [], + }, + COMMA@532..533 "," [] [], + JsNumberLiteralExpression { + value_token: JS_NUMBER_LITERAL@533..534 "3" [] [], + }, + ], + r_paren_token: R_PAREN@534..536 ")" [] [Whitespace(" ")], + }, + }, + }, + ], + abstract_token: missing (optional), + class_token: CLASS_KW@536..542 "class" [] [Whitespace(" ")], + id: JsIdentifierBinding { + name_token: IDENT@542..546 "Bar" [] [Whitespace(" ")], + }, + type_parameters: missing (optional), + extends_clause: missing (optional), + implements_clause: missing (optional), + l_curly_token: L_CURLY@546..547 "{" [] [], + members: JsClassMemberList [], + r_curly_token: R_CURLY@547..548 "}" [] [], + }, + }, + JsEmptyStatement { + semicolon_token: SEMICOLON@548..549 ";" [] [], + }, + JsExport { + export_token: EXPORT_KW@549..557 "export" [Newline("\n")] [Whitespace(" ")], + export_clause: JsClassDeclaration { + decorators: JsDecoratorList [ + JsDecorator { + at_token: AT@557..558 "@" [] [], + expression: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@558..564 "first" [] [Whitespace(" ")], + }, + }, + }, + JsDecorator { + at_token: AT@564..565 "@" [] [], + expression: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@565..572 "second" [] [Whitespace(" ")], + }, + }, + }, + ], + abstract_token: missing (optional), + class_token: CLASS_KW@572..578 "class" [] [Whitespace(" ")], + id: JsIdentifierBinding { + name_token: IDENT@578..582 "Baz" [] [Whitespace(" ")], + }, + type_parameters: missing (optional), + extends_clause: missing (optional), + implements_clause: missing (optional), + l_curly_token: L_CURLY@582..583 "{" [] [], + members: JsClassMemberList [], + r_curly_token: R_CURLY@583..584 "}" [] [], + }, + }, + ], + eof_token: EOF@584..585 "" [Newline("\n")] [], +} + +0: JS_MODULE@0..585 + 0: (empty) + 1: JS_DIRECTIVE_LIST@0..0 + 2: JS_MODULE_ITEM_LIST@0..584 + 0: JS_VARIABLE_STATEMENT@0..49 + 0: JS_VARIABLE_DECLARATION@0..48 + 0: LET_KW@0..25 "let" [Comments("// class expressions"), Newline("\n")] [Whitespace(" ")] + 1: JS_VARIABLE_DECLARATOR_LIST@25..48 + 0: JS_VARIABLE_DECLARATOR@25..48 + 0: JS_IDENTIFIER_BINDING@25..27 + 0: IDENT@25..27 "a" [] [Whitespace(" ")] + 1: (empty) + 2: JS_INITIALIZER_CLAUSE@27..48 + 0: EQ@27..29 "=" [] [Whitespace(" ")] + 1: JS_CLASS_EXPRESSION@29..48 + 0: JS_DECORATOR_LIST@29..40 + 0: JS_DECORATOR@29..40 + 0: AT@29..30 "@" [] [] + 1: JS_IDENTIFIER_EXPRESSION@30..40 + 0: JS_REFERENCE_IDENTIFIER@30..40 + 0: IDENT@30..40 "decorator" [] [Whitespace(" ")] + 1: CLASS_KW@40..46 "class" [] [Whitespace(" ")] + 2: (empty) + 3: (empty) + 4: (empty) + 5: (empty) + 6: L_CURLY@46..47 "{" [] [] + 7: JS_CLASS_MEMBER_LIST@47..47 + 8: R_CURLY@47..48 "}" [] [] + 1: SEMICOLON@48..49 ";" [] [] + 1: JS_VARIABLE_STATEMENT@49..104 + 0: JS_VARIABLE_DECLARATION@49..103 + 0: LET_KW@49..54 "let" [Newline("\n")] [Whitespace(" ")] + 1: JS_VARIABLE_DECLARATOR_LIST@54..103 + 0: JS_VARIABLE_DECLARATOR@54..103 + 0: JS_IDENTIFIER_BINDING@54..56 + 0: IDENT@54..56 "b" [] [Whitespace(" ")] + 1: (empty) + 2: JS_INITIALIZER_CLAUSE@56..103 + 0: EQ@56..58 "=" [] [Whitespace(" ")] + 1: JS_CLASS_EXPRESSION@58..103 + 0: JS_DECORATOR_LIST@58..95 + 0: JS_DECORATOR@58..69 + 0: AT@58..59 "@" [] [] + 1: JS_IDENTIFIER_EXPRESSION@59..69 + 0: JS_REFERENCE_IDENTIFIER@59..69 + 0: IDENT@59..69 "decorator" [] [Whitespace(" ")] + 1: JS_DECORATOR@69..95 + 0: AT@69..70 "@" [] [] + 1: JS_CALL_EXPRESSION@70..95 + 0: JS_IDENTIFIER_EXPRESSION@70..87 + 0: JS_REFERENCE_IDENTIFIER@70..87 + 0: IDENT@70..87 "functionDecorator" [] [] + 1: (empty) + 2: (empty) + 3: JS_CALL_ARGUMENTS@87..95 + 0: L_PAREN@87..88 "(" [] [] + 1: JS_CALL_ARGUMENT_LIST@88..93 + 0: JS_NUMBER_LITERAL_EXPRESSION@88..89 + 0: JS_NUMBER_LITERAL@88..89 "1" [] [] + 1: COMMA@89..90 "," [] [] + 2: JS_NUMBER_LITERAL_EXPRESSION@90..91 + 0: JS_NUMBER_LITERAL@90..91 "2" [] [] + 3: COMMA@91..92 "," [] [] + 4: JS_NUMBER_LITERAL_EXPRESSION@92..93 + 0: JS_NUMBER_LITERAL@92..93 "3" [] [] + 2: R_PAREN@93..95 ")" [] [Whitespace(" ")] + 1: CLASS_KW@95..101 "class" [] [Whitespace(" ")] + 2: (empty) + 3: (empty) + 4: (empty) + 5: (empty) + 6: L_CURLY@101..102 "{" [] [] + 7: JS_CLASS_MEMBER_LIST@102..102 + 8: R_CURLY@102..103 "}" [] [] + 1: SEMICOLON@103..104 ";" [] [] + 2: JS_VARIABLE_STATEMENT@104..140 + 0: JS_VARIABLE_DECLARATION@104..140 + 0: LET_KW@104..109 "let" [Newline("\n")] [Whitespace(" ")] + 1: JS_VARIABLE_DECLARATOR_LIST@109..140 + 0: JS_VARIABLE_DECLARATOR@109..140 + 0: JS_IDENTIFIER_BINDING@109..111 + 0: IDENT@109..111 "c" [] [Whitespace(" ")] + 1: (empty) + 2: JS_INITIALIZER_CLAUSE@111..140 + 0: EQ@111..113 "=" [] [Whitespace(" ")] + 1: JS_CLASS_EXPRESSION@113..140 + 0: JS_DECORATOR_LIST@113..128 + 0: JS_DECORATOR@113..120 + 0: AT@113..114 "@" [] [] + 1: JS_IDENTIFIER_EXPRESSION@114..120 + 0: JS_REFERENCE_IDENTIFIER@114..120 + 0: IDENT@114..120 "first" [] [Whitespace(" ")] + 1: JS_DECORATOR@120..128 + 0: AT@120..121 "@" [] [] + 1: JS_IDENTIFIER_EXPRESSION@121..128 + 0: JS_REFERENCE_IDENTIFIER@121..128 + 0: IDENT@121..128 "second" [] [Whitespace(" ")] + 1: CLASS_KW@128..134 "class" [] [Whitespace(" ")] + 2: JS_IDENTIFIER_BINDING@134..138 + 0: IDENT@134..138 "Foo" [] [Whitespace(" ")] + 3: (empty) + 4: (empty) + 5: (empty) + 6: L_CURLY@138..139 "{" [] [] + 7: JS_CLASS_MEMBER_LIST@139..139 + 8: R_CURLY@139..140 "}" [] [] + 1: (empty) + 3: JS_CLASS_DECLARATION@140..186 + 0: JS_DECORATOR_LIST@140..174 + 0: JS_DECORATOR@140..174 + 0: AT@140..164 "@" [Newline("\n"), Comments("// class declarations"), Newline("\n")] [] + 1: JS_IDENTIFIER_EXPRESSION@164..174 + 0: JS_REFERENCE_IDENTIFIER@164..174 + 0: IDENT@164..174 "decorator" [] [Whitespace(" ")] + 1: (empty) + 2: CLASS_KW@174..180 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@180..184 + 0: IDENT@180..184 "Foo" [] [Whitespace(" ")] + 4: (empty) + 5: (empty) + 6: (empty) + 7: L_CURLY@184..185 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@185..185 + 9: R_CURLY@185..186 "}" [] [] + 4: JS_EMPTY_STATEMENT@186..187 + 0: SEMICOLON@186..187 ";" [] [] + 5: JS_CLASS_DECLARATION@187..237 + 0: JS_DECORATOR_LIST@187..225 + 0: JS_DECORATOR@187..199 + 0: AT@187..189 "@" [Newline("\n")] [] + 1: JS_IDENTIFIER_EXPRESSION@189..199 + 0: JS_REFERENCE_IDENTIFIER@189..199 + 0: IDENT@189..199 "decorator" [] [Whitespace(" ")] + 1: JS_DECORATOR@199..225 + 0: AT@199..200 "@" [] [] + 1: JS_CALL_EXPRESSION@200..225 + 0: JS_IDENTIFIER_EXPRESSION@200..217 + 0: JS_REFERENCE_IDENTIFIER@200..217 + 0: IDENT@200..217 "functionDecorator" [] [] + 1: (empty) + 2: (empty) + 3: JS_CALL_ARGUMENTS@217..225 + 0: L_PAREN@217..218 "(" [] [] + 1: JS_CALL_ARGUMENT_LIST@218..223 + 0: JS_NUMBER_LITERAL_EXPRESSION@218..219 + 0: JS_NUMBER_LITERAL@218..219 "1" [] [] + 1: COMMA@219..220 "," [] [] + 2: JS_NUMBER_LITERAL_EXPRESSION@220..221 + 0: JS_NUMBER_LITERAL@220..221 "2" [] [] + 3: COMMA@221..222 "," [] [] + 4: JS_NUMBER_LITERAL_EXPRESSION@222..223 + 0: JS_NUMBER_LITERAL@222..223 "3" [] [] + 2: R_PAREN@223..225 ")" [] [Whitespace(" ")] + 1: (empty) + 2: CLASS_KW@225..231 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@231..235 + 0: IDENT@231..235 "Bar" [] [Whitespace(" ")] + 4: (empty) + 5: (empty) + 6: (empty) + 7: L_CURLY@235..236 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@236..236 + 9: R_CURLY@236..237 "}" [] [] + 6: JS_EMPTY_STATEMENT@237..238 + 0: SEMICOLON@237..238 ";" [] [] + 7: JS_CLASS_DECLARATION@238..266 + 0: JS_DECORATOR_LIST@238..254 + 0: JS_DECORATOR@238..246 + 0: AT@238..240 "@" [Newline("\n")] [] + 1: JS_IDENTIFIER_EXPRESSION@240..246 + 0: JS_REFERENCE_IDENTIFIER@240..246 + 0: IDENT@240..246 "first" [] [Whitespace(" ")] + 1: JS_DECORATOR@246..254 + 0: AT@246..247 "@" [] [] + 1: JS_IDENTIFIER_EXPRESSION@247..254 + 0: JS_REFERENCE_IDENTIFIER@247..254 + 0: IDENT@247..254 "second" [] [Whitespace(" ")] + 1: (empty) + 2: CLASS_KW@254..260 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@260..264 + 0: IDENT@260..264 "Baz" [] [Whitespace(" ")] + 4: (empty) + 5: (empty) + 6: (empty) + 7: L_CURLY@264..265 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@265..265 + 9: R_CURLY@265..266 "}" [] [] + 8: JS_CLASS_DECLARATION@266..330 + 0: JS_DECORATOR_LIST@266..309 + 0: JS_DECORATOR@266..309 + 0: AT@266..299 "@" [Newline("\n"), Comments("// abstract class dec ..."), Newline("\n")] [] + 1: JS_IDENTIFIER_EXPRESSION@299..309 + 0: JS_REFERENCE_IDENTIFIER@299..309 + 0: IDENT@299..309 "decorator" [] [Whitespace(" ")] + 1: ABSTRACT_KW@309..318 "abstract" [] [Whitespace(" ")] + 2: CLASS_KW@318..324 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@324..328 + 0: IDENT@324..328 "Foo" [] [Whitespace(" ")] + 4: (empty) + 5: (empty) + 6: (empty) + 7: L_CURLY@328..329 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@329..329 + 9: R_CURLY@329..330 "}" [] [] + 9: JS_EMPTY_STATEMENT@330..331 + 0: SEMICOLON@330..331 ";" [] [] + 10: JS_CLASS_DECLARATION@331..390 + 0: JS_DECORATOR_LIST@331..369 + 0: JS_DECORATOR@331..343 + 0: AT@331..333 "@" [Newline("\n")] [] + 1: JS_IDENTIFIER_EXPRESSION@333..343 + 0: JS_REFERENCE_IDENTIFIER@333..343 + 0: IDENT@333..343 "decorator" [] [Whitespace(" ")] + 1: JS_DECORATOR@343..369 + 0: AT@343..344 "@" [] [] + 1: JS_CALL_EXPRESSION@344..369 + 0: JS_IDENTIFIER_EXPRESSION@344..361 + 0: JS_REFERENCE_IDENTIFIER@344..361 + 0: IDENT@344..361 "functionDecorator" [] [] + 1: (empty) + 2: (empty) + 3: JS_CALL_ARGUMENTS@361..369 + 0: L_PAREN@361..362 "(" [] [] + 1: JS_CALL_ARGUMENT_LIST@362..367 + 0: JS_NUMBER_LITERAL_EXPRESSION@362..363 + 0: JS_NUMBER_LITERAL@362..363 "1" [] [] + 1: COMMA@363..364 "," [] [] + 2: JS_NUMBER_LITERAL_EXPRESSION@364..365 + 0: JS_NUMBER_LITERAL@364..365 "2" [] [] + 3: COMMA@365..366 "," [] [] + 4: JS_NUMBER_LITERAL_EXPRESSION@366..367 + 0: JS_NUMBER_LITERAL@366..367 "3" [] [] + 2: R_PAREN@367..369 ")" [] [Whitespace(" ")] + 1: ABSTRACT_KW@369..378 "abstract" [] [Whitespace(" ")] + 2: CLASS_KW@378..384 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@384..388 + 0: IDENT@384..388 "Bar" [] [Whitespace(" ")] + 4: (empty) + 5: (empty) + 6: (empty) + 7: L_CURLY@388..389 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@389..389 + 9: R_CURLY@389..390 "}" [] [] + 11: JS_EMPTY_STATEMENT@390..391 + 0: SEMICOLON@390..391 ";" [] [] + 12: JS_CLASS_DECLARATION@391..428 + 0: JS_DECORATOR_LIST@391..407 + 0: JS_DECORATOR@391..399 + 0: AT@391..393 "@" [Newline("\n")] [] + 1: JS_IDENTIFIER_EXPRESSION@393..399 + 0: JS_REFERENCE_IDENTIFIER@393..399 + 0: IDENT@393..399 "first" [] [Whitespace(" ")] + 1: JS_DECORATOR@399..407 + 0: AT@399..400 "@" [] [] + 1: JS_IDENTIFIER_EXPRESSION@400..407 + 0: JS_REFERENCE_IDENTIFIER@400..407 + 0: IDENT@400..407 "second" [] [Whitespace(" ")] + 1: ABSTRACT_KW@407..416 "abstract" [] [Whitespace(" ")] + 2: CLASS_KW@416..422 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@422..426 + 0: IDENT@422..426 "Baz" [] [Whitespace(" ")] + 4: (empty) + 5: (empty) + 6: (empty) + 7: L_CURLY@426..427 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@427..427 + 9: R_CURLY@427..428 "}" [] [] + 13: JS_EXPORT@428..490 + 0: EXPORT_KW@428..467 "export" [Newline("\n"), Comments("// exported class dec ..."), Newline("\n")] [Whitespace(" ")] + 1: JS_CLASS_DECLARATION@467..490 + 0: JS_DECORATOR_LIST@467..478 + 0: JS_DECORATOR@467..478 + 0: AT@467..468 "@" [] [] + 1: JS_IDENTIFIER_EXPRESSION@468..478 + 0: JS_REFERENCE_IDENTIFIER@468..478 + 0: IDENT@468..478 "decorator" [] [Whitespace(" ")] + 1: (empty) + 2: CLASS_KW@478..484 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@484..488 + 0: IDENT@484..488 "Foo" [] [Whitespace(" ")] + 4: (empty) + 5: (empty) + 6: (empty) + 7: L_CURLY@488..489 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@489..489 + 9: R_CURLY@489..490 "}" [] [] + 14: JS_EMPTY_STATEMENT@490..491 + 0: SEMICOLON@490..491 ";" [] [] + 15: JS_EXPORT@491..548 + 0: EXPORT_KW@491..499 "export" [Newline("\n")] [Whitespace(" ")] + 1: JS_CLASS_DECLARATION@499..548 + 0: JS_DECORATOR_LIST@499..536 + 0: JS_DECORATOR@499..510 + 0: AT@499..500 "@" [] [] + 1: JS_IDENTIFIER_EXPRESSION@500..510 + 0: JS_REFERENCE_IDENTIFIER@500..510 + 0: IDENT@500..510 "decorator" [] [Whitespace(" ")] + 1: JS_DECORATOR@510..536 + 0: AT@510..511 "@" [] [] + 1: JS_CALL_EXPRESSION@511..536 + 0: JS_IDENTIFIER_EXPRESSION@511..528 + 0: JS_REFERENCE_IDENTIFIER@511..528 + 0: IDENT@511..528 "functionDecorator" [] [] + 1: (empty) + 2: (empty) + 3: JS_CALL_ARGUMENTS@528..536 + 0: L_PAREN@528..529 "(" [] [] + 1: JS_CALL_ARGUMENT_LIST@529..534 + 0: JS_NUMBER_LITERAL_EXPRESSION@529..530 + 0: JS_NUMBER_LITERAL@529..530 "1" [] [] + 1: COMMA@530..531 "," [] [] + 2: JS_NUMBER_LITERAL_EXPRESSION@531..532 + 0: JS_NUMBER_LITERAL@531..532 "2" [] [] + 3: COMMA@532..533 "," [] [] + 4: JS_NUMBER_LITERAL_EXPRESSION@533..534 + 0: JS_NUMBER_LITERAL@533..534 "3" [] [] + 2: R_PAREN@534..536 ")" [] [Whitespace(" ")] + 1: (empty) + 2: CLASS_KW@536..542 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@542..546 + 0: IDENT@542..546 "Bar" [] [Whitespace(" ")] + 4: (empty) + 5: (empty) + 6: (empty) + 7: L_CURLY@546..547 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@547..547 + 9: R_CURLY@547..548 "}" [] [] + 16: JS_EMPTY_STATEMENT@548..549 + 0: SEMICOLON@548..549 ";" [] [] + 17: JS_EXPORT@549..584 + 0: EXPORT_KW@549..557 "export" [Newline("\n")] [Whitespace(" ")] + 1: JS_CLASS_DECLARATION@557..584 + 0: JS_DECORATOR_LIST@557..572 + 0: JS_DECORATOR@557..564 + 0: AT@557..558 "@" [] [] + 1: JS_IDENTIFIER_EXPRESSION@558..564 + 0: JS_REFERENCE_IDENTIFIER@558..564 + 0: IDENT@558..564 "first" [] [Whitespace(" ")] + 1: JS_DECORATOR@564..572 + 0: AT@564..565 "@" [] [] + 1: JS_IDENTIFIER_EXPRESSION@565..572 + 0: JS_REFERENCE_IDENTIFIER@565..572 + 0: IDENT@565..572 "second" [] [Whitespace(" ")] + 1: (empty) + 2: CLASS_KW@572..578 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@578..582 + 0: IDENT@578..582 "Baz" [] [Whitespace(" ")] + 4: (empty) + 5: (empty) + 6: (empty) + 7: L_CURLY@582..583 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@583..583 + 9: R_CURLY@583..584 "}" [] [] + 3: EOF@584..585 "" [Newline("\n")] [] diff --git a/crates/rome_js_parser/test_data/inline/ok/decorator.ts b/crates/rome_js_parser/test_data/inline/ok/decorator.ts new file mode 100644 index 00000000000..60434a5a6c7 --- /dev/null +++ b/crates/rome_js_parser/test_data/inline/ok/decorator.ts @@ -0,0 +1,16 @@ +// class expressions +let a = @decorator class {}; +let b = @decorator @functionDecorator(1,2,3) class {}; +let c = @first @second class Foo {} +// class declarations +@decorator class Foo {}; +@decorator @functionDecorator(1,2,3) class Bar {}; +@first @second class Baz {} +// abstract class declarations +@decorator abstract class Foo {}; +@decorator @functionDecorator(1,2,3) abstract class Bar {}; +@first @second abstract class Baz {} +// exported class declarations +export @decorator class Foo {}; +export @decorator @functionDecorator(1,2,3) class Bar {}; +export @first @second class Baz {} diff --git a/crates/rome_js_parser/test_data/inline/ok/decorator_abstract_class_declaration.rast b/crates/rome_js_parser/test_data/inline/ok/decorator_abstract_class_declaration.rast new file mode 100644 index 00000000000..7604bd3b20b --- /dev/null +++ b/crates/rome_js_parser/test_data/inline/ok/decorator_abstract_class_declaration.rast @@ -0,0 +1,211 @@ +JsModule { + interpreter_token: missing (optional), + directives: JsDirectiveList [], + items: JsModuleItemList [ + JsFunctionDeclaration { + async_token: missing (optional), + function_token: FUNCTION_KW@0..9 "function" [] [Whitespace(" ")], + star_token: missing (optional), + id: JsIdentifierBinding { + name_token: IDENT@9..12 "foo" [] [], + }, + type_parameters: missing (optional), + parameters: JsParameters { + l_paren_token: L_PAREN@12..13 "(" [] [], + items: JsParameterList [], + r_paren_token: R_PAREN@13..15 ")" [] [Whitespace(" ")], + }, + return_type_annotation: missing (optional), + body: JsFunctionBody { + l_curly_token: L_CURLY@15..16 "{" [] [], + directives: JsDirectiveList [], + statements: JsStatementList [ + JsClassDeclaration { + decorators: JsDecoratorList [ + JsDecorator { + at_token: AT@16..23 "@" [Newline("\n"), Whitespace(" ")] [], + expression: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@23..33 "decorator" [] [Whitespace(" ")], + }, + }, + }, + ], + abstract_token: ABSTRACT_KW@33..42 "abstract" [] [Whitespace(" ")], + class_token: CLASS_KW@42..48 "class" [] [Whitespace(" ")], + id: JsIdentifierBinding { + name_token: IDENT@48..50 "A" [] [Whitespace(" ")], + }, + type_parameters: missing (optional), + extends_clause: missing (optional), + implements_clause: missing (optional), + l_curly_token: L_CURLY@50..51 "{" [] [], + members: JsClassMemberList [], + r_curly_token: R_CURLY@51..52 "}" [] [], + }, + JsClassDeclaration { + decorators: JsDecoratorList [ + JsDecorator { + at_token: AT@52..59 "@" [Newline("\n"), Whitespace(" ")] [], + expression: JsStaticMemberExpression { + object: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@59..64 "first" [] [], + }, + }, + operator_token: DOT@64..65 "." [] [], + member: JsName { + value_token: IDENT@65..71 "field" [] [Whitespace(" ")], + }, + }, + }, + JsDecorator { + at_token: AT@71..72 "@" [] [], + expression: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@72..79 "second" [] [Whitespace(" ")], + }, + }, + }, + JsDecorator { + at_token: AT@79..80 "@" [] [], + expression: JsCallExpression { + callee: JsParenthesizedExpression { + l_paren_token: L_PAREN@80..81 "(" [] [], + expression: JsArrowFunctionExpression { + async_token: missing (optional), + type_parameters: missing (optional), + parameters: JsParameters { + l_paren_token: L_PAREN@81..82 "(" [] [], + items: JsParameterList [], + r_paren_token: R_PAREN@82..84 ")" [] [Whitespace(" ")], + }, + return_type_annotation: missing (optional), + fat_arrow_token: FAT_ARROW@84..87 "=>" [] [Whitespace(" ")], + body: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@87..96 "decorator" [] [], + }, + }, + }, + r_paren_token: R_PAREN@96..97 ")" [] [], + }, + optional_chain_token: missing (optional), + type_arguments: missing (optional), + arguments: JsCallArguments { + l_paren_token: L_PAREN@97..98 "(" [] [], + args: JsCallArgumentList [], + r_paren_token: R_PAREN@98..99 ")" [] [], + }, + }, + }, + ], + abstract_token: ABSTRACT_KW@99..114 "abstract" [Newline("\n"), Whitespace(" ")] [Whitespace(" ")], + class_token: CLASS_KW@114..120 "class" [] [Whitespace(" ")], + id: JsIdentifierBinding { + name_token: IDENT@120..124 "Bar" [] [Whitespace(" ")], + }, + type_parameters: missing (optional), + extends_clause: missing (optional), + implements_clause: missing (optional), + l_curly_token: L_CURLY@124..125 "{" [] [], + members: JsClassMemberList [], + r_curly_token: R_CURLY@125..126 "}" [] [], + }, + ], + r_curly_token: R_CURLY@126..128 "}" [Newline("\n")] [], + }, + }, + ], + eof_token: EOF@128..129 "" [Newline("\n")] [], +} + +0: JS_MODULE@0..129 + 0: (empty) + 1: JS_DIRECTIVE_LIST@0..0 + 2: JS_MODULE_ITEM_LIST@0..128 + 0: JS_FUNCTION_DECLARATION@0..128 + 0: (empty) + 1: FUNCTION_KW@0..9 "function" [] [Whitespace(" ")] + 2: (empty) + 3: JS_IDENTIFIER_BINDING@9..12 + 0: IDENT@9..12 "foo" [] [] + 4: (empty) + 5: JS_PARAMETERS@12..15 + 0: L_PAREN@12..13 "(" [] [] + 1: JS_PARAMETER_LIST@13..13 + 2: R_PAREN@13..15 ")" [] [Whitespace(" ")] + 6: (empty) + 7: JS_FUNCTION_BODY@15..128 + 0: L_CURLY@15..16 "{" [] [] + 1: JS_DIRECTIVE_LIST@16..16 + 2: JS_STATEMENT_LIST@16..126 + 0: JS_CLASS_DECLARATION@16..52 + 0: JS_DECORATOR_LIST@16..33 + 0: JS_DECORATOR@16..33 + 0: AT@16..23 "@" [Newline("\n"), Whitespace(" ")] [] + 1: JS_IDENTIFIER_EXPRESSION@23..33 + 0: JS_REFERENCE_IDENTIFIER@23..33 + 0: IDENT@23..33 "decorator" [] [Whitespace(" ")] + 1: ABSTRACT_KW@33..42 "abstract" [] [Whitespace(" ")] + 2: CLASS_KW@42..48 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@48..50 + 0: IDENT@48..50 "A" [] [Whitespace(" ")] + 4: (empty) + 5: (empty) + 6: (empty) + 7: L_CURLY@50..51 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@51..51 + 9: R_CURLY@51..52 "}" [] [] + 1: JS_CLASS_DECLARATION@52..126 + 0: JS_DECORATOR_LIST@52..99 + 0: JS_DECORATOR@52..71 + 0: AT@52..59 "@" [Newline("\n"), Whitespace(" ")] [] + 1: JS_STATIC_MEMBER_EXPRESSION@59..71 + 0: JS_IDENTIFIER_EXPRESSION@59..64 + 0: JS_REFERENCE_IDENTIFIER@59..64 + 0: IDENT@59..64 "first" [] [] + 1: DOT@64..65 "." [] [] + 2: JS_NAME@65..71 + 0: IDENT@65..71 "field" [] [Whitespace(" ")] + 1: JS_DECORATOR@71..79 + 0: AT@71..72 "@" [] [] + 1: JS_IDENTIFIER_EXPRESSION@72..79 + 0: JS_REFERENCE_IDENTIFIER@72..79 + 0: IDENT@72..79 "second" [] [Whitespace(" ")] + 2: JS_DECORATOR@79..99 + 0: AT@79..80 "@" [] [] + 1: JS_CALL_EXPRESSION@80..99 + 0: JS_PARENTHESIZED_EXPRESSION@80..97 + 0: L_PAREN@80..81 "(" [] [] + 1: JS_ARROW_FUNCTION_EXPRESSION@81..96 + 0: (empty) + 1: (empty) + 2: JS_PARAMETERS@81..84 + 0: L_PAREN@81..82 "(" [] [] + 1: JS_PARAMETER_LIST@82..82 + 2: R_PAREN@82..84 ")" [] [Whitespace(" ")] + 3: (empty) + 4: FAT_ARROW@84..87 "=>" [] [Whitespace(" ")] + 5: JS_IDENTIFIER_EXPRESSION@87..96 + 0: JS_REFERENCE_IDENTIFIER@87..96 + 0: IDENT@87..96 "decorator" [] [] + 2: R_PAREN@96..97 ")" [] [] + 1: (empty) + 2: (empty) + 3: JS_CALL_ARGUMENTS@97..99 + 0: L_PAREN@97..98 "(" [] [] + 1: JS_CALL_ARGUMENT_LIST@98..98 + 2: R_PAREN@98..99 ")" [] [] + 1: ABSTRACT_KW@99..114 "abstract" [Newline("\n"), Whitespace(" ")] [Whitespace(" ")] + 2: CLASS_KW@114..120 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@120..124 + 0: IDENT@120..124 "Bar" [] [Whitespace(" ")] + 4: (empty) + 5: (empty) + 6: (empty) + 7: L_CURLY@124..125 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@125..125 + 9: R_CURLY@125..126 "}" [] [] + 3: R_CURLY@126..128 "}" [Newline("\n")] [] + 3: EOF@128..129 "" [Newline("\n")] [] diff --git a/crates/rome_js_parser/test_data/inline/ok/decorator_abstract_class_declaration.ts b/crates/rome_js_parser/test_data/inline/ok/decorator_abstract_class_declaration.ts new file mode 100644 index 00000000000..dc1bd59b000 --- /dev/null +++ b/crates/rome_js_parser/test_data/inline/ok/decorator_abstract_class_declaration.ts @@ -0,0 +1,5 @@ +function foo() { + @decorator abstract class A {} + @first.field @second @(() => decorator)() + abstract class Bar {} +} diff --git a/crates/rome_js_parser/test_data/inline/ok/decorator_abstract_class_declaration_top_level.rast b/crates/rome_js_parser/test_data/inline/ok/decorator_abstract_class_declaration_top_level.rast new file mode 100644 index 00000000000..a7652614e62 --- /dev/null +++ b/crates/rome_js_parser/test_data/inline/ok/decorator_abstract_class_declaration_top_level.rast @@ -0,0 +1,172 @@ +JsModule { + interpreter_token: missing (optional), + directives: JsDirectiveList [], + items: JsModuleItemList [ + JsClassDeclaration { + decorators: JsDecoratorList [ + JsDecorator { + at_token: AT@0..1 "@" [] [], + expression: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@1..11 "decorator" [] [Whitespace(" ")], + }, + }, + }, + ], + abstract_token: ABSTRACT_KW@11..20 "abstract" [] [Whitespace(" ")], + class_token: CLASS_KW@20..26 "class" [] [Whitespace(" ")], + id: JsIdentifierBinding { + name_token: IDENT@26..28 "A" [] [Whitespace(" ")], + }, + type_parameters: missing (optional), + extends_clause: missing (optional), + implements_clause: missing (optional), + l_curly_token: L_CURLY@28..29 "{" [] [], + members: JsClassMemberList [], + r_curly_token: R_CURLY@29..30 "}" [] [], + }, + JsClassDeclaration { + decorators: JsDecoratorList [ + JsDecorator { + at_token: AT@30..32 "@" [Newline("\n")] [], + expression: JsStaticMemberExpression { + object: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@32..37 "first" [] [], + }, + }, + operator_token: DOT@37..38 "." [] [], + member: JsName { + value_token: IDENT@38..44 "field" [] [Whitespace(" ")], + }, + }, + }, + JsDecorator { + at_token: AT@44..45 "@" [] [], + expression: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@45..52 "second" [] [Whitespace(" ")], + }, + }, + }, + JsDecorator { + at_token: AT@52..53 "@" [] [], + expression: JsCallExpression { + callee: JsParenthesizedExpression { + l_paren_token: L_PAREN@53..54 "(" [] [], + expression: JsArrowFunctionExpression { + async_token: missing (optional), + type_parameters: missing (optional), + parameters: JsParameters { + l_paren_token: L_PAREN@54..55 "(" [] [], + items: JsParameterList [], + r_paren_token: R_PAREN@55..57 ")" [] [Whitespace(" ")], + }, + return_type_annotation: missing (optional), + fat_arrow_token: FAT_ARROW@57..60 "=>" [] [Whitespace(" ")], + body: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@60..69 "decorator" [] [], + }, + }, + }, + r_paren_token: R_PAREN@69..70 ")" [] [], + }, + optional_chain_token: missing (optional), + type_arguments: missing (optional), + arguments: JsCallArguments { + l_paren_token: L_PAREN@70..71 "(" [] [], + args: JsCallArgumentList [], + r_paren_token: R_PAREN@71..72 ")" [] [], + }, + }, + }, + ], + abstract_token: ABSTRACT_KW@72..82 "abstract" [Newline("\n")] [Whitespace(" ")], + class_token: CLASS_KW@82..88 "class" [] [Whitespace(" ")], + id: JsIdentifierBinding { + name_token: IDENT@88..92 "Bar" [] [Whitespace(" ")], + }, + type_parameters: missing (optional), + extends_clause: missing (optional), + implements_clause: missing (optional), + l_curly_token: L_CURLY@92..93 "{" [] [], + members: JsClassMemberList [], + r_curly_token: R_CURLY@93..94 "}" [] [], + }, + ], + eof_token: EOF@94..95 "" [Newline("\n")] [], +} + +0: JS_MODULE@0..95 + 0: (empty) + 1: JS_DIRECTIVE_LIST@0..0 + 2: JS_MODULE_ITEM_LIST@0..94 + 0: JS_CLASS_DECLARATION@0..30 + 0: JS_DECORATOR_LIST@0..11 + 0: JS_DECORATOR@0..11 + 0: AT@0..1 "@" [] [] + 1: JS_IDENTIFIER_EXPRESSION@1..11 + 0: JS_REFERENCE_IDENTIFIER@1..11 + 0: IDENT@1..11 "decorator" [] [Whitespace(" ")] + 1: ABSTRACT_KW@11..20 "abstract" [] [Whitespace(" ")] + 2: CLASS_KW@20..26 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@26..28 + 0: IDENT@26..28 "A" [] [Whitespace(" ")] + 4: (empty) + 5: (empty) + 6: (empty) + 7: L_CURLY@28..29 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@29..29 + 9: R_CURLY@29..30 "}" [] [] + 1: JS_CLASS_DECLARATION@30..94 + 0: JS_DECORATOR_LIST@30..72 + 0: JS_DECORATOR@30..44 + 0: AT@30..32 "@" [Newline("\n")] [] + 1: JS_STATIC_MEMBER_EXPRESSION@32..44 + 0: JS_IDENTIFIER_EXPRESSION@32..37 + 0: JS_REFERENCE_IDENTIFIER@32..37 + 0: IDENT@32..37 "first" [] [] + 1: DOT@37..38 "." [] [] + 2: JS_NAME@38..44 + 0: IDENT@38..44 "field" [] [Whitespace(" ")] + 1: JS_DECORATOR@44..52 + 0: AT@44..45 "@" [] [] + 1: JS_IDENTIFIER_EXPRESSION@45..52 + 0: JS_REFERENCE_IDENTIFIER@45..52 + 0: IDENT@45..52 "second" [] [Whitespace(" ")] + 2: JS_DECORATOR@52..72 + 0: AT@52..53 "@" [] [] + 1: JS_CALL_EXPRESSION@53..72 + 0: JS_PARENTHESIZED_EXPRESSION@53..70 + 0: L_PAREN@53..54 "(" [] [] + 1: JS_ARROW_FUNCTION_EXPRESSION@54..69 + 0: (empty) + 1: (empty) + 2: JS_PARAMETERS@54..57 + 0: L_PAREN@54..55 "(" [] [] + 1: JS_PARAMETER_LIST@55..55 + 2: R_PAREN@55..57 ")" [] [Whitespace(" ")] + 3: (empty) + 4: FAT_ARROW@57..60 "=>" [] [Whitespace(" ")] + 5: JS_IDENTIFIER_EXPRESSION@60..69 + 0: JS_REFERENCE_IDENTIFIER@60..69 + 0: IDENT@60..69 "decorator" [] [] + 2: R_PAREN@69..70 ")" [] [] + 1: (empty) + 2: (empty) + 3: JS_CALL_ARGUMENTS@70..72 + 0: L_PAREN@70..71 "(" [] [] + 1: JS_CALL_ARGUMENT_LIST@71..71 + 2: R_PAREN@71..72 ")" [] [] + 1: ABSTRACT_KW@72..82 "abstract" [Newline("\n")] [Whitespace(" ")] + 2: CLASS_KW@82..88 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@88..92 + 0: IDENT@88..92 "Bar" [] [Whitespace(" ")] + 4: (empty) + 5: (empty) + 6: (empty) + 7: L_CURLY@92..93 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@93..93 + 9: R_CURLY@93..94 "}" [] [] + 3: EOF@94..95 "" [Newline("\n")] [] diff --git a/crates/rome_js_parser/test_data/inline/ok/decorator_abstract_class_declaration_top_level.ts b/crates/rome_js_parser/test_data/inline/ok/decorator_abstract_class_declaration_top_level.ts new file mode 100644 index 00000000000..28535f438b4 --- /dev/null +++ b/crates/rome_js_parser/test_data/inline/ok/decorator_abstract_class_declaration_top_level.ts @@ -0,0 +1,3 @@ +@decorator abstract class A {} +@first.field @second @(() => decorator)() +abstract class Bar {} diff --git a/crates/rome_js_parser/test_data/inline/ok/decorator_class_declaration.js b/crates/rome_js_parser/test_data/inline/ok/decorator_class_declaration.js new file mode 100644 index 00000000000..1ec127cdd16 --- /dev/null +++ b/crates/rome_js_parser/test_data/inline/ok/decorator_class_declaration.js @@ -0,0 +1,6 @@ +function foo() { + @decorator + class Foo { } + @first.field @second @(() => decorator)() + class Bar {} +} diff --git a/crates/rome_js_parser/test_data/inline/ok/decorator_class_declaration.rast b/crates/rome_js_parser/test_data/inline/ok/decorator_class_declaration.rast new file mode 100644 index 00000000000..aff67517311 --- /dev/null +++ b/crates/rome_js_parser/test_data/inline/ok/decorator_class_declaration.rast @@ -0,0 +1,211 @@ +JsModule { + interpreter_token: missing (optional), + directives: JsDirectiveList [], + items: JsModuleItemList [ + JsFunctionDeclaration { + async_token: missing (optional), + function_token: FUNCTION_KW@0..9 "function" [] [Whitespace(" ")], + star_token: missing (optional), + id: JsIdentifierBinding { + name_token: IDENT@9..12 "foo" [] [], + }, + type_parameters: missing (optional), + parameters: JsParameters { + l_paren_token: L_PAREN@12..13 "(" [] [], + items: JsParameterList [], + r_paren_token: R_PAREN@13..15 ")" [] [Whitespace(" ")], + }, + return_type_annotation: missing (optional), + body: JsFunctionBody { + l_curly_token: L_CURLY@15..16 "{" [] [], + directives: JsDirectiveList [], + statements: JsStatementList [ + JsClassDeclaration { + decorators: JsDecoratorList [ + JsDecorator { + at_token: AT@16..23 "@" [Newline("\n"), Whitespace(" ")] [], + expression: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@23..32 "decorator" [] [], + }, + }, + }, + ], + abstract_token: missing (optional), + class_token: CLASS_KW@32..44 "class" [Newline("\n"), Whitespace(" ")] [Whitespace(" ")], + id: JsIdentifierBinding { + name_token: IDENT@44..48 "Foo" [] [Whitespace(" ")], + }, + type_parameters: missing (optional), + extends_clause: missing (optional), + implements_clause: missing (optional), + l_curly_token: L_CURLY@48..50 "{" [] [Whitespace(" ")], + members: JsClassMemberList [], + r_curly_token: R_CURLY@50..51 "}" [] [], + }, + JsClassDeclaration { + decorators: JsDecoratorList [ + JsDecorator { + at_token: AT@51..58 "@" [Newline("\n"), Whitespace(" ")] [], + expression: JsStaticMemberExpression { + object: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@58..63 "first" [] [], + }, + }, + operator_token: DOT@63..64 "." [] [], + member: JsName { + value_token: IDENT@64..70 "field" [] [Whitespace(" ")], + }, + }, + }, + JsDecorator { + at_token: AT@70..71 "@" [] [], + expression: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@71..78 "second" [] [Whitespace(" ")], + }, + }, + }, + JsDecorator { + at_token: AT@78..79 "@" [] [], + expression: JsCallExpression { + callee: JsParenthesizedExpression { + l_paren_token: L_PAREN@79..80 "(" [] [], + expression: JsArrowFunctionExpression { + async_token: missing (optional), + type_parameters: missing (optional), + parameters: JsParameters { + l_paren_token: L_PAREN@80..81 "(" [] [], + items: JsParameterList [], + r_paren_token: R_PAREN@81..83 ")" [] [Whitespace(" ")], + }, + return_type_annotation: missing (optional), + fat_arrow_token: FAT_ARROW@83..86 "=>" [] [Whitespace(" ")], + body: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@86..95 "decorator" [] [], + }, + }, + }, + r_paren_token: R_PAREN@95..96 ")" [] [], + }, + optional_chain_token: missing (optional), + type_arguments: missing (optional), + arguments: JsCallArguments { + l_paren_token: L_PAREN@96..97 "(" [] [], + args: JsCallArgumentList [], + r_paren_token: R_PAREN@97..98 ")" [] [], + }, + }, + }, + ], + abstract_token: missing (optional), + class_token: CLASS_KW@98..110 "class" [Newline("\n"), Whitespace(" ")] [Whitespace(" ")], + id: JsIdentifierBinding { + name_token: IDENT@110..114 "Bar" [] [Whitespace(" ")], + }, + type_parameters: missing (optional), + extends_clause: missing (optional), + implements_clause: missing (optional), + l_curly_token: L_CURLY@114..115 "{" [] [], + members: JsClassMemberList [], + r_curly_token: R_CURLY@115..116 "}" [] [], + }, + ], + r_curly_token: R_CURLY@116..118 "}" [Newline("\n")] [], + }, + }, + ], + eof_token: EOF@118..119 "" [Newline("\n")] [], +} + +0: JS_MODULE@0..119 + 0: (empty) + 1: JS_DIRECTIVE_LIST@0..0 + 2: JS_MODULE_ITEM_LIST@0..118 + 0: JS_FUNCTION_DECLARATION@0..118 + 0: (empty) + 1: FUNCTION_KW@0..9 "function" [] [Whitespace(" ")] + 2: (empty) + 3: JS_IDENTIFIER_BINDING@9..12 + 0: IDENT@9..12 "foo" [] [] + 4: (empty) + 5: JS_PARAMETERS@12..15 + 0: L_PAREN@12..13 "(" [] [] + 1: JS_PARAMETER_LIST@13..13 + 2: R_PAREN@13..15 ")" [] [Whitespace(" ")] + 6: (empty) + 7: JS_FUNCTION_BODY@15..118 + 0: L_CURLY@15..16 "{" [] [] + 1: JS_DIRECTIVE_LIST@16..16 + 2: JS_STATEMENT_LIST@16..116 + 0: JS_CLASS_DECLARATION@16..51 + 0: JS_DECORATOR_LIST@16..32 + 0: JS_DECORATOR@16..32 + 0: AT@16..23 "@" [Newline("\n"), Whitespace(" ")] [] + 1: JS_IDENTIFIER_EXPRESSION@23..32 + 0: JS_REFERENCE_IDENTIFIER@23..32 + 0: IDENT@23..32 "decorator" [] [] + 1: (empty) + 2: CLASS_KW@32..44 "class" [Newline("\n"), Whitespace(" ")] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@44..48 + 0: IDENT@44..48 "Foo" [] [Whitespace(" ")] + 4: (empty) + 5: (empty) + 6: (empty) + 7: L_CURLY@48..50 "{" [] [Whitespace(" ")] + 8: JS_CLASS_MEMBER_LIST@50..50 + 9: R_CURLY@50..51 "}" [] [] + 1: JS_CLASS_DECLARATION@51..116 + 0: JS_DECORATOR_LIST@51..98 + 0: JS_DECORATOR@51..70 + 0: AT@51..58 "@" [Newline("\n"), Whitespace(" ")] [] + 1: JS_STATIC_MEMBER_EXPRESSION@58..70 + 0: JS_IDENTIFIER_EXPRESSION@58..63 + 0: JS_REFERENCE_IDENTIFIER@58..63 + 0: IDENT@58..63 "first" [] [] + 1: DOT@63..64 "." [] [] + 2: JS_NAME@64..70 + 0: IDENT@64..70 "field" [] [Whitespace(" ")] + 1: JS_DECORATOR@70..78 + 0: AT@70..71 "@" [] [] + 1: JS_IDENTIFIER_EXPRESSION@71..78 + 0: JS_REFERENCE_IDENTIFIER@71..78 + 0: IDENT@71..78 "second" [] [Whitespace(" ")] + 2: JS_DECORATOR@78..98 + 0: AT@78..79 "@" [] [] + 1: JS_CALL_EXPRESSION@79..98 + 0: JS_PARENTHESIZED_EXPRESSION@79..96 + 0: L_PAREN@79..80 "(" [] [] + 1: JS_ARROW_FUNCTION_EXPRESSION@80..95 + 0: (empty) + 1: (empty) + 2: JS_PARAMETERS@80..83 + 0: L_PAREN@80..81 "(" [] [] + 1: JS_PARAMETER_LIST@81..81 + 2: R_PAREN@81..83 ")" [] [Whitespace(" ")] + 3: (empty) + 4: FAT_ARROW@83..86 "=>" [] [Whitespace(" ")] + 5: JS_IDENTIFIER_EXPRESSION@86..95 + 0: JS_REFERENCE_IDENTIFIER@86..95 + 0: IDENT@86..95 "decorator" [] [] + 2: R_PAREN@95..96 ")" [] [] + 1: (empty) + 2: (empty) + 3: JS_CALL_ARGUMENTS@96..98 + 0: L_PAREN@96..97 "(" [] [] + 1: JS_CALL_ARGUMENT_LIST@97..97 + 2: R_PAREN@97..98 ")" [] [] + 1: (empty) + 2: CLASS_KW@98..110 "class" [Newline("\n"), Whitespace(" ")] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@110..114 + 0: IDENT@110..114 "Bar" [] [Whitespace(" ")] + 4: (empty) + 5: (empty) + 6: (empty) + 7: L_CURLY@114..115 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@115..115 + 9: R_CURLY@115..116 "}" [] [] + 3: R_CURLY@116..118 "}" [Newline("\n")] [] + 3: EOF@118..119 "" [Newline("\n")] [] diff --git a/crates/rome_js_parser/test_data/inline/ok/decorator_class_declaration_top_level.js b/crates/rome_js_parser/test_data/inline/ok/decorator_class_declaration_top_level.js new file mode 100644 index 00000000000..e8a8355cb7e --- /dev/null +++ b/crates/rome_js_parser/test_data/inline/ok/decorator_class_declaration_top_level.js @@ -0,0 +1,4 @@ +@decorator +class Foo { } +@first.field @second @(() => decorator)() +class Bar {} diff --git a/crates/rome_js_parser/test_data/inline/ok/decorator_class_declaration_top_level.rast b/crates/rome_js_parser/test_data/inline/ok/decorator_class_declaration_top_level.rast new file mode 100644 index 00000000000..f40fdd3ffcc --- /dev/null +++ b/crates/rome_js_parser/test_data/inline/ok/decorator_class_declaration_top_level.rast @@ -0,0 +1,172 @@ +JsModule { + interpreter_token: missing (optional), + directives: JsDirectiveList [], + items: JsModuleItemList [ + JsClassDeclaration { + decorators: JsDecoratorList [ + JsDecorator { + at_token: AT@0..1 "@" [] [], + expression: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@1..10 "decorator" [] [], + }, + }, + }, + ], + abstract_token: missing (optional), + class_token: CLASS_KW@10..17 "class" [Newline("\n")] [Whitespace(" ")], + id: JsIdentifierBinding { + name_token: IDENT@17..21 "Foo" [] [Whitespace(" ")], + }, + type_parameters: missing (optional), + extends_clause: missing (optional), + implements_clause: missing (optional), + l_curly_token: L_CURLY@21..23 "{" [] [Whitespace(" ")], + members: JsClassMemberList [], + r_curly_token: R_CURLY@23..24 "}" [] [], + }, + JsClassDeclaration { + decorators: JsDecoratorList [ + JsDecorator { + at_token: AT@24..26 "@" [Newline("\n")] [], + expression: JsStaticMemberExpression { + object: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@26..31 "first" [] [], + }, + }, + operator_token: DOT@31..32 "." [] [], + member: JsName { + value_token: IDENT@32..38 "field" [] [Whitespace(" ")], + }, + }, + }, + JsDecorator { + at_token: AT@38..39 "@" [] [], + expression: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@39..46 "second" [] [Whitespace(" ")], + }, + }, + }, + JsDecorator { + at_token: AT@46..47 "@" [] [], + expression: JsCallExpression { + callee: JsParenthesizedExpression { + l_paren_token: L_PAREN@47..48 "(" [] [], + expression: JsArrowFunctionExpression { + async_token: missing (optional), + type_parameters: missing (optional), + parameters: JsParameters { + l_paren_token: L_PAREN@48..49 "(" [] [], + items: JsParameterList [], + r_paren_token: R_PAREN@49..51 ")" [] [Whitespace(" ")], + }, + return_type_annotation: missing (optional), + fat_arrow_token: FAT_ARROW@51..54 "=>" [] [Whitespace(" ")], + body: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@54..63 "decorator" [] [], + }, + }, + }, + r_paren_token: R_PAREN@63..64 ")" [] [], + }, + optional_chain_token: missing (optional), + type_arguments: missing (optional), + arguments: JsCallArguments { + l_paren_token: L_PAREN@64..65 "(" [] [], + args: JsCallArgumentList [], + r_paren_token: R_PAREN@65..66 ")" [] [], + }, + }, + }, + ], + abstract_token: missing (optional), + class_token: CLASS_KW@66..73 "class" [Newline("\n")] [Whitespace(" ")], + id: JsIdentifierBinding { + name_token: IDENT@73..77 "Bar" [] [Whitespace(" ")], + }, + type_parameters: missing (optional), + extends_clause: missing (optional), + implements_clause: missing (optional), + l_curly_token: L_CURLY@77..78 "{" [] [], + members: JsClassMemberList [], + r_curly_token: R_CURLY@78..79 "}" [] [], + }, + ], + eof_token: EOF@79..80 "" [Newline("\n")] [], +} + +0: JS_MODULE@0..80 + 0: (empty) + 1: JS_DIRECTIVE_LIST@0..0 + 2: JS_MODULE_ITEM_LIST@0..79 + 0: JS_CLASS_DECLARATION@0..24 + 0: JS_DECORATOR_LIST@0..10 + 0: JS_DECORATOR@0..10 + 0: AT@0..1 "@" [] [] + 1: JS_IDENTIFIER_EXPRESSION@1..10 + 0: JS_REFERENCE_IDENTIFIER@1..10 + 0: IDENT@1..10 "decorator" [] [] + 1: (empty) + 2: CLASS_KW@10..17 "class" [Newline("\n")] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@17..21 + 0: IDENT@17..21 "Foo" [] [Whitespace(" ")] + 4: (empty) + 5: (empty) + 6: (empty) + 7: L_CURLY@21..23 "{" [] [Whitespace(" ")] + 8: JS_CLASS_MEMBER_LIST@23..23 + 9: R_CURLY@23..24 "}" [] [] + 1: JS_CLASS_DECLARATION@24..79 + 0: JS_DECORATOR_LIST@24..66 + 0: JS_DECORATOR@24..38 + 0: AT@24..26 "@" [Newline("\n")] [] + 1: JS_STATIC_MEMBER_EXPRESSION@26..38 + 0: JS_IDENTIFIER_EXPRESSION@26..31 + 0: JS_REFERENCE_IDENTIFIER@26..31 + 0: IDENT@26..31 "first" [] [] + 1: DOT@31..32 "." [] [] + 2: JS_NAME@32..38 + 0: IDENT@32..38 "field" [] [Whitespace(" ")] + 1: JS_DECORATOR@38..46 + 0: AT@38..39 "@" [] [] + 1: JS_IDENTIFIER_EXPRESSION@39..46 + 0: JS_REFERENCE_IDENTIFIER@39..46 + 0: IDENT@39..46 "second" [] [Whitespace(" ")] + 2: JS_DECORATOR@46..66 + 0: AT@46..47 "@" [] [] + 1: JS_CALL_EXPRESSION@47..66 + 0: JS_PARENTHESIZED_EXPRESSION@47..64 + 0: L_PAREN@47..48 "(" [] [] + 1: JS_ARROW_FUNCTION_EXPRESSION@48..63 + 0: (empty) + 1: (empty) + 2: JS_PARAMETERS@48..51 + 0: L_PAREN@48..49 "(" [] [] + 1: JS_PARAMETER_LIST@49..49 + 2: R_PAREN@49..51 ")" [] [Whitespace(" ")] + 3: (empty) + 4: FAT_ARROW@51..54 "=>" [] [Whitespace(" ")] + 5: JS_IDENTIFIER_EXPRESSION@54..63 + 0: JS_REFERENCE_IDENTIFIER@54..63 + 0: IDENT@54..63 "decorator" [] [] + 2: R_PAREN@63..64 ")" [] [] + 1: (empty) + 2: (empty) + 3: JS_CALL_ARGUMENTS@64..66 + 0: L_PAREN@64..65 "(" [] [] + 1: JS_CALL_ARGUMENT_LIST@65..65 + 2: R_PAREN@65..66 ")" [] [] + 1: (empty) + 2: CLASS_KW@66..73 "class" [Newline("\n")] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@73..77 + 0: IDENT@73..77 "Bar" [] [Whitespace(" ")] + 4: (empty) + 5: (empty) + 6: (empty) + 7: L_CURLY@77..78 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@78..78 + 9: R_CURLY@78..79 "}" [] [] + 3: EOF@79..80 "" [Newline("\n")] [] diff --git a/crates/rome_js_parser/test_data/inline/ok/decorator_class_not_top_level.rast b/crates/rome_js_parser/test_data/inline/ok/decorator_class_not_top_level.rast new file mode 100644 index 00000000000..3fc11903524 --- /dev/null +++ b/crates/rome_js_parser/test_data/inline/ok/decorator_class_not_top_level.rast @@ -0,0 +1,161 @@ +JsModule { + interpreter_token: missing (optional), + directives: JsDirectiveList [], + items: JsModuleItemList [ + JsIfStatement { + if_token: IF_KW@0..3 "if" [] [Whitespace(" ")], + l_paren_token: L_PAREN@3..4 "(" [] [], + test: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@4..5 "a" [] [], + }, + }, + r_paren_token: R_PAREN@5..7 ")" [] [Whitespace(" ")], + consequent: JsBlockStatement { + l_curly_token: L_CURLY@7..8 "{" [] [], + statements: JsStatementList [ + JsClassDeclaration { + decorators: JsDecoratorList [ + JsDecorator { + at_token: AT@8..12 "@" [Newline("\n"), Whitespace(" ")] [], + expression: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@12..16 "dec" [] [Whitespace(" ")], + }, + }, + }, + ], + abstract_token: missing (optional), + class_token: CLASS_KW@16..22 "class" [] [Whitespace(" ")], + id: JsIdentifierBinding { + name_token: IDENT@22..30 "MyClass" [] [Whitespace(" ")], + }, + type_parameters: missing (optional), + extends_clause: missing (optional), + implements_clause: missing (optional), + l_curly_token: L_CURLY@30..31 "{" [] [], + members: JsClassMemberList [], + r_curly_token: R_CURLY@31..32 "}" [] [], + }, + ], + r_curly_token: R_CURLY@32..34 "}" [Newline("\n")] [], + }, + else_clause: missing (optional), + }, + JsFunctionDeclaration { + async_token: missing (optional), + function_token: FUNCTION_KW@34..44 "function" [Newline("\n")] [Whitespace(" ")], + star_token: missing (optional), + id: JsIdentifierBinding { + name_token: IDENT@44..47 "foo" [] [], + }, + type_parameters: missing (optional), + parameters: JsParameters { + l_paren_token: L_PAREN@47..48 "(" [] [], + items: JsParameterList [], + r_paren_token: R_PAREN@48..50 ")" [] [Whitespace(" ")], + }, + return_type_annotation: missing (optional), + body: JsFunctionBody { + l_curly_token: L_CURLY@50..51 "{" [] [], + directives: JsDirectiveList [], + statements: JsStatementList [ + JsClassDeclaration { + decorators: JsDecoratorList [ + JsDecorator { + at_token: AT@51..55 "@" [Newline("\n"), Whitespace(" ")] [], + expression: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@55..59 "dec" [] [Whitespace(" ")], + }, + }, + }, + ], + abstract_token: missing (optional), + class_token: CLASS_KW@59..65 "class" [] [Whitespace(" ")], + id: JsIdentifierBinding { + name_token: IDENT@65..73 "MyClass" [] [Whitespace(" ")], + }, + type_parameters: missing (optional), + extends_clause: missing (optional), + implements_clause: missing (optional), + l_curly_token: L_CURLY@73..74 "{" [] [], + members: JsClassMemberList [], + r_curly_token: R_CURLY@74..75 "}" [] [], + }, + ], + r_curly_token: R_CURLY@75..77 "}" [Newline("\n")] [], + }, + }, + ], + eof_token: EOF@77..78 "" [Newline("\n")] [], +} + +0: JS_MODULE@0..78 + 0: (empty) + 1: JS_DIRECTIVE_LIST@0..0 + 2: JS_MODULE_ITEM_LIST@0..77 + 0: JS_IF_STATEMENT@0..34 + 0: IF_KW@0..3 "if" [] [Whitespace(" ")] + 1: L_PAREN@3..4 "(" [] [] + 2: JS_IDENTIFIER_EXPRESSION@4..5 + 0: JS_REFERENCE_IDENTIFIER@4..5 + 0: IDENT@4..5 "a" [] [] + 3: R_PAREN@5..7 ")" [] [Whitespace(" ")] + 4: JS_BLOCK_STATEMENT@7..34 + 0: L_CURLY@7..8 "{" [] [] + 1: JS_STATEMENT_LIST@8..32 + 0: JS_CLASS_DECLARATION@8..32 + 0: JS_DECORATOR_LIST@8..16 + 0: JS_DECORATOR@8..16 + 0: AT@8..12 "@" [Newline("\n"), Whitespace(" ")] [] + 1: JS_IDENTIFIER_EXPRESSION@12..16 + 0: JS_REFERENCE_IDENTIFIER@12..16 + 0: IDENT@12..16 "dec" [] [Whitespace(" ")] + 1: (empty) + 2: CLASS_KW@16..22 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@22..30 + 0: IDENT@22..30 "MyClass" [] [Whitespace(" ")] + 4: (empty) + 5: (empty) + 6: (empty) + 7: L_CURLY@30..31 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@31..31 + 9: R_CURLY@31..32 "}" [] [] + 2: R_CURLY@32..34 "}" [Newline("\n")] [] + 5: (empty) + 1: JS_FUNCTION_DECLARATION@34..77 + 0: (empty) + 1: FUNCTION_KW@34..44 "function" [Newline("\n")] [Whitespace(" ")] + 2: (empty) + 3: JS_IDENTIFIER_BINDING@44..47 + 0: IDENT@44..47 "foo" [] [] + 4: (empty) + 5: JS_PARAMETERS@47..50 + 0: L_PAREN@47..48 "(" [] [] + 1: JS_PARAMETER_LIST@48..48 + 2: R_PAREN@48..50 ")" [] [Whitespace(" ")] + 6: (empty) + 7: JS_FUNCTION_BODY@50..77 + 0: L_CURLY@50..51 "{" [] [] + 1: JS_DIRECTIVE_LIST@51..51 + 2: JS_STATEMENT_LIST@51..75 + 0: JS_CLASS_DECLARATION@51..75 + 0: JS_DECORATOR_LIST@51..59 + 0: JS_DECORATOR@51..59 + 0: AT@51..55 "@" [Newline("\n"), Whitespace(" ")] [] + 1: JS_IDENTIFIER_EXPRESSION@55..59 + 0: JS_REFERENCE_IDENTIFIER@55..59 + 0: IDENT@55..59 "dec" [] [Whitespace(" ")] + 1: (empty) + 2: CLASS_KW@59..65 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@65..73 + 0: IDENT@65..73 "MyClass" [] [Whitespace(" ")] + 4: (empty) + 5: (empty) + 6: (empty) + 7: L_CURLY@73..74 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@74..74 + 9: R_CURLY@74..75 "}" [] [] + 3: R_CURLY@75..77 "}" [Newline("\n")] [] + 3: EOF@77..78 "" [Newline("\n")] [] diff --git a/crates/rome_js_parser/test_data/inline/ok/decorator_class_not_top_level.ts b/crates/rome_js_parser/test_data/inline/ok/decorator_class_not_top_level.ts new file mode 100644 index 00000000000..72c5d3288fe --- /dev/null +++ b/crates/rome_js_parser/test_data/inline/ok/decorator_class_not_top_level.ts @@ -0,0 +1,6 @@ +if (a) { + @dec class MyClass {} +} +function foo() { + @dec class MyClass {} +} diff --git a/crates/rome_js_parser/test_data/inline/ok/decorator_export_class_clause.js b/crates/rome_js_parser/test_data/inline/ok/decorator_export_class_clause.js new file mode 100644 index 00000000000..108731f86ec --- /dev/null +++ b/crates/rome_js_parser/test_data/inline/ok/decorator_export_class_clause.js @@ -0,0 +1,4 @@ +export @decorator class Bar {}; +export @first @second class Foo { + constructor() {} +} diff --git a/crates/rome_js_parser/test_data/inline/ok/decorator_export_class_clause.rast b/crates/rome_js_parser/test_data/inline/ok/decorator_export_class_clause.rast new file mode 100644 index 00000000000..9ea6367a0ed --- /dev/null +++ b/crates/rome_js_parser/test_data/inline/ok/decorator_export_class_clause.rast @@ -0,0 +1,152 @@ +JsModule { + interpreter_token: missing (optional), + directives: JsDirectiveList [], + items: JsModuleItemList [ + JsExport { + export_token: EXPORT_KW@0..7 "export" [] [Whitespace(" ")], + export_clause: JsClassDeclaration { + decorators: JsDecoratorList [ + JsDecorator { + at_token: AT@7..8 "@" [] [], + expression: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@8..18 "decorator" [] [Whitespace(" ")], + }, + }, + }, + ], + abstract_token: missing (optional), + class_token: CLASS_KW@18..24 "class" [] [Whitespace(" ")], + id: JsIdentifierBinding { + name_token: IDENT@24..28 "Bar" [] [Whitespace(" ")], + }, + type_parameters: missing (optional), + extends_clause: missing (optional), + implements_clause: missing (optional), + l_curly_token: L_CURLY@28..29 "{" [] [], + members: JsClassMemberList [], + r_curly_token: R_CURLY@29..30 "}" [] [], + }, + }, + JsEmptyStatement { + semicolon_token: SEMICOLON@30..31 ";" [] [], + }, + JsExport { + export_token: EXPORT_KW@31..39 "export" [Newline("\n")] [Whitespace(" ")], + export_clause: JsClassDeclaration { + decorators: JsDecoratorList [ + JsDecorator { + at_token: AT@39..40 "@" [] [], + expression: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@40..46 "first" [] [Whitespace(" ")], + }, + }, + }, + JsDecorator { + at_token: AT@46..47 "@" [] [], + expression: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@47..54 "second" [] [Whitespace(" ")], + }, + }, + }, + ], + abstract_token: missing (optional), + class_token: CLASS_KW@54..60 "class" [] [Whitespace(" ")], + id: JsIdentifierBinding { + name_token: IDENT@60..64 "Foo" [] [Whitespace(" ")], + }, + type_parameters: missing (optional), + extends_clause: missing (optional), + implements_clause: missing (optional), + l_curly_token: L_CURLY@64..65 "{" [] [], + members: JsClassMemberList [ + JsConstructorClassMember { + modifiers: JsConstructorModifierList [], + name: JsLiteralMemberName { + value: IDENT@65..81 "constructor" [Newline("\n"), Whitespace(" ")] [], + }, + parameters: JsConstructorParameters { + l_paren_token: L_PAREN@81..82 "(" [] [], + parameters: JsConstructorParameterList [], + r_paren_token: R_PAREN@82..84 ")" [] [Whitespace(" ")], + }, + body: JsFunctionBody { + l_curly_token: L_CURLY@84..85 "{" [] [], + directives: JsDirectiveList [], + statements: JsStatementList [], + r_curly_token: R_CURLY@85..86 "}" [] [], + }, + }, + ], + r_curly_token: R_CURLY@86..88 "}" [Newline("\n")] [], + }, + }, + ], + eof_token: EOF@88..89 "" [Newline("\n")] [], +} + +0: JS_MODULE@0..89 + 0: (empty) + 1: JS_DIRECTIVE_LIST@0..0 + 2: JS_MODULE_ITEM_LIST@0..88 + 0: JS_EXPORT@0..30 + 0: EXPORT_KW@0..7 "export" [] [Whitespace(" ")] + 1: JS_CLASS_DECLARATION@7..30 + 0: JS_DECORATOR_LIST@7..18 + 0: JS_DECORATOR@7..18 + 0: AT@7..8 "@" [] [] + 1: JS_IDENTIFIER_EXPRESSION@8..18 + 0: JS_REFERENCE_IDENTIFIER@8..18 + 0: IDENT@8..18 "decorator" [] [Whitespace(" ")] + 1: (empty) + 2: CLASS_KW@18..24 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@24..28 + 0: IDENT@24..28 "Bar" [] [Whitespace(" ")] + 4: (empty) + 5: (empty) + 6: (empty) + 7: L_CURLY@28..29 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@29..29 + 9: R_CURLY@29..30 "}" [] [] + 1: JS_EMPTY_STATEMENT@30..31 + 0: SEMICOLON@30..31 ";" [] [] + 2: JS_EXPORT@31..88 + 0: EXPORT_KW@31..39 "export" [Newline("\n")] [Whitespace(" ")] + 1: JS_CLASS_DECLARATION@39..88 + 0: JS_DECORATOR_LIST@39..54 + 0: JS_DECORATOR@39..46 + 0: AT@39..40 "@" [] [] + 1: JS_IDENTIFIER_EXPRESSION@40..46 + 0: JS_REFERENCE_IDENTIFIER@40..46 + 0: IDENT@40..46 "first" [] [Whitespace(" ")] + 1: JS_DECORATOR@46..54 + 0: AT@46..47 "@" [] [] + 1: JS_IDENTIFIER_EXPRESSION@47..54 + 0: JS_REFERENCE_IDENTIFIER@47..54 + 0: IDENT@47..54 "second" [] [Whitespace(" ")] + 1: (empty) + 2: CLASS_KW@54..60 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@60..64 + 0: IDENT@60..64 "Foo" [] [Whitespace(" ")] + 4: (empty) + 5: (empty) + 6: (empty) + 7: L_CURLY@64..65 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@65..86 + 0: JS_CONSTRUCTOR_CLASS_MEMBER@65..86 + 0: JS_CONSTRUCTOR_MODIFIER_LIST@65..65 + 1: JS_LITERAL_MEMBER_NAME@65..81 + 0: IDENT@65..81 "constructor" [Newline("\n"), Whitespace(" ")] [] + 2: JS_CONSTRUCTOR_PARAMETERS@81..84 + 0: L_PAREN@81..82 "(" [] [] + 1: JS_CONSTRUCTOR_PARAMETER_LIST@82..82 + 2: R_PAREN@82..84 ")" [] [Whitespace(" ")] + 3: JS_FUNCTION_BODY@84..86 + 0: L_CURLY@84..85 "{" [] [] + 1: JS_DIRECTIVE_LIST@85..85 + 2: JS_STATEMENT_LIST@85..85 + 3: R_CURLY@85..86 "}" [] [] + 9: R_CURLY@86..88 "}" [Newline("\n")] [] + 3: EOF@88..89 "" [Newline("\n")] [] diff --git a/crates/rome_js_parser/test_data/inline/ok/decorator_expression_class.js b/crates/rome_js_parser/test_data/inline/ok/decorator_expression_class.js new file mode 100644 index 00000000000..55997262943 --- /dev/null +++ b/crates/rome_js_parser/test_data/inline/ok/decorator_expression_class.js @@ -0,0 +1,4 @@ +let a = @decorator class {}; +let b = @first @second class foo { + constructor() {} +} diff --git a/crates/rome_js_parser/test_data/inline/ok/decorator_expression_class.rast b/crates/rome_js_parser/test_data/inline/ok/decorator_expression_class.rast new file mode 100644 index 00000000000..d13c74bec59 --- /dev/null +++ b/crates/rome_js_parser/test_data/inline/ok/decorator_expression_class.rast @@ -0,0 +1,186 @@ +JsModule { + interpreter_token: missing (optional), + directives: JsDirectiveList [], + items: JsModuleItemList [ + JsVariableStatement { + declaration: JsVariableDeclaration { + kind: LET_KW@0..4 "let" [] [Whitespace(" ")], + declarators: JsVariableDeclaratorList [ + JsVariableDeclarator { + id: JsIdentifierBinding { + name_token: IDENT@4..6 "a" [] [Whitespace(" ")], + }, + variable_annotation: missing (optional), + initializer: JsInitializerClause { + eq_token: EQ@6..8 "=" [] [Whitespace(" ")], + expression: JsClassExpression { + decorators: JsDecoratorList [ + JsDecorator { + at_token: AT@8..9 "@" [] [], + expression: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@9..19 "decorator" [] [Whitespace(" ")], + }, + }, + }, + ], + class_token: CLASS_KW@19..25 "class" [] [Whitespace(" ")], + id: missing (optional), + type_parameters: missing (optional), + extends_clause: missing (optional), + implements_clause: missing (optional), + l_curly_token: L_CURLY@25..26 "{" [] [], + members: JsClassMemberList [], + r_curly_token: R_CURLY@26..27 "}" [] [], + }, + }, + }, + ], + }, + semicolon_token: SEMICOLON@27..28 ";" [] [], + }, + JsVariableStatement { + declaration: JsVariableDeclaration { + kind: LET_KW@28..33 "let" [Newline("\n")] [Whitespace(" ")], + declarators: JsVariableDeclaratorList [ + JsVariableDeclarator { + id: JsIdentifierBinding { + name_token: IDENT@33..35 "b" [] [Whitespace(" ")], + }, + variable_annotation: missing (optional), + initializer: JsInitializerClause { + eq_token: EQ@35..37 "=" [] [Whitespace(" ")], + expression: JsClassExpression { + decorators: JsDecoratorList [ + JsDecorator { + at_token: AT@37..38 "@" [] [], + expression: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@38..44 "first" [] [Whitespace(" ")], + }, + }, + }, + JsDecorator { + at_token: AT@44..45 "@" [] [], + expression: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@45..52 "second" [] [Whitespace(" ")], + }, + }, + }, + ], + class_token: CLASS_KW@52..58 "class" [] [Whitespace(" ")], + id: JsIdentifierBinding { + name_token: IDENT@58..62 "foo" [] [Whitespace(" ")], + }, + type_parameters: missing (optional), + extends_clause: missing (optional), + implements_clause: missing (optional), + l_curly_token: L_CURLY@62..63 "{" [] [], + members: JsClassMemberList [ + JsConstructorClassMember { + modifiers: JsConstructorModifierList [], + name: JsLiteralMemberName { + value: IDENT@63..76 "constructor" [Newline("\n"), Whitespace(" ")] [], + }, + parameters: JsConstructorParameters { + l_paren_token: L_PAREN@76..77 "(" [] [], + parameters: JsConstructorParameterList [], + r_paren_token: R_PAREN@77..79 ")" [] [Whitespace(" ")], + }, + body: JsFunctionBody { + l_curly_token: L_CURLY@79..80 "{" [] [], + directives: JsDirectiveList [], + statements: JsStatementList [], + r_curly_token: R_CURLY@80..81 "}" [] [], + }, + }, + ], + r_curly_token: R_CURLY@81..83 "}" [Newline("\n")] [], + }, + }, + }, + ], + }, + semicolon_token: missing (optional), + }, + ], + eof_token: EOF@83..84 "" [Newline("\n")] [], +} + +0: JS_MODULE@0..84 + 0: (empty) + 1: JS_DIRECTIVE_LIST@0..0 + 2: JS_MODULE_ITEM_LIST@0..83 + 0: JS_VARIABLE_STATEMENT@0..28 + 0: JS_VARIABLE_DECLARATION@0..27 + 0: LET_KW@0..4 "let" [] [Whitespace(" ")] + 1: JS_VARIABLE_DECLARATOR_LIST@4..27 + 0: JS_VARIABLE_DECLARATOR@4..27 + 0: JS_IDENTIFIER_BINDING@4..6 + 0: IDENT@4..6 "a" [] [Whitespace(" ")] + 1: (empty) + 2: JS_INITIALIZER_CLAUSE@6..27 + 0: EQ@6..8 "=" [] [Whitespace(" ")] + 1: JS_CLASS_EXPRESSION@8..27 + 0: JS_DECORATOR_LIST@8..19 + 0: JS_DECORATOR@8..19 + 0: AT@8..9 "@" [] [] + 1: JS_IDENTIFIER_EXPRESSION@9..19 + 0: JS_REFERENCE_IDENTIFIER@9..19 + 0: IDENT@9..19 "decorator" [] [Whitespace(" ")] + 1: CLASS_KW@19..25 "class" [] [Whitespace(" ")] + 2: (empty) + 3: (empty) + 4: (empty) + 5: (empty) + 6: L_CURLY@25..26 "{" [] [] + 7: JS_CLASS_MEMBER_LIST@26..26 + 8: R_CURLY@26..27 "}" [] [] + 1: SEMICOLON@27..28 ";" [] [] + 1: JS_VARIABLE_STATEMENT@28..83 + 0: JS_VARIABLE_DECLARATION@28..83 + 0: LET_KW@28..33 "let" [Newline("\n")] [Whitespace(" ")] + 1: JS_VARIABLE_DECLARATOR_LIST@33..83 + 0: JS_VARIABLE_DECLARATOR@33..83 + 0: JS_IDENTIFIER_BINDING@33..35 + 0: IDENT@33..35 "b" [] [Whitespace(" ")] + 1: (empty) + 2: JS_INITIALIZER_CLAUSE@35..83 + 0: EQ@35..37 "=" [] [Whitespace(" ")] + 1: JS_CLASS_EXPRESSION@37..83 + 0: JS_DECORATOR_LIST@37..52 + 0: JS_DECORATOR@37..44 + 0: AT@37..38 "@" [] [] + 1: JS_IDENTIFIER_EXPRESSION@38..44 + 0: JS_REFERENCE_IDENTIFIER@38..44 + 0: IDENT@38..44 "first" [] [Whitespace(" ")] + 1: JS_DECORATOR@44..52 + 0: AT@44..45 "@" [] [] + 1: JS_IDENTIFIER_EXPRESSION@45..52 + 0: JS_REFERENCE_IDENTIFIER@45..52 + 0: IDENT@45..52 "second" [] [Whitespace(" ")] + 1: CLASS_KW@52..58 "class" [] [Whitespace(" ")] + 2: JS_IDENTIFIER_BINDING@58..62 + 0: IDENT@58..62 "foo" [] [Whitespace(" ")] + 3: (empty) + 4: (empty) + 5: (empty) + 6: L_CURLY@62..63 "{" [] [] + 7: JS_CLASS_MEMBER_LIST@63..81 + 0: JS_CONSTRUCTOR_CLASS_MEMBER@63..81 + 0: JS_CONSTRUCTOR_MODIFIER_LIST@63..63 + 1: JS_LITERAL_MEMBER_NAME@63..76 + 0: IDENT@63..76 "constructor" [Newline("\n"), Whitespace(" ")] [] + 2: JS_CONSTRUCTOR_PARAMETERS@76..79 + 0: L_PAREN@76..77 "(" [] [] + 1: JS_CONSTRUCTOR_PARAMETER_LIST@77..77 + 2: R_PAREN@77..79 ")" [] [Whitespace(" ")] + 3: JS_FUNCTION_BODY@79..81 + 0: L_CURLY@79..80 "{" [] [] + 1: JS_DIRECTIVE_LIST@80..80 + 2: JS_STATEMENT_LIST@80..80 + 3: R_CURLY@80..81 "}" [] [] + 8: R_CURLY@81..83 "}" [Newline("\n")] [] + 1: (empty) + 3: EOF@83..84 "" [Newline("\n")] [] diff --git a/crates/rome_js_parser/test_data/inline/ok/export_class_clause.rast b/crates/rome_js_parser/test_data/inline/ok/export_class_clause.rast index e791059434d..88191e88e52 100644 --- a/crates/rome_js_parser/test_data/inline/ok/export_class_clause.rast +++ b/crates/rome_js_parser/test_data/inline/ok/export_class_clause.rast @@ -5,6 +5,7 @@ JsModule { JsExport { export_token: EXPORT_KW@0..7 "export" [] [Whitespace(" ")], export_clause: JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@7..13 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -21,6 +22,7 @@ JsModule { JsExport { export_token: EXPORT_KW@17..25 "export" [Newline("\n")] [Whitespace(" ")], export_clause: JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@25..31 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -53,32 +55,34 @@ JsModule { 0: JS_EXPORT@0..17 0: EXPORT_KW@0..7 "export" [] [Whitespace(" ")] 1: JS_CLASS_DECLARATION@7..17 - 0: (empty) - 1: CLASS_KW@7..13 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@13..15 + 0: JS_DECORATOR_LIST@7..7 + 1: (empty) + 2: CLASS_KW@7..13 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@13..15 0: IDENT@13..15 "A" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@15..16 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@16..16 - 8: R_CURLY@16..17 "}" [] [] + 6: (empty) + 7: L_CURLY@15..16 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@16..16 + 9: R_CURLY@16..17 "}" [] [] 1: JS_EXPORT@17..45 0: EXPORT_KW@17..25 "export" [Newline("\n")] [Whitespace(" ")] 1: JS_CLASS_DECLARATION@25..45 - 0: (empty) - 1: CLASS_KW@25..31 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@31..33 + 0: JS_DECORATOR_LIST@25..25 + 1: (empty) + 2: CLASS_KW@25..31 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@31..33 0: IDENT@31..33 "A" [] [Whitespace(" ")] - 3: (empty) - 4: JS_EXTENDS_CLAUSE@33..43 + 4: (empty) + 5: JS_EXTENDS_CLAUSE@33..43 0: EXTENDS_KW@33..41 "extends" [] [Whitespace(" ")] 1: JS_IDENTIFIER_EXPRESSION@41..43 0: JS_REFERENCE_IDENTIFIER@41..43 0: IDENT@41..43 "B" [] [Whitespace(" ")] 2: (empty) - 5: (empty) - 6: L_CURLY@43..44 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@44..44 - 8: R_CURLY@44..45 "}" [] [] + 6: (empty) + 7: L_CURLY@43..44 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@44..44 + 9: R_CURLY@44..45 "}" [] [] 3: EOF@45..46 "" [Newline("\n")] [] diff --git a/crates/rome_js_parser/test_data/inline/ok/export_default_class_clause.rast b/crates/rome_js_parser/test_data/inline/ok/export_default_class_clause.rast index 3a2d9482477..9d543fd864d 100644 --- a/crates/rome_js_parser/test_data/inline/ok/export_default_class_clause.rast +++ b/crates/rome_js_parser/test_data/inline/ok/export_default_class_clause.rast @@ -7,6 +7,7 @@ JsModule { export_clause: JsExportDefaultDeclarationClause { default_token: DEFAULT_KW@7..15 "default" [] [Whitespace(" ")], declaration: JsClassExportDefaultDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@15..21 "class" [] [Whitespace(" ")], id: missing (optional), @@ -33,14 +34,15 @@ JsModule { 1: JS_EXPORT_DEFAULT_DECLARATION_CLAUSE@7..23 0: DEFAULT_KW@7..15 "default" [] [Whitespace(" ")] 1: JS_CLASS_EXPORT_DEFAULT_DECLARATION@15..23 - 0: (empty) - 1: CLASS_KW@15..21 "class" [] [Whitespace(" ")] - 2: (empty) + 0: JS_DECORATOR_LIST@15..15 + 1: (empty) + 2: CLASS_KW@15..21 "class" [] [Whitespace(" ")] 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@21..22 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@22..22 - 8: R_CURLY@22..23 "}" [] [] + 6: (empty) + 7: L_CURLY@21..22 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@22..22 + 9: R_CURLY@22..23 "}" [] [] 2: (empty) 3: EOF@23..24 "" [Newline("\n")] [] diff --git a/crates/rome_js_parser/test_data/inline/ok/getter_class_member.rast b/crates/rome_js_parser/test_data/inline/ok/getter_class_member.rast index aac21c282b1..044a8668a1b 100644 --- a/crates/rome_js_parser/test_data/inline/ok/getter_class_member.rast +++ b/crates/rome_js_parser/test_data/inline/ok/getter_class_member.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@0..6 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -144,6 +145,7 @@ JsModule { r_curly_token: R_CURLY@143..145 "}" [Newline("\n")] [], }, JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@145..152 "class" [Newline("\n")] [Whitespace(" ")], id: JsIdentifierBinding { @@ -236,15 +238,16 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..212 0: JS_CLASS_DECLARATION@0..145 - 0: (empty) - 1: CLASS_KW@0..6 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@6..14 + 0: JS_DECORATOR_LIST@0..0 + 1: (empty) + 2: CLASS_KW@0..6 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@6..14 0: IDENT@6..14 "Getters" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@14..15 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@15..143 + 6: (empty) + 7: L_CURLY@14..15 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@15..143 0: JS_GETTER_CLASS_MEMBER@15..30 0: JS_METHOD_MODIFIER_LIST@15..15 1: GET_KW@15..22 "get" [Newline("\n"), Whitespace(" ")] [Whitespace(" ")] @@ -346,17 +349,18 @@ JsModule { 1: JS_DIRECTIVE_LIST@142..142 2: JS_STATEMENT_LIST@142..142 3: R_CURLY@142..143 "}" [] [] - 8: R_CURLY@143..145 "}" [Newline("\n")] [] + 9: R_CURLY@143..145 "}" [Newline("\n")] [] 1: JS_CLASS_DECLARATION@145..212 - 0: (empty) - 1: CLASS_KW@145..152 "class" [Newline("\n")] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@152..163 + 0: JS_DECORATOR_LIST@145..145 + 1: (empty) + 2: CLASS_KW@145..152 "class" [Newline("\n")] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@152..163 0: IDENT@152..163 "NotGetters" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@163..164 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@164..210 + 6: (empty) + 7: L_CURLY@163..164 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@164..210 0: JS_METHOD_CLASS_MEMBER@164..175 0: JS_METHOD_MODIFIER_LIST@164..164 1: (empty) @@ -413,5 +417,5 @@ JsModule { 1: JS_DIRECTIVE_LIST@209..209 2: JS_STATEMENT_LIST@209..209 3: R_CURLY@209..210 "}" [] [] - 8: R_CURLY@210..212 "}" [Newline("\n")] [] + 9: R_CURLY@210..212 "}" [Newline("\n")] [] 3: EOF@212..213 "" [Newline("\n")] [] diff --git a/crates/rome_js_parser/test_data/inline/ok/js_class_property_member_modifiers.rast b/crates/rome_js_parser/test_data/inline/ok/js_class_property_member_modifiers.rast index 8a9e1382ca7..16fe2b11545 100644 --- a/crates/rome_js_parser/test_data/inline/ok/js_class_property_member_modifiers.rast +++ b/crates/rome_js_parser/test_data/inline/ok/js_class_property_member_modifiers.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@0..6 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -74,6 +75,7 @@ JsModule { r_curly_token: R_CURLY@77..79 "}" [Newline("\n")] [], }, JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@79..86 "class" [Newline("\n")] [Whitespace(" ")], id: JsIdentifierBinding { @@ -114,15 +116,16 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..114 0: JS_CLASS_DECLARATION@0..79 - 0: (empty) - 1: CLASS_KW@0..6 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@6..11 + 0: JS_DECORATOR_LIST@0..0 + 1: (empty) + 2: CLASS_KW@0..6 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@6..11 0: IDENT@6..11 "Test" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@11..12 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@12..77 + 6: (empty) + 7: L_CURLY@11..12 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@12..77 0: JS_PROPERTY_CLASS_MEMBER@12..30 0: JS_PROPERTY_MODIFIER_LIST@12..24 0: JS_STATIC_MODIFIER@12..24 @@ -161,17 +164,18 @@ JsModule { 1: JS_NUMBER_LITERAL_EXPRESSION@75..76 0: JS_NUMBER_LITERAL@75..76 "1" [] [] 4: SEMICOLON@76..77 ";" [] [] - 8: R_CURLY@77..79 "}" [Newline("\n")] [] + 9: R_CURLY@77..79 "}" [Newline("\n")] [] 1: JS_CLASS_DECLARATION@79..114 - 0: (empty) - 1: CLASS_KW@79..86 "class" [Newline("\n")] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@86..90 + 0: JS_DECORATOR_LIST@79..79 + 1: (empty) + 2: CLASS_KW@79..86 "class" [Newline("\n")] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@86..90 0: IDENT@86..90 "Foo" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@90..91 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@91..112 + 6: (empty) + 7: L_CURLY@90..91 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@91..112 0: JS_PROPERTY_CLASS_MEMBER@91..104 0: JS_PROPERTY_MODIFIER_LIST@91..91 1: JS_LITERAL_MEMBER_NAME@91..104 @@ -186,5 +190,5 @@ JsModule { 2: (empty) 3: (empty) 4: (empty) - 8: R_CURLY@112..114 "}" [Newline("\n")] [] + 9: R_CURLY@112..114 "}" [Newline("\n")] [] 3: EOF@114..115 "" [Newline("\n")] [] diff --git a/crates/rome_js_parser/test_data/inline/ok/method_class_member.rast b/crates/rome_js_parser/test_data/inline/ok/method_class_member.rast index 0ff1d41b1d2..05a58005796 100644 --- a/crates/rome_js_parser/test_data/inline/ok/method_class_member.rast +++ b/crates/rome_js_parser/test_data/inline/ok/method_class_member.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@0..6 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -204,6 +205,7 @@ JsModule { r_curly_token: R_CURLY@172..174 "}" [Newline("\n")] [], }, JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@174..181 "class" [Newline("\n")] [Whitespace(" ")], id: JsIdentifierBinding { @@ -372,6 +374,7 @@ JsModule { r_curly_token: R_CURLY@379..381 "}" [Newline("\n")] [], }, JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@381..388 "class" [Newline("\n")] [Whitespace(" ")], id: JsIdentifierBinding { @@ -602,15 +605,16 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..624 0: JS_CLASS_DECLARATION@0..174 - 0: (empty) - 1: CLASS_KW@0..6 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@6..11 + 0: JS_DECORATOR_LIST@0..0 + 1: (empty) + 2: CLASS_KW@0..6 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@6..11 0: IDENT@6..11 "Test" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@11..12 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@12..172 + 6: (empty) + 7: L_CURLY@11..12 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@12..172 0: JS_METHOD_CLASS_MEMBER@12..26 0: JS_METHOD_MODIFIER_LIST@12..12 1: (empty) @@ -763,17 +767,18 @@ JsModule { 1: JS_DIRECTIVE_LIST@171..171 2: JS_STATEMENT_LIST@171..171 3: R_CURLY@171..172 "}" [] [] - 8: R_CURLY@172..174 "}" [Newline("\n")] [] + 9: R_CURLY@172..174 "}" [Newline("\n")] [] 1: JS_CLASS_DECLARATION@174..381 - 0: (empty) - 1: CLASS_KW@174..181 "class" [Newline("\n")] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@181..200 + 0: JS_DECORATOR_LIST@174..174 + 1: (empty) + 2: CLASS_KW@174..181 "class" [Newline("\n")] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@181..200 0: IDENT@181..200 "ContextualKeywords" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@200..201 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@201..379 + 6: (empty) + 7: L_CURLY@200..201 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@201..379 0: JS_METHOD_CLASS_MEMBER@201..243 0: JS_METHOD_MODIFIER_LIST@201..201 1: (empty) @@ -900,17 +905,18 @@ JsModule { 1: JS_DIRECTIVE_LIST@357..357 2: JS_STATEMENT_LIST@357..357 3: R_CURLY@357..379 "}" [] [Whitespace(" "), Comments("// Method called set")] - 8: R_CURLY@379..381 "}" [Newline("\n")] [] + 9: R_CURLY@379..381 "}" [Newline("\n")] [] 2: JS_CLASS_DECLARATION@381..624 - 0: (empty) - 1: CLASS_KW@381..388 "class" [Newline("\n")] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@388..395 + 0: JS_DECORATOR_LIST@381..381 + 1: (empty) + 2: CLASS_KW@381..388 "class" [Newline("\n")] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@388..395 0: IDENT@388..395 "Static" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@395..396 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@396..622 + 6: (empty) + 7: L_CURLY@395..396 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@396..622 0: JS_METHOD_CLASS_MEMBER@396..417 0: JS_METHOD_MODIFIER_LIST@396..406 0: JS_STATIC_MODIFIER@396..406 @@ -1071,5 +1077,5 @@ JsModule { 1: JS_DIRECTIVE_LIST@621..621 2: JS_STATEMENT_LIST@621..621 3: R_CURLY@621..622 "}" [] [] - 8: R_CURLY@622..624 "}" [Newline("\n")] [] + 9: R_CURLY@622..624 "}" [Newline("\n")] [] 3: EOF@624..625 "" [Newline("\n")] [] diff --git a/crates/rome_js_parser/test_data/inline/ok/private_name_presence_check.rast b/crates/rome_js_parser/test_data/inline/ok/private_name_presence_check.rast index 4897f3e6091..309cb72638f 100644 --- a/crates/rome_js_parser/test_data/inline/ok/private_name_presence_check.rast +++ b/crates/rome_js_parser/test_data/inline/ok/private_name_presence_check.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@0..6 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -71,15 +72,16 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..49 0: JS_CLASS_DECLARATION@0..49 - 0: (empty) - 1: CLASS_KW@0..6 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@6..8 + 0: JS_DECORATOR_LIST@0..0 + 1: (empty) + 2: CLASS_KW@0..6 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@6..8 0: IDENT@6..8 "A" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@8..9 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@9..47 + 6: (empty) + 7: L_CURLY@8..9 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@9..47 0: JS_PROPERTY_CLASS_MEMBER@9..17 0: JS_PROPERTY_MODIFIER_LIST@9..9 1: JS_PRIVATE_CLASS_MEMBER_NAME@9..16 @@ -115,5 +117,5 @@ JsModule { 0: THIS_KW@40..44 "this" [] [] 1: (empty) 3: R_CURLY@44..47 "}" [Newline("\n"), Whitespace(" ")] [] - 8: R_CURLY@47..49 "}" [Newline("\n")] [] + 9: R_CURLY@47..49 "}" [Newline("\n")] [] 3: EOF@49..50 "" [Newline("\n")] [] diff --git a/crates/rome_js_parser/test_data/inline/ok/property_class_member.rast b/crates/rome_js_parser/test_data/inline/ok/property_class_member.rast index 78e5cd20230..f9d46a7e577 100644 --- a/crates/rome_js_parser/test_data/inline/ok/property_class_member.rast +++ b/crates/rome_js_parser/test_data/inline/ok/property_class_member.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@0..6 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -183,15 +184,16 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..261 0: JS_CLASS_DECLARATION@0..261 - 0: (empty) - 1: CLASS_KW@0..6 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@6..10 + 0: JS_DECORATOR_LIST@0..0 + 1: (empty) + 2: CLASS_KW@0..6 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@6..10 0: IDENT@6..10 "foo" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@10..11 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@11..259 + 6: (empty) + 7: L_CURLY@10..11 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@11..259 0: JS_PROPERTY_CLASS_MEMBER@11..22 0: JS_PROPERTY_MODIFIER_LIST@11..11 1: JS_LITERAL_MEMBER_NAME@11..22 @@ -307,5 +309,5 @@ JsModule { 1: JS_NUMBER_LITERAL_EXPRESSION@258..259 0: JS_NUMBER_LITERAL@258..259 "1" [] [] 4: (empty) - 8: R_CURLY@259..261 "}" [Newline("\n")] [] + 9: R_CURLY@259..261 "}" [Newline("\n")] [] 3: EOF@261..262 "" [Newline("\n")] [] diff --git a/crates/rome_js_parser/test_data/inline/ok/setter_class_member.rast b/crates/rome_js_parser/test_data/inline/ok/setter_class_member.rast index f1b89c4bc94..40cc5e84ac1 100644 --- a/crates/rome_js_parser/test_data/inline/ok/setter_class_member.rast +++ b/crates/rome_js_parser/test_data/inline/ok/setter_class_member.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@0..6 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -193,6 +194,7 @@ JsModule { r_curly_token: R_CURLY@150..152 "}" [Newline("\n")] [], }, JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@152..159 "class" [Newline("\n")] [Whitespace(" ")], id: JsIdentifierBinding { @@ -312,15 +314,16 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..222 0: JS_CLASS_DECLARATION@0..152 - 0: (empty) - 1: CLASS_KW@0..6 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@6..14 + 0: JS_DECORATOR_LIST@0..0 + 1: (empty) + 2: CLASS_KW@0..6 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@6..14 0: IDENT@6..14 "Setters" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@14..15 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@15..150 + 6: (empty) + 7: L_CURLY@14..15 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@15..150 0: JS_SETTER_CLASS_MEMBER@15..31 0: JS_METHOD_MODIFIER_LIST@15..15 1: SET_KW@15..22 "set" [Newline("\n"), Whitespace(" ")] [Whitespace(" ")] @@ -457,17 +460,18 @@ JsModule { 1: JS_DIRECTIVE_LIST@149..149 2: JS_STATEMENT_LIST@149..149 3: R_CURLY@149..150 "}" [] [] - 8: R_CURLY@150..152 "}" [Newline("\n")] [] + 9: R_CURLY@150..152 "}" [Newline("\n")] [] 1: JS_CLASS_DECLARATION@152..222 - 0: (empty) - 1: CLASS_KW@152..159 "class" [Newline("\n")] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@159..170 + 0: JS_DECORATOR_LIST@152..152 + 1: (empty) + 2: CLASS_KW@152..159 "class" [Newline("\n")] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@159..170 0: IDENT@159..170 "NotSetters" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@170..171 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@171..220 + 6: (empty) + 7: L_CURLY@170..171 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@171..220 0: JS_METHOD_CLASS_MEMBER@171..183 0: JS_METHOD_MODIFIER_LIST@171..171 1: (empty) @@ -542,5 +546,5 @@ JsModule { 1: JS_DIRECTIVE_LIST@219..219 2: JS_STATEMENT_LIST@219..219 3: R_CURLY@219..220 "}" [] [] - 8: R_CURLY@220..222 "}" [Newline("\n")] [] + 9: R_CURLY@220..222 "}" [Newline("\n")] [] 3: EOF@222..223 "" [Newline("\n")] [] diff --git a/crates/rome_js_parser/test_data/inline/ok/static_generator_constructor_method.rast b/crates/rome_js_parser/test_data/inline/ok/static_generator_constructor_method.rast index b6cc266ff3b..e7d866f68f3 100644 --- a/crates/rome_js_parser/test_data/inline/ok/static_generator_constructor_method.rast +++ b/crates/rome_js_parser/test_data/inline/ok/static_generator_constructor_method.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@0..6 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -77,15 +78,16 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..71 0: JS_CLASS_DECLARATION@0..71 - 0: (empty) - 1: CLASS_KW@0..6 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@6..8 + 0: JS_DECORATOR_LIST@0..0 + 1: (empty) + 2: CLASS_KW@0..6 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@6..8 0: IDENT@6..8 "A" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@8..9 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@9..69 + 6: (empty) + 7: L_CURLY@8..9 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@9..69 0: JS_METHOD_CLASS_MEMBER@9..42 0: JS_METHOD_MODIFIER_LIST@9..18 0: JS_STATIC_MODIFIER@9..18 @@ -126,5 +128,5 @@ JsModule { 1: JS_DIRECTIVE_LIST@68..68 2: JS_STATEMENT_LIST@68..68 3: R_CURLY@68..69 "}" [] [] - 8: R_CURLY@69..71 "}" [Newline("\n")] [] + 9: R_CURLY@69..71 "}" [Newline("\n")] [] 3: EOF@71..72 "" [Newline("\n")] [] diff --git a/crates/rome_js_parser/test_data/inline/ok/static_initialization_block_member.rast b/crates/rome_js_parser/test_data/inline/ok/static_initialization_block_member.rast index 6a19123ab4e..e3e7011dfc5 100644 --- a/crates/rome_js_parser/test_data/inline/ok/static_initialization_block_member.rast +++ b/crates/rome_js_parser/test_data/inline/ok/static_initialization_block_member.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@0..6 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -63,15 +64,16 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..59 0: JS_CLASS_DECLARATION@0..59 - 0: (empty) - 1: CLASS_KW@0..6 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@6..8 + 0: JS_DECORATOR_LIST@0..0 + 1: (empty) + 2: CLASS_KW@0..6 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@6..8 0: IDENT@6..8 "A" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@8..9 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@9..57 + 6: (empty) + 7: L_CURLY@8..9 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@9..57 0: JS_PROPERTY_CLASS_MEMBER@9..21 0: JS_PROPERTY_MODIFIER_LIST@9..19 0: JS_STATIC_MODIFIER@9..19 @@ -98,5 +100,5 @@ JsModule { 0: JS_STRING_LITERAL@46..52 "\"test\"" [] [] 1: SEMICOLON@52..53 ";" [] [] 3: R_CURLY@53..57 "}" [Newline("\n"), Whitespace(" ")] [] - 8: R_CURLY@57..59 "}" [Newline("\n")] [] + 9: R_CURLY@57..59 "}" [Newline("\n")] [] 3: EOF@59..60 "" [Newline("\n")] [] diff --git a/crates/rome_js_parser/test_data/inline/ok/static_member_expression.rast b/crates/rome_js_parser/test_data/inline/ok/static_member_expression.rast index 2fb015f3754..a228e6d8f32 100644 --- a/crates/rome_js_parser/test_data/inline/ok/static_member_expression.rast +++ b/crates/rome_js_parser/test_data/inline/ok/static_member_expression.rast @@ -87,6 +87,7 @@ JsModule { semicolon_token: missing (optional), }, JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@53..60 "class" [Newline("\n")] [Whitespace(" ")], id: JsIdentifierBinding { @@ -261,15 +262,16 @@ JsModule { 0: IDENT@50..53 "bar" [] [] 1: (empty) 6: JS_CLASS_DECLARATION@53..159 - 0: (empty) - 1: CLASS_KW@53..60 "class" [Newline("\n")] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@60..65 + 0: JS_DECORATOR_LIST@53..53 + 1: (empty) + 2: CLASS_KW@53..60 "class" [Newline("\n")] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@60..65 0: IDENT@60..65 "Test" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@65..66 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@66..157 + 6: (empty) + 7: L_CURLY@65..66 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@66..157 0: JS_PROPERTY_CLASS_MEMBER@66..73 0: JS_PROPERTY_MODIFIER_LIST@66..66 1: JS_PRIVATE_CLASS_MEMBER_NAME@66..73 @@ -340,5 +342,5 @@ JsModule { 1: IDENT@149..152 "bar" [] [] 1: SEMICOLON@152..153 ";" [] [] 3: R_CURLY@153..157 "}" [Newline("\n"), Whitespace(" ")] [] - 8: R_CURLY@157..159 "}" [Newline("\n")] [] + 9: R_CURLY@157..159 "}" [Newline("\n")] [] 3: EOF@159..160 "" [Newline("\n")] [] diff --git a/crates/rome_js_parser/test_data/inline/ok/static_method.rast b/crates/rome_js_parser/test_data/inline/ok/static_method.rast index fda52cb36d9..fd3b3dde806 100644 --- a/crates/rome_js_parser/test_data/inline/ok/static_method.rast +++ b/crates/rome_js_parser/test_data/inline/ok/static_method.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@0..6 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -138,15 +139,16 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..98 0: JS_CLASS_DECLARATION@0..98 - 0: (empty) - 1: CLASS_KW@0..6 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@6..10 + 0: JS_DECORATOR_LIST@0..0 + 1: (empty) + 2: CLASS_KW@0..6 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@6..10 0: IDENT@6..10 "foo" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@10..11 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@11..96 + 6: (empty) + 7: L_CURLY@10..11 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@11..96 0: JS_METHOD_CLASS_MEMBER@11..31 0: JS_METHOD_MODIFIER_LIST@11..20 0: JS_STATIC_MODIFIER@11..20 @@ -233,5 +235,5 @@ JsModule { 1: JS_DIRECTIVE_LIST@95..95 2: JS_STATEMENT_LIST@95..95 3: R_CURLY@95..96 "}" [] [] - 8: R_CURLY@96..98 "}" [Newline("\n")] [] + 9: R_CURLY@96..98 "}" [Newline("\n")] [] 3: EOF@98..99 "" [Newline("\n")] [] diff --git a/crates/rome_js_parser/test_data/inline/ok/super_expression.rast b/crates/rome_js_parser/test_data/inline/ok/super_expression.rast index cfc0ae22243..f459d6167e4 100644 --- a/crates/rome_js_parser/test_data/inline/ok/super_expression.rast +++ b/crates/rome_js_parser/test_data/inline/ok/super_expression.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@0..6 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -136,20 +137,21 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..110 0: JS_CLASS_DECLARATION@0..110 - 0: (empty) - 1: CLASS_KW@0..6 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@6..11 + 0: JS_DECORATOR_LIST@0..0 + 1: (empty) + 2: CLASS_KW@0..6 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@6..11 0: IDENT@6..11 "Test" [] [Whitespace(" ")] - 3: (empty) - 4: JS_EXTENDS_CLAUSE@11..21 + 4: (empty) + 5: JS_EXTENDS_CLAUSE@11..21 0: EXTENDS_KW@11..19 "extends" [] [Whitespace(" ")] 1: JS_IDENTIFIER_EXPRESSION@19..21 0: JS_REFERENCE_IDENTIFIER@19..21 0: IDENT@19..21 "B" [] [Whitespace(" ")] 2: (empty) - 5: (empty) - 6: L_CURLY@21..22 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@22..108 + 6: (empty) + 7: L_CURLY@21..22 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@22..108 0: JS_CONSTRUCTOR_CLASS_MEMBER@22..57 0: JS_CONSTRUCTOR_MODIFIER_LIST@22..22 1: JS_LITERAL_MEMBER_NAME@22..36 @@ -224,5 +226,5 @@ JsModule { 4: R_BRACK@102..103 "]" [] [] 1: SEMICOLON@103..104 ";" [] [] 3: R_CURLY@104..108 "}" [Newline("\n"), Whitespace(" ")] [] - 8: R_CURLY@108..110 "}" [Newline("\n")] [] + 9: R_CURLY@108..110 "}" [Newline("\n")] [] 3: EOF@110..111 "" [Newline("\n")] [] diff --git a/crates/rome_js_parser/test_data/inline/ok/super_expression_in_constructor_parameter_list.rast b/crates/rome_js_parser/test_data/inline/ok/super_expression_in_constructor_parameter_list.rast index 8028fd756f5..5c2e974ce13 100644 --- a/crates/rome_js_parser/test_data/inline/ok/super_expression_in_constructor_parameter_list.rast +++ b/crates/rome_js_parser/test_data/inline/ok/super_expression_in_constructor_parameter_list.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@0..6 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -73,20 +74,21 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..49 0: JS_CLASS_DECLARATION@0..49 - 0: (empty) - 1: CLASS_KW@0..6 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@6..8 + 0: JS_DECORATOR_LIST@0..0 + 1: (empty) + 2: CLASS_KW@0..6 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@6..8 0: IDENT@6..8 "A" [] [Whitespace(" ")] - 3: (empty) - 4: JS_EXTENDS_CLAUSE@8..18 + 4: (empty) + 5: JS_EXTENDS_CLAUSE@8..18 0: EXTENDS_KW@8..16 "extends" [] [Whitespace(" ")] 1: JS_IDENTIFIER_EXPRESSION@16..18 0: JS_REFERENCE_IDENTIFIER@16..18 0: IDENT@16..18 "B" [] [Whitespace(" ")] 2: (empty) - 5: (empty) - 6: L_CURLY@18..20 "{" [] [Whitespace(" ")] - 7: JS_CLASS_MEMBER_LIST@20..48 + 6: (empty) + 7: L_CURLY@18..20 "{" [] [Whitespace(" ")] + 8: JS_CLASS_MEMBER_LIST@20..48 0: JS_CONSTRUCTOR_CLASS_MEMBER@20..48 0: JS_CONSTRUCTOR_MODIFIER_LIST@20..20 1: JS_LITERAL_MEMBER_NAME@20..31 @@ -116,5 +118,5 @@ JsModule { 1: JS_DIRECTIVE_LIST@46..46 2: JS_STATEMENT_LIST@46..46 3: R_CURLY@46..48 "}" [] [Whitespace(" ")] - 8: R_CURLY@48..49 "}" [] [] + 9: R_CURLY@48..49 "}" [] [] 3: EOF@49..50 "" [Newline("\n")] [] diff --git a/crates/rome_js_parser/test_data/inline/ok/ts_abstract_classes.rast b/crates/rome_js_parser/test_data/inline/ok/ts_abstract_classes.rast index 27e590b4684..1c91f6b794f 100644 --- a/crates/rome_js_parser/test_data/inline/ok/ts_abstract_classes.rast +++ b/crates/rome_js_parser/test_data/inline/ok/ts_abstract_classes.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: ABSTRACT_KW@0..9 "abstract" [] [Whitespace(" ")], class_token: CLASS_KW@9..15 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -16,6 +17,7 @@ JsModule { r_curly_token: R_CURLY@18..19 "}" [] [], }, JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: ABSTRACT_KW@19..29 "abstract" [Newline("\n")] [Whitespace(" ")], class_token: CLASS_KW@29..35 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -262,6 +264,7 @@ JsModule { r_curly_token: R_CURLY@294..296 "}" [Newline("\n")] [], }, JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: ABSTRACT_KW@296..306 "abstract" [Newline("\n")] [Whitespace(" ")], class_token: CLASS_KW@306..312 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -358,26 +361,28 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..441 0: JS_CLASS_DECLARATION@0..19 - 0: ABSTRACT_KW@0..9 "abstract" [] [Whitespace(" ")] - 1: CLASS_KW@9..15 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@15..17 + 0: JS_DECORATOR_LIST@0..0 + 1: ABSTRACT_KW@0..9 "abstract" [] [Whitespace(" ")] + 2: CLASS_KW@9..15 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@15..17 0: IDENT@15..17 "A" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@17..18 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@18..18 - 8: R_CURLY@18..19 "}" [] [] + 6: (empty) + 7: L_CURLY@17..18 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@18..18 + 9: R_CURLY@18..19 "}" [] [] 1: JS_CLASS_DECLARATION@19..296 - 0: ABSTRACT_KW@19..29 "abstract" [Newline("\n")] [Whitespace(" ")] - 1: CLASS_KW@29..35 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@35..51 + 0: JS_DECORATOR_LIST@19..19 + 1: ABSTRACT_KW@19..29 "abstract" [Newline("\n")] [Whitespace(" ")] + 2: CLASS_KW@29..35 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@35..51 0: IDENT@35..51 "ConcreteMembers" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@51..52 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@52..294 + 6: (empty) + 7: L_CURLY@51..52 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@52..294 0: JS_PROPERTY_CLASS_MEMBER@52..70 0: JS_PROPERTY_MODIFIER_LIST@52..52 1: JS_LITERAL_MEMBER_NAME@52..61 @@ -542,17 +547,18 @@ JsModule { 1: JS_DIRECTIVE_LIST@293..293 2: JS_STATEMENT_LIST@293..293 3: R_CURLY@293..294 "}" [] [] - 8: R_CURLY@294..296 "}" [Newline("\n")] [] + 9: R_CURLY@294..296 "}" [Newline("\n")] [] 2: JS_CLASS_DECLARATION@296..441 - 0: ABSTRACT_KW@296..306 "abstract" [Newline("\n")] [Whitespace(" ")] - 1: CLASS_KW@306..312 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@312..328 + 0: JS_DECORATOR_LIST@296..296 + 1: ABSTRACT_KW@296..306 "abstract" [Newline("\n")] [Whitespace(" ")] + 2: CLASS_KW@306..312 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@312..328 0: IDENT@312..328 "AbstractMembers" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@328..329 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@329..439 + 6: (empty) + 7: L_CURLY@328..329 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@329..439 0: TS_PROPERTY_SIGNATURE_CLASS_MEMBER@329..356 0: TS_PROPERTY_SIGNATURE_MODIFIER_LIST@329..343 0: TS_ABSTRACT_MODIFIER@329..343 @@ -606,5 +612,5 @@ JsModule { 3: (empty) 5: R_PAREN@437..438 ")" [] [] 6: SEMICOLON@438..439 ";" [] [] - 8: R_CURLY@439..441 "}" [Newline("\n")] [] + 9: R_CURLY@439..441 "}" [Newline("\n")] [] 3: EOF@441..442 "" [Newline("\n")] [] diff --git a/crates/rome_js_parser/test_data/inline/ok/ts_abstract_property_can_be_optional.rast b/crates/rome_js_parser/test_data/inline/ok/ts_abstract_property_can_be_optional.rast index f40f9544085..93693d8a648 100644 --- a/crates/rome_js_parser/test_data/inline/ok/ts_abstract_property_can_be_optional.rast +++ b/crates/rome_js_parser/test_data/inline/ok/ts_abstract_property_can_be_optional.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: ABSTRACT_KW@0..9 "abstract" [] [Whitespace(" ")], class_token: CLASS_KW@9..15 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -45,15 +46,16 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..49 0: JS_CLASS_DECLARATION@0..49 - 0: ABSTRACT_KW@0..9 "abstract" [] [Whitespace(" ")] - 1: CLASS_KW@9..15 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@15..17 + 0: JS_DECORATOR_LIST@0..0 + 1: ABSTRACT_KW@0..9 "abstract" [] [Whitespace(" ")] + 2: CLASS_KW@9..15 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@15..17 0: IDENT@15..17 "A" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@17..18 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@18..47 + 6: (empty) + 7: L_CURLY@17..18 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@18..47 0: TS_PROPERTY_SIGNATURE_CLASS_MEMBER@18..47 0: TS_PROPERTY_SIGNATURE_MODIFIER_LIST@18..33 0: TS_ABSTRACT_MODIFIER@18..33 @@ -67,5 +69,5 @@ JsModule { 1: TS_STRING_TYPE@40..46 0: STRING_KW@40..46 "string" [] [] 3: SEMICOLON@46..47 ";" [] [] - 8: R_CURLY@47..49 "}" [Newline("\n")] [] + 9: R_CURLY@47..49 "}" [Newline("\n")] [] 3: EOF@49..50 "" [Newline("\n")] [] diff --git a/crates/rome_js_parser/test_data/inline/ok/ts_class_decorator.rast b/crates/rome_js_parser/test_data/inline/ok/ts_class_decorator.rast index e1943bd8392..57fb87f85e7 100644 --- a/crates/rome_js_parser/test_data/inline/ok/ts_class_decorator.rast +++ b/crates/rome_js_parser/test_data/inline/ok/ts_class_decorator.rast @@ -24,8 +24,18 @@ JsModule { }, }, JsClassDeclaration { + decorators: JsDecoratorList [ + JsDecorator { + at_token: AT@18..20 "@" [Newline("\n")] [], + expression: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@20..24 "test" [] [], + }, + }, + }, + ], abstract_token: missing (optional), - class_token: CLASS_KW@18..31 "class" [Newline("\n"), Skipped("@"), Skipped("test"), Newline("\n")] [Whitespace(" ")], + class_token: CLASS_KW@24..31 "class" [Newline("\n")] [Whitespace(" ")], id: JsIdentifierBinding { name_token: IDENT@31..36 "Test" [] [Whitespace(" ")], }, @@ -37,8 +47,46 @@ JsModule { r_curly_token: R_CURLY@37..38 "}" [] [], }, JsClassDeclaration { + decorators: JsDecoratorList [ + JsDecorator { + at_token: AT@38..40 "@" [Newline("\n")] [], + expression: JsStaticMemberExpression { + object: JsStaticMemberExpression { + object: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@40..44 "test" [] [], + }, + }, + operator_token: DOT@44..45 "." [] [], + member: JsName { + value_token: IDENT@45..46 "a" [] [], + }, + }, + operator_token: QUESTIONDOT@46..48 "?." [] [], + member: JsName { + value_token: IDENT@48..50 "c" [] [Whitespace(" ")], + }, + }, + }, + JsDecorator { + at_token: AT@50..51 "@" [] [], + expression: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@51..56 "test" [] [Whitespace(" ")], + }, + }, + }, + JsDecorator { + at_token: AT@56..57 "@" [] [], + expression: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@57..61 "test" [] [], + }, + }, + }, + ], abstract_token: missing (optional), - class_token: CLASS_KW@38..68 "class" [Newline("\n"), Skipped("@"), Skipped("test"), Skipped("."), Skipped("a"), Skipped("?."), Skipped("c"), Whitespace(" "), Skipped("@"), Skipped("test"), Whitespace(" "), Skipped("@"), Skipped("test"), Newline("\n")] [Whitespace(" ")], + class_token: CLASS_KW@61..68 "class" [Newline("\n")] [Whitespace(" ")], id: JsIdentifierBinding { name_token: IDENT@68..73 "Test2" [] [], }, @@ -49,50 +97,14 @@ JsModule { members: JsClassMemberList [], r_curly_token: R_CURLY@74..75 "}" [] [], }, - JsExport { - export_token: EXPORT_KW@75..89 "export" [Newline("\n"), Skipped("@"), Skipped("test"), Whitespace(" ")] [Whitespace(" ")], - export_clause: JsClassDeclaration { - abstract_token: missing (optional), - class_token: CLASS_KW@89..95 "class" [] [Whitespace(" ")], - id: JsIdentifierBinding { - name_token: IDENT@95..100 "Test" [] [Whitespace(" ")], - }, - type_parameters: missing (optional), - extends_clause: missing (optional), - implements_clause: missing (optional), - l_curly_token: L_CURLY@100..101 "{" [] [], - members: JsClassMemberList [], - r_curly_token: R_CURLY@101..102 "}" [] [], - }, - }, - JsExport { - export_token: EXPORT_KW@102..116 "export" [Newline("\n"), Skipped("@"), Skipped("test"), Whitespace(" ")] [Whitespace(" ")], - export_clause: JsExportDefaultDeclarationClause { - default_token: DEFAULT_KW@116..124 "default" [] [Whitespace(" ")], - declaration: JsClassExportDefaultDeclaration { - abstract_token: missing (optional), - class_token: CLASS_KW@124..130 "class" [] [Whitespace(" ")], - id: JsIdentifierBinding { - name_token: IDENT@130..135 "Test" [] [Whitespace(" ")], - }, - type_parameters: missing (optional), - extends_clause: missing (optional), - implements_clause: missing (optional), - l_curly_token: L_CURLY@135..136 "{" [] [], - members: JsClassMemberList [], - r_curly_token: R_CURLY@136..137 "}" [] [], - }, - semicolon_token: missing (optional), - }, - }, ], - eof_token: EOF@137..138 "" [Newline("\n")] [], + eof_token: EOF@75..76 "" [Newline("\n")] [], } -0: JS_MODULE@0..138 +0: JS_MODULE@0..76 0: (empty) 1: JS_DIRECTIVE_LIST@0..0 - 2: JS_MODULE_ITEM_LIST@0..137 + 2: JS_MODULE_ITEM_LIST@0..75 0: JS_FUNCTION_DECLARATION@0..18 0: (empty) 1: FUNCTION_KW@0..9 "function" [] [Whitespace(" ")] @@ -111,54 +123,55 @@ JsModule { 2: JS_STATEMENT_LIST@17..17 3: R_CURLY@17..18 "}" [] [] 1: JS_CLASS_DECLARATION@18..38 - 0: (empty) - 1: CLASS_KW@18..31 "class" [Newline("\n"), Skipped("@"), Skipped("test"), Newline("\n")] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@31..36 + 0: JS_DECORATOR_LIST@18..24 + 0: JS_DECORATOR@18..24 + 0: AT@18..20 "@" [Newline("\n")] [] + 1: JS_IDENTIFIER_EXPRESSION@20..24 + 0: JS_REFERENCE_IDENTIFIER@20..24 + 0: IDENT@20..24 "test" [] [] + 1: (empty) + 2: CLASS_KW@24..31 "class" [Newline("\n")] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@31..36 0: IDENT@31..36 "Test" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@36..37 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@37..37 - 8: R_CURLY@37..38 "}" [] [] + 6: (empty) + 7: L_CURLY@36..37 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@37..37 + 9: R_CURLY@37..38 "}" [] [] 2: JS_CLASS_DECLARATION@38..75 - 0: (empty) - 1: CLASS_KW@38..68 "class" [Newline("\n"), Skipped("@"), Skipped("test"), Skipped("."), Skipped("a"), Skipped("?."), Skipped("c"), Whitespace(" "), Skipped("@"), Skipped("test"), Whitespace(" "), Skipped("@"), Skipped("test"), Newline("\n")] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@68..73 + 0: JS_DECORATOR_LIST@38..61 + 0: JS_DECORATOR@38..50 + 0: AT@38..40 "@" [Newline("\n")] [] + 1: JS_STATIC_MEMBER_EXPRESSION@40..50 + 0: JS_STATIC_MEMBER_EXPRESSION@40..46 + 0: JS_IDENTIFIER_EXPRESSION@40..44 + 0: JS_REFERENCE_IDENTIFIER@40..44 + 0: IDENT@40..44 "test" [] [] + 1: DOT@44..45 "." [] [] + 2: JS_NAME@45..46 + 0: IDENT@45..46 "a" [] [] + 1: QUESTIONDOT@46..48 "?." [] [] + 2: JS_NAME@48..50 + 0: IDENT@48..50 "c" [] [Whitespace(" ")] + 1: JS_DECORATOR@50..56 + 0: AT@50..51 "@" [] [] + 1: JS_IDENTIFIER_EXPRESSION@51..56 + 0: JS_REFERENCE_IDENTIFIER@51..56 + 0: IDENT@51..56 "test" [] [Whitespace(" ")] + 2: JS_DECORATOR@56..61 + 0: AT@56..57 "@" [] [] + 1: JS_IDENTIFIER_EXPRESSION@57..61 + 0: JS_REFERENCE_IDENTIFIER@57..61 + 0: IDENT@57..61 "test" [] [] + 1: (empty) + 2: CLASS_KW@61..68 "class" [Newline("\n")] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@68..73 0: IDENT@68..73 "Test2" [] [] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@73..74 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@74..74 - 8: R_CURLY@74..75 "}" [] [] - 3: JS_EXPORT@75..102 - 0: EXPORT_KW@75..89 "export" [Newline("\n"), Skipped("@"), Skipped("test"), Whitespace(" ")] [Whitespace(" ")] - 1: JS_CLASS_DECLARATION@89..102 - 0: (empty) - 1: CLASS_KW@89..95 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@95..100 - 0: IDENT@95..100 "Test" [] [Whitespace(" ")] - 3: (empty) - 4: (empty) - 5: (empty) - 6: L_CURLY@100..101 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@101..101 - 8: R_CURLY@101..102 "}" [] [] - 4: JS_EXPORT@102..137 - 0: EXPORT_KW@102..116 "export" [Newline("\n"), Skipped("@"), Skipped("test"), Whitespace(" ")] [Whitespace(" ")] - 1: JS_EXPORT_DEFAULT_DECLARATION_CLAUSE@116..137 - 0: DEFAULT_KW@116..124 "default" [] [Whitespace(" ")] - 1: JS_CLASS_EXPORT_DEFAULT_DECLARATION@124..137 - 0: (empty) - 1: CLASS_KW@124..130 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@130..135 - 0: IDENT@130..135 "Test" [] [Whitespace(" ")] - 3: (empty) - 4: (empty) - 5: (empty) - 6: L_CURLY@135..136 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@136..136 - 8: R_CURLY@136..137 "}" [] [] - 2: (empty) - 3: EOF@137..138 "" [Newline("\n")] [] + 6: (empty) + 7: L_CURLY@73..74 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@74..74 + 9: R_CURLY@74..75 "}" [] [] + 3: EOF@75..76 "" [Newline("\n")] [] diff --git a/crates/rome_js_parser/test_data/inline/ok/ts_class_decorator.ts b/crates/rome_js_parser/test_data/inline/ok/ts_class_decorator.ts index 9ed470aead4..065a262049e 100644 --- a/crates/rome_js_parser/test_data/inline/ok/ts_class_decorator.ts +++ b/crates/rome_js_parser/test_data/inline/ok/ts_class_decorator.ts @@ -3,5 +3,3 @@ function test() {} class Test {} @test.a?.c @test @test class Test2{} -@test export class Test {} -@test export default class Test {} diff --git a/crates/rome_js_parser/test_data/inline/ok/ts_class_named_abstract_is_valid_in_ts.rast b/crates/rome_js_parser/test_data/inline/ok/ts_class_named_abstract_is_valid_in_ts.rast index 438e2cc9086..b8d6389abfb 100644 --- a/crates/rome_js_parser/test_data/inline/ok/ts_class_named_abstract_is_valid_in_ts.rast +++ b/crates/rome_js_parser/test_data/inline/ok/ts_class_named_abstract_is_valid_in_ts.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@0..6 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -24,14 +25,15 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..17 0: JS_CLASS_DECLARATION@0..17 - 0: (empty) - 1: CLASS_KW@0..6 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@6..15 + 0: JS_DECORATOR_LIST@0..0 + 1: (empty) + 2: CLASS_KW@0..6 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@6..15 0: IDENT@6..15 "abstract" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@15..16 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@16..16 - 8: R_CURLY@16..17 "}" [] [] + 6: (empty) + 7: L_CURLY@15..16 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@16..16 + 9: R_CURLY@16..17 "}" [] [] 3: EOF@17..18 "" [Newline("\n")] [] diff --git a/crates/rome_js_parser/test_data/inline/ok/ts_class_property_annotation.rast b/crates/rome_js_parser/test_data/inline/ok/ts_class_property_annotation.rast index 8e00c0fd468..306761ca6e6 100644 --- a/crates/rome_js_parser/test_data/inline/ok/ts_class_property_annotation.rast +++ b/crates/rome_js_parser/test_data/inline/ok/ts_class_property_annotation.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@0..6 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -78,15 +79,16 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..61 0: JS_CLASS_DECLARATION@0..61 - 0: (empty) - 1: CLASS_KW@0..6 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@6..8 + 0: JS_DECORATOR_LIST@0..0 + 1: (empty) + 2: CLASS_KW@0..6 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@6..8 0: IDENT@6..8 "A" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@8..9 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@9..59 + 6: (empty) + 7: L_CURLY@8..9 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@9..59 0: JS_PROPERTY_CLASS_MEMBER@9..22 0: JS_PROPERTY_MODIFIER_LIST@9..9 1: JS_LITERAL_MEMBER_NAME@9..13 @@ -124,5 +126,5 @@ JsModule { 0: STRING_KW@52..58 "string" [] [] 3: (empty) 4: SEMICOLON@58..59 ";" [] [] - 8: R_CURLY@59..61 "}" [Newline("\n")] [] + 9: R_CURLY@59..61 "}" [Newline("\n")] [] 3: EOF@61..62 "" [Newline("\n")] [] diff --git a/crates/rome_js_parser/test_data/inline/ok/ts_class_property_member_modifiers.rast b/crates/rome_js_parser/test_data/inline/ok/ts_class_property_member_modifiers.rast index 7e23e531eb8..65288cdbfe4 100644 --- a/crates/rome_js_parser/test_data/inline/ok/ts_class_property_member_modifiers.rast +++ b/crates/rome_js_parser/test_data/inline/ok/ts_class_property_member_modifiers.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@0..6 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -26,6 +27,7 @@ JsModule { r_curly_token: R_CURLY@21..23 "}" [Newline("\n")] [], }, JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: ABSTRACT_KW@23..33 "abstract" [Newline("\n")] [Whitespace(" ")], class_token: CLASS_KW@33..39 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -334,15 +336,16 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..552 0: JS_CLASS_DECLARATION@0..23 - 0: (empty) - 1: CLASS_KW@0..6 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@6..11 + 0: JS_DECORATOR_LIST@0..0 + 1: (empty) + 2: CLASS_KW@0..6 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@6..11 0: IDENT@6..11 "Base" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@11..12 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@12..21 + 6: (empty) + 7: L_CURLY@11..12 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@12..21 0: JS_PROPERTY_CLASS_MEMBER@12..21 0: JS_PROPERTY_MODIFIER_LIST@12..12 1: JS_LITERAL_MEMBER_NAME@12..20 @@ -350,22 +353,23 @@ JsModule { 2: (empty) 3: (empty) 4: SEMICOLON@20..21 ";" [] [] - 8: R_CURLY@21..23 "}" [Newline("\n")] [] + 9: R_CURLY@21..23 "}" [Newline("\n")] [] 1: JS_CLASS_DECLARATION@23..552 - 0: ABSTRACT_KW@23..33 "abstract" [Newline("\n")] [Whitespace(" ")] - 1: CLASS_KW@33..39 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@39..44 + 0: JS_DECORATOR_LIST@23..23 + 1: ABSTRACT_KW@23..33 "abstract" [Newline("\n")] [Whitespace(" ")] + 2: CLASS_KW@33..39 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@39..44 0: IDENT@39..44 "Test" [] [Whitespace(" ")] - 3: (empty) - 4: JS_EXTENDS_CLAUSE@44..57 + 4: (empty) + 5: JS_EXTENDS_CLAUSE@44..57 0: EXTENDS_KW@44..52 "extends" [] [Whitespace(" ")] 1: JS_IDENTIFIER_EXPRESSION@52..57 0: JS_REFERENCE_IDENTIFIER@52..57 0: IDENT@52..57 "Base" [] [Whitespace(" ")] 2: (empty) - 5: (empty) - 6: L_CURLY@57..58 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@58..550 + 6: (empty) + 7: L_CURLY@57..58 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@58..550 0: TS_PROPERTY_SIGNATURE_CLASS_MEMBER@58..81 0: TS_PROPERTY_SIGNATURE_MODIFIER_LIST@58..71 0: TS_DECLARE_MODIFIER@58..71 @@ -548,5 +552,5 @@ JsModule { 1: TS_STRING_TYPE@543..549 0: STRING_KW@543..549 "string" [] [] 3: SEMICOLON@549..550 ";" [] [] - 8: R_CURLY@550..552 "}" [Newline("\n")] [] + 9: R_CURLY@550..552 "}" [Newline("\n")] [] 3: EOF@552..553 "" [Newline("\n")] [] diff --git a/crates/rome_js_parser/test_data/inline/ok/ts_class_type_parameters.rast b/crates/rome_js_parser/test_data/inline/ok/ts_class_type_parameters.rast index 4026d91a468..db238a60f01 100644 --- a/crates/rome_js_parser/test_data/inline/ok/ts_class_type_parameters.rast +++ b/crates/rome_js_parser/test_data/inline/ok/ts_class_type_parameters.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@0..6 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -55,11 +56,12 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..28 0: JS_CLASS_DECLARATION@0..28 - 0: (empty) - 1: CLASS_KW@0..6 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@6..16 + 0: JS_DECORATOR_LIST@0..0 + 1: (empty) + 2: CLASS_KW@0..6 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@6..16 0: IDENT@6..16 "BuildError" [] [] - 3: TS_TYPE_PARAMETERS@16..26 + 4: TS_TYPE_PARAMETERS@16..26 0: L_ANGLE@16..17 "<" [] [] 1: TS_TYPE_PARAMETER_LIST@17..24 0: TS_TYPE_PARAMETER@17..18 @@ -83,9 +85,9 @@ JsModule { 2: (empty) 3: (empty) 2: R_ANGLE@24..26 ">" [] [Whitespace(" ")] - 4: (empty) 5: (empty) - 6: L_CURLY@26..27 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@27..27 - 8: R_CURLY@27..28 "}" [] [] + 6: (empty) + 7: L_CURLY@26..27 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@27..27 + 9: R_CURLY@27..28 "}" [] [] 3: EOF@28..29 "" [Newline("\n")] [] diff --git a/crates/rome_js_parser/test_data/inline/ok/ts_decorate_computed_member.rast b/crates/rome_js_parser/test_data/inline/ok/ts_decorate_computed_member.rast index 199fb1fa9ca..40324e43030 100644 --- a/crates/rome_js_parser/test_data/inline/ok/ts_decorate_computed_member.rast +++ b/crates/rome_js_parser/test_data/inline/ok/ts_decorate_computed_member.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@0..6 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -43,15 +44,16 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..35 0: JS_CLASS_DECLARATION@0..35 - 0: (empty) - 1: CLASS_KW@0..6 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@6..11 + 0: JS_DECORATOR_LIST@0..0 + 1: (empty) + 2: CLASS_KW@0..6 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@6..11 0: IDENT@6..11 "Test" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@11..12 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@12..33 + 6: (empty) + 7: L_CURLY@11..12 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@12..33 0: JS_PROPERTY_CLASS_MEMBER@12..33 0: JS_PROPERTY_MODIFIER_LIST@12..12 1: JS_COMPUTED_MEMBER_NAME@12..24 @@ -65,5 +67,5 @@ JsModule { 0: STRING_KW@26..32 "string" [] [] 3: (empty) 4: SEMICOLON@32..33 ";" [] [] - 8: R_CURLY@33..35 "}" [Newline("\n")] [] + 9: R_CURLY@33..35 "}" [Newline("\n")] [] 3: EOF@35..36 "" [Newline("\n")] [] diff --git a/crates/rome_js_parser/test_data/inline/ok/ts_decorated_class_members.rast b/crates/rome_js_parser/test_data/inline/ok/ts_decorated_class_members.rast index c3028884ded..c8c0907cdae 100644 --- a/crates/rome_js_parser/test_data/inline/ok/ts_decorated_class_members.rast +++ b/crates/rome_js_parser/test_data/inline/ok/ts_decorated_class_members.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@0..6 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -129,15 +130,16 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..152 0: JS_CLASS_DECLARATION@0..152 - 0: (empty) - 1: CLASS_KW@0..6 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@6..11 + 0: JS_DECORATOR_LIST@0..0 + 1: (empty) + 2: CLASS_KW@0..6 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@6..11 0: IDENT@6..11 "Test" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@11..12 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@12..150 + 6: (empty) + 7: L_CURLY@11..12 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@12..150 0: JS_PROPERTY_CLASS_MEMBER@12..34 0: JS_PROPERTY_MODIFIER_LIST@12..12 1: JS_LITERAL_MEMBER_NAME@12..25 @@ -218,5 +220,5 @@ JsModule { 0: IDENT@145..149 "prop" [] [] 2: (empty) 3: SEMICOLON@149..150 ";" [] [] - 8: R_CURLY@150..152 "}" [Newline("\n")] [] + 9: R_CURLY@150..152 "}" [Newline("\n")] [] 3: EOF@152..153 "" [Newline("\n")] [] diff --git a/crates/rome_js_parser/test_data/inline/ok/ts_decorator_assignment.rast b/crates/rome_js_parser/test_data/inline/ok/ts_decorator_assignment.rast index b14d59c3aab..d5b11c9205a 100644 --- a/crates/rome_js_parser/test_data/inline/ok/ts_decorator_assignment.rast +++ b/crates/rome_js_parser/test_data/inline/ok/ts_decorator_assignment.rast @@ -3,8 +3,34 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [ + JsDecorator { + at_token: AT@0..1 "@" [] [], + expression: JsCallExpression { + callee: JsIdentifierExpression { + name: JsReferenceIdentifier { + value_token: IDENT@1..5 "test" [] [], + }, + }, + optional_chain_token: missing (optional), + type_arguments: missing (optional), + arguments: JsCallArguments { + l_paren_token: L_PAREN@5..6 "(" [] [], + args: JsCallArgumentList [ + JsPreUpdateExpression { + operator_token: MINUS2@6..8 "--" [] [], + operand: JsIdentifierAssignment { + name_token: IDENT@8..9 "a" [] [], + }, + }, + ], + r_paren_token: R_PAREN@9..10 ")" [] [], + }, + }, + }, + ], abstract_token: missing (optional), - class_token: CLASS_KW@0..17 "class" [Skipped("@"), Skipped("test"), Skipped("("), Skipped("--"), Skipped("a"), Skipped(")"), Newline("\n")] [Whitespace(" ")], + class_token: CLASS_KW@10..17 "class" [Newline("\n")] [Whitespace(" ")], id: JsIdentifierBinding { name_token: IDENT@17..22 "Test" [] [Whitespace(" ")], }, @@ -24,14 +50,31 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..24 0: JS_CLASS_DECLARATION@0..24 - 0: (empty) - 1: CLASS_KW@0..17 "class" [Skipped("@"), Skipped("test"), Skipped("("), Skipped("--"), Skipped("a"), Skipped(")"), Newline("\n")] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@17..22 + 0: JS_DECORATOR_LIST@0..10 + 0: JS_DECORATOR@0..10 + 0: AT@0..1 "@" [] [] + 1: JS_CALL_EXPRESSION@1..10 + 0: JS_IDENTIFIER_EXPRESSION@1..5 + 0: JS_REFERENCE_IDENTIFIER@1..5 + 0: IDENT@1..5 "test" [] [] + 1: (empty) + 2: (empty) + 3: JS_CALL_ARGUMENTS@5..10 + 0: L_PAREN@5..6 "(" [] [] + 1: JS_CALL_ARGUMENT_LIST@6..9 + 0: JS_PRE_UPDATE_EXPRESSION@6..9 + 0: MINUS2@6..8 "--" [] [] + 1: JS_IDENTIFIER_ASSIGNMENT@8..9 + 0: IDENT@8..9 "a" [] [] + 2: R_PAREN@9..10 ")" [] [] + 1: (empty) + 2: CLASS_KW@10..17 "class" [Newline("\n")] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@17..22 0: IDENT@17..22 "Test" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@22..23 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@23..23 - 8: R_CURLY@23..24 "}" [] [] + 6: (empty) + 7: L_CURLY@22..23 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@23..23 + 9: R_CURLY@23..24 "}" [] [] 3: EOF@24..25 "" [Newline("\n")] [] diff --git a/crates/rome_js_parser/test_data/inline/ok/ts_decorator_call_expression_with_arrow.rast b/crates/rome_js_parser/test_data/inline/ok/ts_decorator_call_expression_with_arrow.rast index f06cef41f4d..875f909297c 100644 --- a/crates/rome_js_parser/test_data/inline/ok/ts_decorator_call_expression_with_arrow.rast +++ b/crates/rome_js_parser/test_data/inline/ok/ts_decorator_call_expression_with_arrow.rast @@ -5,6 +5,7 @@ JsModule { JsExport { export_token: EXPORT_KW@0..7 "export" [] [Whitespace(" ")], export_clause: JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@7..13 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -47,15 +48,16 @@ JsModule { 0: JS_EXPORT@0..65 0: EXPORT_KW@0..7 "export" [] [Whitespace(" ")] 1: JS_CLASS_DECLARATION@7..65 - 0: (empty) - 1: CLASS_KW@7..13 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@13..17 + 0: JS_DECORATOR_LIST@7..7 + 1: (empty) + 2: CLASS_KW@7..13 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@13..17 0: IDENT@13..17 "Foo" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@17..18 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@18..63 + 6: (empty) + 7: L_CURLY@17..18 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@18..63 0: JS_PROPERTY_CLASS_MEMBER@18..63 0: JS_PROPERTY_MODIFIER_LIST@18..18 1: JS_LITERAL_MEMBER_NAME@18..54 @@ -68,5 +70,5 @@ JsModule { 0: NUMBER_KW@57..63 "number" [] [] 3: (empty) 4: (empty) - 8: R_CURLY@63..65 "}" [Newline("\n")] [] + 9: R_CURLY@63..65 "}" [Newline("\n")] [] 3: EOF@65..66 "" [Newline("\n")] [] diff --git a/crates/rome_js_parser/test_data/inline/ok/ts_export_assignment_identifier.rast b/crates/rome_js_parser/test_data/inline/ok/ts_export_assignment_identifier.rast index 35bfe5d7c1d..71556802738 100644 --- a/crates/rome_js_parser/test_data/inline/ok/ts_export_assignment_identifier.rast +++ b/crates/rome_js_parser/test_data/inline/ok/ts_export_assignment_identifier.rast @@ -59,6 +59,7 @@ JsModule { export_clause: TsExportAssignmentClause { eq_token: EQ@50..52 "=" [] [Whitespace(" ")], expression: JsClassExpression { + decorators: JsDecoratorList [], class_token: CLASS_KW@52..58 "class" [] [Whitespace(" ")], id: missing (optional), type_parameters: missing (optional), @@ -169,14 +170,15 @@ JsModule { 1: TS_EXPORT_ASSIGNMENT_CLAUSE@50..60 0: EQ@50..52 "=" [] [Whitespace(" ")] 1: JS_CLASS_EXPRESSION@52..60 - 0: CLASS_KW@52..58 "class" [] [Whitespace(" ")] - 1: (empty) + 0: JS_DECORATOR_LIST@52..52 + 1: CLASS_KW@52..58 "class" [] [Whitespace(" ")] 2: (empty) 3: (empty) 4: (empty) - 5: L_CURLY@58..59 "{" [] [] - 6: JS_CLASS_MEMBER_LIST@59..59 - 7: R_CURLY@59..60 "}" [] [] + 5: (empty) + 6: L_CURLY@58..59 "{" [] [] + 7: JS_CLASS_MEMBER_LIST@59..59 + 8: R_CURLY@59..60 "}" [] [] 2: (empty) 3: JS_EXPORT@60..84 0: EXPORT_KW@60..68 "export" [Newline("\n")] [Whitespace(" ")] diff --git a/crates/rome_js_parser/test_data/inline/ok/ts_export_declare.rast b/crates/rome_js_parser/test_data/inline/ok/ts_export_declare.rast index 1a935319c7a..d686c604f19 100644 --- a/crates/rome_js_parser/test_data/inline/ok/ts_export_declare.rast +++ b/crates/rome_js_parser/test_data/inline/ok/ts_export_declare.rast @@ -84,6 +84,7 @@ JsModule { export_clause: TsExportDeclareClause { declare_token: DECLARE_KW@126..134 "declare" [] [Whitespace(" ")], declaration: JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@134..140 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -187,16 +188,17 @@ JsModule { 1: TS_EXPORT_DECLARE_CLAUSE@126..144 0: DECLARE_KW@126..134 "declare" [] [Whitespace(" ")] 1: JS_CLASS_DECLARATION@134..144 - 0: (empty) - 1: CLASS_KW@134..140 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@140..142 + 0: JS_DECORATOR_LIST@134..134 + 1: (empty) + 2: CLASS_KW@134..140 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@140..142 0: IDENT@140..142 "D" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@142..143 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@143..143 - 8: R_CURLY@143..144 "}" [] [] + 6: (empty) + 7: L_CURLY@142..143 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@143..143 + 9: R_CURLY@143..144 "}" [] [] 5: JS_EXPORT@144..172 0: EXPORT_KW@144..152 "export" [Newline("\n")] [Whitespace(" ")] 1: TS_EXPORT_DECLARE_CLAUSE@152..172 diff --git a/crates/rome_js_parser/test_data/inline/ok/ts_extends_generic_type.rast b/crates/rome_js_parser/test_data/inline/ok/ts_extends_generic_type.rast index 30f3d248dc4..87e824305bb 100644 --- a/crates/rome_js_parser/test_data/inline/ok/ts_extends_generic_type.rast +++ b/crates/rome_js_parser/test_data/inline/ok/ts_extends_generic_type.rast @@ -15,6 +15,7 @@ JsModule { semicolon_token: SEMICOLON@36..37 ";" [] [], }, JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@37..44 "class" [Newline("\n")] [Whitespace(" ")], id: JsIdentifierBinding { @@ -79,12 +80,13 @@ JsModule { 0: STRING_KW@30..36 "string" [] [] 5: SEMICOLON@36..37 ";" [] [] 1: JS_CLASS_DECLARATION@37..101 - 0: (empty) - 1: CLASS_KW@37..44 "class" [Newline("\n")] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@44..46 + 0: JS_DECORATOR_LIST@37..37 + 1: (empty) + 2: CLASS_KW@37..44 "class" [Newline("\n")] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@44..46 0: IDENT@44..46 "D" [] [Whitespace(" ")] - 3: (empty) - 4: JS_EXTENDS_CLAUSE@46..80 + 4: (empty) + 5: JS_EXTENDS_CLAUSE@46..80 0: EXTENDS_KW@46..54 "extends" [] [Whitespace(" ")] 1: JS_IDENTIFIER_EXPRESSION@54..55 0: JS_REFERENCE_IDENTIFIER@54..55 @@ -97,9 +99,9 @@ JsModule { 0: IDENT@56..78 "IHasVisualizationModel" [] [] 1: (empty) 2: R_ANGLE@78..80 ">" [] [Whitespace(" ")] - 5: (empty) - 6: L_CURLY@80..81 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@81..99 + 6: (empty) + 7: L_CURLY@80..81 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@81..99 0: JS_PROPERTY_CLASS_MEMBER@81..99 0: JS_PROPERTY_MODIFIER_LIST@81..81 1: JS_LITERAL_MEMBER_NAME@81..88 @@ -110,5 +112,5 @@ JsModule { 1: JS_STRING_LITERAL_EXPRESSION@90..98 0: JS_STRING_LITERAL@90..98 "\"string\"" [] [] 4: SEMICOLON@98..99 ";" [] [] - 8: R_CURLY@99..101 "}" [Newline("\n")] [] + 9: R_CURLY@99..101 "}" [Newline("\n")] [] 3: EOF@101..102 "" [Newline("\n")] [] diff --git a/crates/rome_js_parser/test_data/inline/ok/ts_index_signature_class_member.rast b/crates/rome_js_parser/test_data/inline/ok/ts_index_signature_class_member.rast index 5a58f975a5b..15e96ad4d39 100644 --- a/crates/rome_js_parser/test_data/inline/ok/ts_index_signature_class_member.rast +++ b/crates/rome_js_parser/test_data/inline/ok/ts_index_signature_class_member.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@0..6 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -40,6 +41,7 @@ JsModule { r_curly_token: R_CURLY@34..36 "}" [Newline("\n")] [], }, JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@36..43 "class" [Newline("\n")] [Whitespace(" ")], id: JsIdentifierBinding { @@ -97,15 +99,16 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..78 0: JS_CLASS_DECLARATION@0..36 - 0: (empty) - 1: CLASS_KW@0..6 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@6..8 + 0: JS_DECORATOR_LIST@0..0 + 1: (empty) + 2: CLASS_KW@0..6 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@6..8 0: IDENT@6..8 "A" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@8..9 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@9..34 + 6: (empty) + 7: L_CURLY@8..9 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@9..34 0: TS_INDEX_SIGNATURE_CLASS_MEMBER@9..34 0: TS_INDEX_SIGNATURE_MODIFIER_LIST@9..9 1: L_BRACK@9..15 "[" [Newline("\n"), Whitespace(" ")] [] @@ -122,17 +125,18 @@ JsModule { 1: TS_STRING_TYPE@27..33 0: STRING_KW@27..33 "string" [] [] 5: SEMICOLON@33..34 ";" [] [] - 8: R_CURLY@34..36 "}" [Newline("\n")] [] + 9: R_CURLY@34..36 "}" [Newline("\n")] [] 1: JS_CLASS_DECLARATION@36..78 - 0: (empty) - 1: CLASS_KW@36..43 "class" [Newline("\n")] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@43..45 + 0: JS_DECORATOR_LIST@36..36 + 1: (empty) + 2: CLASS_KW@36..43 "class" [Newline("\n")] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@43..45 0: IDENT@43..45 "B" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@45..46 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@46..76 + 6: (empty) + 7: L_CURLY@45..46 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@46..76 0: TS_INDEX_SIGNATURE_CLASS_MEMBER@46..76 0: TS_INDEX_SIGNATURE_MODIFIER_LIST@46..46 1: L_BRACK@46..52 "[" [Newline("\n"), Whitespace(" ")] [] @@ -158,5 +162,5 @@ JsModule { 4: (empty) 2: R_CURLY@75..76 "}" [] [] 5: (empty) - 8: R_CURLY@76..78 "}" [Newline("\n")] [] + 9: R_CURLY@76..78 "}" [Newline("\n")] [] 3: EOF@78..79 "" [Newline("\n")] [] diff --git a/crates/rome_js_parser/test_data/inline/ok/ts_index_signature_class_member_can_be_static.rast b/crates/rome_js_parser/test_data/inline/ok/ts_index_signature_class_member_can_be_static.rast index 5927e336bd0..6d09e8c87f7 100644 --- a/crates/rome_js_parser/test_data/inline/ok/ts_index_signature_class_member_can_be_static.rast +++ b/crates/rome_js_parser/test_data/inline/ok/ts_index_signature_class_member_can_be_static.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@0..6 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -44,6 +45,7 @@ JsModule { r_curly_token: R_CURLY@41..43 "}" [Newline("\n")] [], }, JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@43..50 "class" [Newline("\n")] [Whitespace(" ")], id: JsIdentifierBinding { @@ -96,15 +98,16 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..96 0: JS_CLASS_DECLARATION@0..43 - 0: (empty) - 1: CLASS_KW@0..6 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@6..8 + 0: JS_DECORATOR_LIST@0..0 + 1: (empty) + 2: CLASS_KW@0..6 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@6..8 0: IDENT@6..8 "A" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@8..9 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@9..41 + 6: (empty) + 7: L_CURLY@8..9 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@9..41 0: TS_INDEX_SIGNATURE_CLASS_MEMBER@9..41 0: TS_INDEX_SIGNATURE_MODIFIER_LIST@9..21 0: JS_STATIC_MODIFIER@9..21 @@ -123,17 +126,18 @@ JsModule { 1: TS_STRING_TYPE@34..40 0: STRING_KW@34..40 "string" [] [] 5: SEMICOLON@40..41 ";" [] [] - 8: R_CURLY@41..43 "}" [Newline("\n")] [] + 9: R_CURLY@41..43 "}" [Newline("\n")] [] 1: JS_CLASS_DECLARATION@43..96 - 0: (empty) - 1: CLASS_KW@43..50 "class" [Newline("\n")] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@50..52 + 0: JS_DECORATOR_LIST@43..43 + 1: (empty) + 2: CLASS_KW@43..50 "class" [Newline("\n")] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@50..52 0: IDENT@50..52 "B" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@52..53 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@53..94 + 6: (empty) + 7: L_CURLY@52..53 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@53..94 0: TS_INDEX_SIGNATURE_CLASS_MEMBER@53..94 0: TS_INDEX_SIGNATURE_MODIFIER_LIST@53..74 0: JS_STATIC_MODIFIER@53..65 @@ -154,5 +158,5 @@ JsModule { 1: TS_STRING_TYPE@87..93 0: STRING_KW@87..93 "string" [] [] 5: SEMICOLON@93..94 ";" [] [] - 8: R_CURLY@94..96 "}" [Newline("\n")] [] + 9: R_CURLY@94..96 "}" [Newline("\n")] [] 3: EOF@96..97 "" [Newline("\n")] [] diff --git a/crates/rome_js_parser/test_data/inline/ok/ts_instantiation_expressions_1.rast b/crates/rome_js_parser/test_data/inline/ok/ts_instantiation_expressions_1.rast index b30f9e31803..cc034461478 100644 --- a/crates/rome_js_parser/test_data/inline/ok/ts_instantiation_expressions_1.rast +++ b/crates/rome_js_parser/test_data/inline/ok/ts_instantiation_expressions_1.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@0..6 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -1139,6 +1140,7 @@ JsModule { }, operator_token: R_ANGLE@508..510 ">" [] [Whitespace(" ")], right: JsClassExpression { + decorators: JsDecoratorList [], class_token: CLASS_KW@510..516 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { name_token: IDENT@516..518 "A" [] [Whitespace(" ")], @@ -1614,15 +1616,16 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..794 0: JS_CLASS_DECLARATION@0..48 - 0: (empty) - 1: CLASS_KW@0..6 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@6..8 + 0: JS_DECORATOR_LIST@0..0 + 1: (empty) + 2: CLASS_KW@0..6 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@6..8 0: IDENT@6..8 "A" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@8..9 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@9..46 + 6: (empty) + 7: L_CURLY@8..9 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@9..46 0: JS_CONSTRUCTOR_CLASS_MEMBER@9..46 0: JS_CONSTRUCTOR_MODIFIER_LIST@9..9 1: JS_LITERAL_MEMBER_NAME@9..22 @@ -1657,7 +1660,7 @@ JsModule { 2: R_PAREN@41..42 ")" [] [] 1: SEMICOLON@42..43 ";" [] [] 3: R_CURLY@43..46 "}" [Newline("\n"), Whitespace(" ")] [] - 8: R_CURLY@46..48 "}" [Newline("\n")] [] + 9: R_CURLY@46..48 "}" [Newline("\n")] [] 1: JS_EXPRESSION_STATEMENT@48..75 0: JS_TEMPLATE_EXPRESSION@48..74 0: JS_IDENTIFIER_EXPRESSION@48..50 @@ -2353,15 +2356,16 @@ JsModule { 0: IDENT@506..508 "T" [] [Whitespace(" ")] 1: R_ANGLE@508..510 ">" [] [Whitespace(" ")] 2: JS_CLASS_EXPRESSION@510..520 - 0: CLASS_KW@510..516 "class" [] [Whitespace(" ")] - 1: JS_IDENTIFIER_BINDING@516..518 + 0: JS_DECORATOR_LIST@510..510 + 1: CLASS_KW@510..516 "class" [] [Whitespace(" ")] + 2: JS_IDENTIFIER_BINDING@516..518 0: IDENT@516..518 "A" [] [Whitespace(" ")] - 2: (empty) 3: (empty) 4: (empty) - 5: L_CURLY@518..519 "{" [] [] - 6: JS_CLASS_MEMBER_LIST@519..519 - 7: R_CURLY@519..520 "}" [] [] + 5: (empty) + 6: L_CURLY@518..519 "{" [] [] + 7: JS_CLASS_MEMBER_LIST@519..519 + 8: R_CURLY@519..520 "}" [] [] 1: SEMICOLON@520..521 ";" [] [] 34: JS_EXPRESSION_STATEMENT@521..538 0: JS_BINARY_EXPRESSION@521..537 diff --git a/crates/rome_js_parser/test_data/inline/ok/ts_instantiation_expressions_asi.rast b/crates/rome_js_parser/test_data/inline/ok/ts_instantiation_expressions_asi.rast index 888ae3749b5..a47658cba95 100644 --- a/crates/rome_js_parser/test_data/inline/ok/ts_instantiation_expressions_asi.rast +++ b/crates/rome_js_parser/test_data/inline/ok/ts_instantiation_expressions_asi.rast @@ -241,6 +241,7 @@ JsModule { semicolon_token: missing (optional), }, JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@147..154 "class" [Newline("\n")] [Whitespace(" ")], id: JsIdentifierBinding { @@ -357,6 +358,7 @@ JsModule { semicolon_token: missing (optional), }, JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@211..218 "class" [Newline("\n")] [Whitespace(" ")], id: JsIdentifierBinding { @@ -420,6 +422,7 @@ JsModule { r_curly_token: R_CURLY@277..279 "}" [Newline("\n")] [], }, JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@279..286 "class" [Newline("\n")] [Whitespace(" ")], id: JsIdentifierBinding { @@ -483,6 +486,7 @@ JsModule { r_curly_token: R_CURLY@345..347 "}" [Newline("\n")] [], }, JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@347..354 "class" [Newline("\n")] [Whitespace(" ")], id: JsIdentifierBinding { @@ -546,6 +550,7 @@ JsModule { r_curly_token: R_CURLY@415..417 "}" [Newline("\n")] [], }, JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@417..424 "class" [Newline("\n")] [Whitespace(" ")], id: JsIdentifierBinding { @@ -609,6 +614,7 @@ JsModule { r_curly_token: R_CURLY@489..491 "}" [Newline("\n")] [], }, JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@491..498 "class" [Newline("\n")] [Whitespace(" ")], id: JsIdentifierBinding { @@ -889,16 +895,17 @@ JsModule { 2: R_ANGLE@146..147 ">" [] [] 1: (empty) 9: JS_CLASS_DECLARATION@147..158 - 0: (empty) - 1: CLASS_KW@147..154 "class" [Newline("\n")] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@154..156 + 0: JS_DECORATOR_LIST@147..147 + 1: (empty) + 2: CLASS_KW@147..154 "class" [Newline("\n")] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@154..156 0: IDENT@154..156 "C" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@156..157 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@157..157 - 8: R_CURLY@157..158 "}" [] [] + 6: (empty) + 7: L_CURLY@156..157 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@157..157 + 9: R_CURLY@157..158 "}" [] [] 10: JS_VARIABLE_STATEMENT@158..176 0: JS_VARIABLE_DECLARATION@158..176 0: LET_KW@158..163 "let" [Newline("\n")] [Whitespace(" ")] @@ -968,15 +975,16 @@ JsModule { 2: R_PAREN@210..211 ")" [] [] 1: (empty) 14: JS_CLASS_DECLARATION@211..279 - 0: (empty) - 1: CLASS_KW@211..218 "class" [Newline("\n")] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@218..221 + 0: JS_DECORATOR_LIST@211..211 + 1: (empty) + 2: CLASS_KW@211..218 "class" [Newline("\n")] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@218..221 0: IDENT@218..221 "C1" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@221..222 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@222..277 + 6: (empty) + 7: L_CURLY@221..222 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@222..277 0: JS_PROPERTY_CLASS_MEMBER@222..256 0: JS_PROPERTY_MODIFIER_LIST@222..234 0: JS_STATIC_MODIFIER@222..234 @@ -1009,17 +1017,18 @@ JsModule { 1: JS_NUMBER_LITERAL_EXPRESSION@274..277 0: JS_NUMBER_LITERAL@274..277 "123" [] [] 4: (empty) - 8: R_CURLY@277..279 "}" [Newline("\n")] [] + 9: R_CURLY@277..279 "}" [Newline("\n")] [] 15: JS_CLASS_DECLARATION@279..347 - 0: (empty) - 1: CLASS_KW@279..286 "class" [Newline("\n")] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@286..289 + 0: JS_DECORATOR_LIST@279..279 + 1: (empty) + 2: CLASS_KW@279..286 "class" [Newline("\n")] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@286..289 0: IDENT@286..289 "C2" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@289..290 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@290..345 + 6: (empty) + 7: L_CURLY@289..290 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@290..345 0: JS_PROPERTY_CLASS_MEMBER@290..324 0: JS_PROPERTY_MODIFIER_LIST@290..302 0: TS_ACCESSIBILITY_MODIFIER@290..302 @@ -1052,17 +1061,18 @@ JsModule { 1: JS_NUMBER_LITERAL_EXPRESSION@342..345 0: JS_NUMBER_LITERAL@342..345 "123" [] [] 4: (empty) - 8: R_CURLY@345..347 "}" [Newline("\n")] [] + 9: R_CURLY@345..347 "}" [Newline("\n")] [] 16: JS_CLASS_DECLARATION@347..417 - 0: (empty) - 1: CLASS_KW@347..354 "class" [Newline("\n")] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@354..357 + 0: JS_DECORATOR_LIST@347..347 + 1: (empty) + 2: CLASS_KW@347..354 "class" [Newline("\n")] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@354..357 0: IDENT@354..357 "C3" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@357..358 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@358..415 + 6: (empty) + 7: L_CURLY@357..358 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@358..415 0: JS_PROPERTY_CLASS_MEMBER@358..393 0: JS_PROPERTY_MODIFIER_LIST@358..371 0: TS_ACCESSIBILITY_MODIFIER@358..371 @@ -1095,17 +1105,18 @@ JsModule { 1: JS_NUMBER_LITERAL_EXPRESSION@412..415 0: JS_NUMBER_LITERAL@412..415 "123" [] [] 4: (empty) - 8: R_CURLY@415..417 "}" [Newline("\n")] [] + 9: R_CURLY@415..417 "}" [Newline("\n")] [] 17: JS_CLASS_DECLARATION@417..491 - 0: (empty) - 1: CLASS_KW@417..424 "class" [Newline("\n")] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@424..427 + 0: JS_DECORATOR_LIST@417..417 + 1: (empty) + 2: CLASS_KW@417..424 "class" [Newline("\n")] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@424..427 0: IDENT@424..427 "C4" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@427..428 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@428..489 + 6: (empty) + 7: L_CURLY@427..428 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@428..489 0: JS_PROPERTY_CLASS_MEMBER@428..465 0: JS_PROPERTY_MODIFIER_LIST@428..443 0: TS_ACCESSIBILITY_MODIFIER@428..443 @@ -1138,17 +1149,18 @@ JsModule { 1: JS_NUMBER_LITERAL_EXPRESSION@486..489 0: JS_NUMBER_LITERAL@486..489 "123" [] [] 4: (empty) - 8: R_CURLY@489..491 "}" [Newline("\n")] [] + 9: R_CURLY@489..491 "}" [Newline("\n")] [] 18: JS_CLASS_DECLARATION@491..556 - 0: (empty) - 1: CLASS_KW@491..498 "class" [Newline("\n")] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@498..501 + 0: JS_DECORATOR_LIST@491..491 + 1: (empty) + 2: CLASS_KW@491..498 "class" [Newline("\n")] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@498..501 0: IDENT@498..501 "C5" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@501..502 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@502..554 + 6: (empty) + 7: L_CURLY@501..502 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@502..554 0: JS_PROPERTY_CLASS_MEMBER@502..539 0: JS_PROPERTY_MODIFIER_LIST@502..517 0: TS_ACCESSIBILITY_MODIFIER@502..517 @@ -1180,7 +1192,7 @@ JsModule { 1: JS_NUMBER_LITERAL_EXPRESSION@551..554 0: JS_NUMBER_LITERAL@551..554 "123" [] [] 4: (empty) - 8: R_CURLY@554..556 "}" [Newline("\n")] [] + 9: R_CURLY@554..556 "}" [Newline("\n")] [] 19: JS_VARIABLE_STATEMENT@556..580 0: JS_VARIABLE_DECLARATION@556..580 0: CONST_KW@556..563 "const" [Newline("\n")] [Whitespace(" ")] diff --git a/crates/rome_js_parser/test_data/inline/ok/ts_instantiation_expressions_new_line.rast b/crates/rome_js_parser/test_data/inline/ok/ts_instantiation_expressions_new_line.rast index 422e636c432..a8b2093258d 100644 --- a/crates/rome_js_parser/test_data/inline/ok/ts_instantiation_expressions_new_line.rast +++ b/crates/rome_js_parser/test_data/inline/ok/ts_instantiation_expressions_new_line.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@0..6 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -1123,6 +1124,7 @@ JsModule { semicolon_token: missing (optional), }, JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@461..468 "class" [Newline("\n")] [Whitespace(" ")], id: JsIdentifierBinding { @@ -1595,15 +1597,16 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..687 0: JS_CLASS_DECLARATION@0..53 - 0: (empty) - 1: CLASS_KW@0..6 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@6..8 + 0: JS_DECORATOR_LIST@0..0 + 1: (empty) + 2: CLASS_KW@0..6 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@6..8 0: IDENT@6..8 "A" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@8..9 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@9..51 + 6: (empty) + 7: L_CURLY@8..9 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@9..51 0: JS_CONSTRUCTOR_CLASS_MEMBER@9..51 0: JS_CONSTRUCTOR_MODIFIER_LIST@9..9 1: JS_LITERAL_MEMBER_NAME@9..22 @@ -1642,7 +1645,7 @@ JsModule { 2: R_PAREN@46..47 ")" [] [] 1: SEMICOLON@47..48 ";" [] [] 3: R_CURLY@48..51 "}" [Newline("\n"), Whitespace(" ")] [] - 8: R_CURLY@51..53 "}" [Newline("\n")] [] + 9: R_CURLY@51..53 "}" [Newline("\n")] [] 1: JS_FUNCTION_DECLARATION@53..101 0: (empty) 1: FUNCTION_KW@53..63 "function" [Newline("\n")] [Whitespace(" ")] @@ -2324,16 +2327,17 @@ JsModule { 2: R_ANGLE@460..461 ">" [] [] 1: (empty) 40: JS_CLASS_DECLARATION@461..472 - 0: (empty) - 1: CLASS_KW@461..468 "class" [Newline("\n")] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@468..470 + 0: JS_DECORATOR_LIST@461..461 + 1: (empty) + 2: CLASS_KW@461..468 "class" [Newline("\n")] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@468..470 0: IDENT@468..470 "A" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@470..471 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@471..471 - 8: R_CURLY@471..472 "}" [] [] + 6: (empty) + 7: L_CURLY@470..471 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@471..471 + 9: R_CURLY@471..472 "}" [] [] 41: JS_EMPTY_STATEMENT@472..473 0: SEMICOLON@472..473 ";" [] [] 42: JS_EXPRESSION_STATEMENT@473..479 diff --git a/crates/rome_js_parser/test_data/inline/ok/ts_method_and_constructor_overload.rast b/crates/rome_js_parser/test_data/inline/ok/ts_method_and_constructor_overload.rast index 9023f5e10ec..e202391605b 100644 --- a/crates/rome_js_parser/test_data/inline/ok/ts_method_and_constructor_overload.rast +++ b/crates/rome_js_parser/test_data/inline/ok/ts_method_and_constructor_overload.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@0..6 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -253,15 +254,16 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..251 0: JS_CLASS_DECLARATION@0..251 - 0: (empty) - 1: CLASS_KW@0..6 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@6..11 + 0: JS_DECORATOR_LIST@0..0 + 1: (empty) + 2: CLASS_KW@0..6 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@6..11 0: IDENT@6..11 "Test" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@11..12 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@12..249 + 6: (empty) + 7: L_CURLY@11..12 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@12..249 0: TS_CONSTRUCTOR_SIGNATURE_CLASS_MEMBER@12..32 0: JS_CONSTRUCTOR_MODIFIER_LIST@12..12 1: JS_LITERAL_MEMBER_NAME@12..29 @@ -422,5 +424,5 @@ JsModule { 0: JS_STRING_LITERAL@241..248 "\"test\"" [] [Whitespace(" ")] 2: (empty) 3: R_CURLY@248..249 "}" [] [] - 8: R_CURLY@249..251 "}" [Newline("\n")] [] + 9: R_CURLY@249..251 "}" [Newline("\n")] [] 3: EOF@251..252 "" [Newline("\n")] [] diff --git a/crates/rome_js_parser/test_data/inline/ok/ts_method_class_member.rast b/crates/rome_js_parser/test_data/inline/ok/ts_method_class_member.rast index 04c95212890..91b44ddf9ea 100644 --- a/crates/rome_js_parser/test_data/inline/ok/ts_method_class_member.rast +++ b/crates/rome_js_parser/test_data/inline/ok/ts_method_class_member.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@0..6 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -128,15 +129,16 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..58 0: JS_CLASS_DECLARATION@0..58 - 0: (empty) - 1: CLASS_KW@0..6 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@6..11 + 0: JS_DECORATOR_LIST@0..0 + 1: (empty) + 2: CLASS_KW@0..6 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@6..11 0: IDENT@6..11 "Test" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@11..12 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@12..56 + 6: (empty) + 7: L_CURLY@11..12 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@12..56 0: JS_METHOD_CLASS_MEMBER@12..56 0: JS_METHOD_MODIFIER_LIST@12..12 1: (empty) @@ -211,5 +213,5 @@ JsModule { 1: JS_DIRECTIVE_LIST@55..55 2: JS_STATEMENT_LIST@55..55 3: R_CURLY@55..56 "}" [] [] - 8: R_CURLY@56..58 "}" [Newline("\n")] [] + 9: R_CURLY@56..58 "}" [Newline("\n")] [] 3: EOF@58..59 "" [Newline("\n")] [] diff --git a/crates/rome_js_parser/test_data/inline/ok/ts_new_with_type_arguments.rast b/crates/rome_js_parser/test_data/inline/ok/ts_new_with_type_arguments.rast index 3d0173cd486..aeae9596ca1 100644 --- a/crates/rome_js_parser/test_data/inline/ok/ts_new_with_type_arguments.rast +++ b/crates/rome_js_parser/test_data/inline/ok/ts_new_with_type_arguments.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@0..6 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -97,11 +98,12 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..43 0: JS_CLASS_DECLARATION@0..22 - 0: (empty) - 1: CLASS_KW@0..6 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@6..10 + 0: JS_DECORATOR_LIST@0..0 + 1: (empty) + 2: CLASS_KW@0..6 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@6..10 0: IDENT@6..10 "Test" [] [] - 3: TS_TYPE_PARAMETERS@10..20 + 4: TS_TYPE_PARAMETERS@10..20 0: L_ANGLE@10..11 "<" [] [] 1: TS_TYPE_PARAMETER_LIST@11..18 0: TS_TYPE_PARAMETER@11..12 @@ -125,11 +127,11 @@ JsModule { 2: (empty) 3: (empty) 2: R_ANGLE@18..20 ">" [] [Whitespace(" ")] - 4: (empty) 5: (empty) - 6: L_CURLY@20..21 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@21..21 - 8: R_CURLY@21..22 "}" [] [] + 6: (empty) + 7: L_CURLY@20..21 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@21..21 + 9: R_CURLY@21..22 "}" [] [] 1: JS_EXPRESSION_STATEMENT@22..43 0: JS_NEW_EXPRESSION@22..42 0: NEW_KW@22..27 "new" [Newline("\n")] [Whitespace(" ")] diff --git a/crates/rome_js_parser/test_data/inline/ok/ts_optional_method_class_member.rast b/crates/rome_js_parser/test_data/inline/ok/ts_optional_method_class_member.rast index eb36423aaa3..6db915ef8bc 100644 --- a/crates/rome_js_parser/test_data/inline/ok/ts_optional_method_class_member.rast +++ b/crates/rome_js_parser/test_data/inline/ok/ts_optional_method_class_member.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@0..6 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -47,15 +48,16 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..22 0: JS_CLASS_DECLARATION@0..22 - 0: (empty) - 1: CLASS_KW@0..6 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@6..8 + 0: JS_DECORATOR_LIST@0..0 + 1: (empty) + 2: CLASS_KW@0..6 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@6..8 0: IDENT@6..8 "A" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@8..10 "{" [] [Whitespace(" ")] - 7: JS_CLASS_MEMBER_LIST@10..21 + 6: (empty) + 7: L_CURLY@8..10 "{" [] [Whitespace(" ")] + 8: JS_CLASS_MEMBER_LIST@10..21 0: JS_METHOD_CLASS_MEMBER@10..21 0: JS_METHOD_MODIFIER_LIST@10..10 1: (empty) @@ -74,5 +76,5 @@ JsModule { 1: JS_DIRECTIVE_LIST@19..19 2: JS_STATEMENT_LIST@19..19 3: R_CURLY@19..21 "}" [] [Whitespace(" ")] - 8: R_CURLY@21..22 "}" [] [] + 9: R_CURLY@21..22 "}" [] [] 3: EOF@22..23 "" [Newline("\n")] [] diff --git a/crates/rome_js_parser/test_data/inline/ok/ts_parameter_option_binding_pattern.rast b/crates/rome_js_parser/test_data/inline/ok/ts_parameter_option_binding_pattern.rast index 1e12a8b2315..3a9168e4f43 100644 --- a/crates/rome_js_parser/test_data/inline/ok/ts_parameter_option_binding_pattern.rast +++ b/crates/rome_js_parser/test_data/inline/ok/ts_parameter_option_binding_pattern.rast @@ -15,6 +15,7 @@ JsModule { JsExport { export_token: EXPORT_KW@21..31 "export" [Newline("\n"), Whitespace(" ")] [Whitespace(" ")], export_clause: JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@31..37 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -139,15 +140,16 @@ JsModule { 0: JS_EXPORT@21..152 0: EXPORT_KW@21..31 "export" [Newline("\n"), Whitespace(" ")] [Whitespace(" ")] 1: JS_CLASS_DECLARATION@31..152 - 0: (empty) - 1: CLASS_KW@31..37 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@37..41 + 0: JS_DECORATOR_LIST@31..31 + 1: (empty) + 2: CLASS_KW@31..37 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@37..41 0: IDENT@37..41 "Ajv" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@41..42 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@42..148 + 6: (empty) + 7: L_CURLY@41..42 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@42..148 0: TS_METHOD_SIGNATURE_CLASS_MEMBER@42..148 0: TS_METHOD_SIGNATURE_MODIFIER_LIST@42..42 1: (empty) @@ -208,6 +210,6 @@ JsModule { 1: TS_STRING_TYPE@141..147 0: STRING_KW@141..147 "string" [] [] 7: SEMICOLON@147..148 ";" [] [] - 8: R_CURLY@148..152 "}" [Newline("\n"), Whitespace(" ")] [] + 9: R_CURLY@148..152 "}" [Newline("\n"), Whitespace(" ")] [] 2: R_CURLY@152..154 "}" [Newline("\n")] [] 3: EOF@154..155 "" [Newline("\n")] [] diff --git a/crates/rome_js_parser/test_data/inline/ok/ts_property_class_member_can_be_named_set_or_get.rast b/crates/rome_js_parser/test_data/inline/ok/ts_property_class_member_can_be_named_set_or_get.rast index 83296e6ad09..a6608b89d3c 100644 --- a/crates/rome_js_parser/test_data/inline/ok/ts_property_class_member_can_be_named_set_or_get.rast +++ b/crates/rome_js_parser/test_data/inline/ok/ts_property_class_member_can_be_named_set_or_get.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@0..6 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -59,15 +60,16 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..36 0: JS_CLASS_DECLARATION@0..36 - 0: (empty) - 1: CLASS_KW@0..6 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@6..8 + 0: JS_DECORATOR_LIST@0..0 + 1: (empty) + 2: CLASS_KW@0..6 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@6..8 0: IDENT@6..8 "B" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@8..10 "{" [] [Whitespace(" ")] - 7: JS_CLASS_MEMBER_LIST@10..35 + 6: (empty) + 7: L_CURLY@8..10 "{" [] [Whitespace(" ")] + 8: JS_CLASS_MEMBER_LIST@10..35 0: JS_PROPERTY_CLASS_MEMBER@10..23 0: JS_PROPERTY_MODIFIER_LIST@10..10 1: JS_LITERAL_MEMBER_NAME@10..13 @@ -92,5 +94,5 @@ JsModule { 1: (empty) 3: (empty) 4: (empty) - 8: R_CURLY@35..36 "}" [] [] + 9: R_CURLY@35..36 "}" [] [] 3: EOF@36..37 "" [Newline("\n")] [] diff --git a/crates/rome_js_parser/test_data/inline/ok/ts_property_parameter.rast b/crates/rome_js_parser/test_data/inline/ok/ts_property_parameter.rast index d4d14ebd3e2..49df5379f54 100644 --- a/crates/rome_js_parser/test_data/inline/ok/ts_property_parameter.rast +++ b/crates/rome_js_parser/test_data/inline/ok/ts_property_parameter.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@0..6 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -82,6 +83,7 @@ JsModule { r_curly_token: R_CURLY@59..60 "}" [] [], }, JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@60..67 "class" [Newline("\n")] [Whitespace(" ")], id: JsIdentifierBinding { @@ -186,6 +188,7 @@ JsModule { r_curly_token: R_CURLY@159..160 "}" [] [], }, JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@160..167 "class" [Newline("\n")] [Whitespace(" ")], id: JsIdentifierBinding { @@ -284,15 +287,16 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..243 0: JS_CLASS_DECLARATION@0..60 - 0: (empty) - 1: CLASS_KW@0..6 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@6..8 + 0: JS_DECORATOR_LIST@0..0 + 1: (empty) + 2: CLASS_KW@0..6 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@6..8 0: IDENT@6..8 "A" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@8..10 "{" [] [Whitespace(" ")] - 7: JS_CLASS_MEMBER_LIST@10..59 + 6: (empty) + 7: L_CURLY@8..10 "{" [] [Whitespace(" ")] + 8: JS_CLASS_MEMBER_LIST@10..59 0: JS_CONSTRUCTOR_CLASS_MEMBER@10..59 0: JS_CONSTRUCTOR_MODIFIER_LIST@10..10 1: JS_LITERAL_MEMBER_NAME@10..21 @@ -338,17 +342,18 @@ JsModule { 1: JS_DIRECTIVE_LIST@57..57 2: JS_STATEMENT_LIST@57..57 3: R_CURLY@57..59 "}" [] [Whitespace(" ")] - 8: R_CURLY@59..60 "}" [] [] + 9: R_CURLY@59..60 "}" [] [] 1: JS_CLASS_DECLARATION@60..160 - 0: (empty) - 1: CLASS_KW@60..67 "class" [Newline("\n")] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@67..69 + 0: JS_DECORATOR_LIST@60..60 + 1: (empty) + 2: CLASS_KW@60..67 "class" [Newline("\n")] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@67..69 0: IDENT@67..69 "B" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@69..71 "{" [] [Whitespace(" ")] - 7: JS_CLASS_MEMBER_LIST@71..159 + 6: (empty) + 7: L_CURLY@69..71 "{" [] [Whitespace(" ")] + 8: JS_CLASS_MEMBER_LIST@71..159 0: JS_CONSTRUCTOR_CLASS_MEMBER@71..159 0: JS_CONSTRUCTOR_MODIFIER_LIST@71..71 1: JS_LITERAL_MEMBER_NAME@71..82 @@ -411,17 +416,18 @@ JsModule { 1: JS_DIRECTIVE_LIST@157..157 2: JS_STATEMENT_LIST@157..157 3: R_CURLY@157..159 "}" [] [Whitespace(" ")] - 8: R_CURLY@159..160 "}" [] [] + 9: R_CURLY@159..160 "}" [] [] 2: JS_CLASS_DECLARATION@160..243 - 0: (empty) - 1: CLASS_KW@160..167 "class" [Newline("\n")] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@167..169 + 0: JS_DECORATOR_LIST@160..160 + 1: (empty) + 2: CLASS_KW@160..167 "class" [Newline("\n")] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@167..169 0: IDENT@167..169 "C" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@169..171 "{" [] [Whitespace(" ")] - 7: JS_CLASS_MEMBER_LIST@171..242 + 6: (empty) + 7: L_CURLY@169..171 "{" [] [Whitespace(" ")] + 8: JS_CLASS_MEMBER_LIST@171..242 0: JS_CONSTRUCTOR_CLASS_MEMBER@171..242 0: JS_CONSTRUCTOR_MODIFIER_LIST@171..171 1: JS_LITERAL_MEMBER_NAME@171..182 @@ -475,5 +481,5 @@ JsModule { 1: JS_DIRECTIVE_LIST@240..240 2: JS_STATEMENT_LIST@240..240 3: R_CURLY@240..242 "}" [] [Whitespace(" ")] - 8: R_CURLY@242..243 "}" [] [] + 9: R_CURLY@242..243 "}" [] [] 3: EOF@243..244 "" [Newline("\n")] [] diff --git a/crates/rome_js_parser/test_data/inline/ok/ts_readonly_property_initializer_ambient_context.rast b/crates/rome_js_parser/test_data/inline/ok/ts_readonly_property_initializer_ambient_context.rast index d04996aa4e6..6926a6395d5 100644 --- a/crates/rome_js_parser/test_data/inline/ok/ts_readonly_property_initializer_ambient_context.rast +++ b/crates/rome_js_parser/test_data/inline/ok/ts_readonly_property_initializer_ambient_context.rast @@ -5,6 +5,7 @@ JsModule { TsDeclareStatement { declare_token: DECLARE_KW@0..8 "declare" [] [Whitespace(" ")], declaration: JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@8..14 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -38,6 +39,7 @@ JsModule { }, }, JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@43..50 "class" [Newline("\n")] [Whitespace(" ")], id: JsIdentifierBinding { @@ -75,6 +77,7 @@ JsModule { TsDeclareStatement { declare_token: DECLARE_KW@87..96 "declare" [Newline("\n")] [Whitespace(" ")], declaration: JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@96..102 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -111,6 +114,7 @@ JsModule { }, }, JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@139..146 "class" [Newline("\n")] [Whitespace(" ")], id: JsIdentifierBinding { @@ -151,6 +155,7 @@ JsModule { TsDeclareStatement { declare_token: DECLARE_KW@191..200 "declare" [Newline("\n")] [Whitespace(" ")], declaration: JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@200..206 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -187,6 +192,7 @@ JsModule { }, }, JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@242..249 "class" [Newline("\n")] [Whitespace(" ")], id: JsIdentifierBinding { @@ -235,15 +241,16 @@ JsModule { 0: TS_DECLARE_STATEMENT@0..43 0: DECLARE_KW@0..8 "declare" [] [Whitespace(" ")] 1: JS_CLASS_DECLARATION@8..43 - 0: (empty) - 1: CLASS_KW@8..14 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@14..16 + 0: JS_DECORATOR_LIST@8..8 + 1: (empty) + 2: CLASS_KW@8..14 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@14..16 0: IDENT@14..16 "A" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@16..18 "{" [] [Whitespace(" ")] - 7: JS_CLASS_MEMBER_LIST@18..42 + 6: (empty) + 7: L_CURLY@16..18 "{" [] [Whitespace(" ")] + 8: JS_CLASS_MEMBER_LIST@18..42 0: TS_INITIALIZED_PROPERTY_SIGNATURE_CLASS_MEMBER@18..42 0: TS_PROPERTY_SIGNATURE_MODIFIER_LIST@18..27 0: TS_READONLY_MODIFIER@18..27 @@ -256,17 +263,18 @@ JsModule { 1: JS_STRING_LITERAL_EXPRESSION@34..40 0: JS_STRING_LITERAL@34..40 "\"test\"" [] [] 4: SEMICOLON@40..42 ";" [] [Whitespace(" ")] - 8: R_CURLY@42..43 "}" [] [] + 9: R_CURLY@42..43 "}" [] [] 1: JS_CLASS_DECLARATION@43..87 - 0: (empty) - 1: CLASS_KW@43..50 "class" [Newline("\n")] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@50..52 + 0: JS_DECORATOR_LIST@43..43 + 1: (empty) + 2: CLASS_KW@43..50 "class" [Newline("\n")] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@50..52 0: IDENT@50..52 "B" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@52..54 "{" [] [Whitespace(" ")] - 7: JS_CLASS_MEMBER_LIST@54..86 + 6: (empty) + 7: L_CURLY@52..54 "{" [] [Whitespace(" ")] + 8: JS_CLASS_MEMBER_LIST@54..86 0: TS_INITIALIZED_PROPERTY_SIGNATURE_CLASS_MEMBER@54..86 0: TS_PROPERTY_SIGNATURE_MODIFIER_LIST@54..71 0: TS_DECLARE_MODIFIER@54..62 @@ -281,19 +289,20 @@ JsModule { 1: JS_STRING_LITERAL_EXPRESSION@78..84 0: JS_STRING_LITERAL@78..84 "\"test\"" [] [] 4: SEMICOLON@84..86 ";" [] [Whitespace(" ")] - 8: R_CURLY@86..87 "}" [] [] + 9: R_CURLY@86..87 "}" [] [] 2: TS_DECLARE_STATEMENT@87..139 0: DECLARE_KW@87..96 "declare" [Newline("\n")] [Whitespace(" ")] 1: JS_CLASS_DECLARATION@96..139 - 0: (empty) - 1: CLASS_KW@96..102 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@102..104 + 0: JS_DECORATOR_LIST@96..96 + 1: (empty) + 2: CLASS_KW@96..102 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@102..104 0: IDENT@102..104 "A" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@104..106 "{" [] [Whitespace(" ")] - 7: JS_CLASS_MEMBER_LIST@106..138 + 6: (empty) + 7: L_CURLY@104..106 "{" [] [Whitespace(" ")] + 8: JS_CLASS_MEMBER_LIST@106..138 0: TS_INITIALIZED_PROPERTY_SIGNATURE_CLASS_MEMBER@106..138 0: TS_PROPERTY_SIGNATURE_MODIFIER_LIST@106..123 0: TS_ACCESSIBILITY_MODIFIER@106..114 @@ -308,17 +317,18 @@ JsModule { 1: JS_STRING_LITERAL_EXPRESSION@130..136 0: JS_STRING_LITERAL@130..136 "\"test\"" [] [] 4: SEMICOLON@136..138 ";" [] [Whitespace(" ")] - 8: R_CURLY@138..139 "}" [] [] + 9: R_CURLY@138..139 "}" [] [] 3: JS_CLASS_DECLARATION@139..191 - 0: (empty) - 1: CLASS_KW@139..146 "class" [Newline("\n")] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@146..148 + 0: JS_DECORATOR_LIST@139..139 + 1: (empty) + 2: CLASS_KW@139..146 "class" [Newline("\n")] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@146..148 0: IDENT@146..148 "B" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@148..150 "{" [] [Whitespace(" ")] - 7: JS_CLASS_MEMBER_LIST@150..190 + 6: (empty) + 7: L_CURLY@148..150 "{" [] [Whitespace(" ")] + 8: JS_CLASS_MEMBER_LIST@150..190 0: TS_INITIALIZED_PROPERTY_SIGNATURE_CLASS_MEMBER@150..190 0: TS_PROPERTY_SIGNATURE_MODIFIER_LIST@150..175 0: TS_DECLARE_MODIFIER@150..158 @@ -335,19 +345,20 @@ JsModule { 1: JS_STRING_LITERAL_EXPRESSION@182..188 0: JS_STRING_LITERAL@182..188 "\"test\"" [] [] 4: SEMICOLON@188..190 ";" [] [Whitespace(" ")] - 8: R_CURLY@190..191 "}" [] [] + 9: R_CURLY@190..191 "}" [] [] 4: TS_DECLARE_STATEMENT@191..242 0: DECLARE_KW@191..200 "declare" [Newline("\n")] [Whitespace(" ")] 1: JS_CLASS_DECLARATION@200..242 - 0: (empty) - 1: CLASS_KW@200..206 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@206..208 + 0: JS_DECORATOR_LIST@200..200 + 1: (empty) + 2: CLASS_KW@200..206 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@206..208 0: IDENT@206..208 "A" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@208..210 "{" [] [Whitespace(" ")] - 7: JS_CLASS_MEMBER_LIST@210..241 + 6: (empty) + 7: L_CURLY@208..210 "{" [] [Whitespace(" ")] + 8: JS_CLASS_MEMBER_LIST@210..241 0: TS_INITIALIZED_PROPERTY_SIGNATURE_CLASS_MEMBER@210..241 0: TS_PROPERTY_SIGNATURE_MODIFIER_LIST@210..226 0: JS_STATIC_MODIFIER@210..217 @@ -362,17 +373,18 @@ JsModule { 1: JS_STRING_LITERAL_EXPRESSION@233..239 0: JS_STRING_LITERAL@233..239 "\"test\"" [] [] 4: SEMICOLON@239..241 ";" [] [Whitespace(" ")] - 8: R_CURLY@241..242 "}" [] [] + 9: R_CURLY@241..242 "}" [] [] 5: JS_CLASS_DECLARATION@242..293 - 0: (empty) - 1: CLASS_KW@242..249 "class" [Newline("\n")] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@249..251 + 0: JS_DECORATOR_LIST@242..242 + 1: (empty) + 2: CLASS_KW@242..249 "class" [Newline("\n")] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@249..251 0: IDENT@249..251 "B" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@251..253 "{" [] [Whitespace(" ")] - 7: JS_CLASS_MEMBER_LIST@253..292 + 6: (empty) + 7: L_CURLY@251..253 "{" [] [Whitespace(" ")] + 8: JS_CLASS_MEMBER_LIST@253..292 0: TS_INITIALIZED_PROPERTY_SIGNATURE_CLASS_MEMBER@253..292 0: TS_PROPERTY_SIGNATURE_MODIFIER_LIST@253..277 0: TS_DECLARE_MODIFIER@253..261 @@ -389,5 +401,5 @@ JsModule { 1: JS_STRING_LITERAL_EXPRESSION@284..290 0: JS_STRING_LITERAL@284..290 "\"test\"" [] [] 4: SEMICOLON@290..292 ";" [] [Whitespace(" ")] - 8: R_CURLY@292..293 "}" [] [] + 9: R_CURLY@292..293 "}" [] [] 3: EOF@293..294 "" [Newline("\n")] [] diff --git a/crates/rome_js_parser/test_data/inline/ok/ts_return_type_annotation.rast b/crates/rome_js_parser/test_data/inline/ok/ts_return_type_annotation.rast index 018ac7d5597..7cabe9e6291 100644 --- a/crates/rome_js_parser/test_data/inline/ok/ts_return_type_annotation.rast +++ b/crates/rome_js_parser/test_data/inline/ok/ts_return_type_annotation.rast @@ -215,6 +215,7 @@ JsModule { semicolon_token: missing (optional), }, JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@160..167 "class" [Newline("\n")] [Whitespace(" ")], id: JsIdentifierBinding { @@ -447,15 +448,16 @@ JsModule { 2: R_CURLY@159..160 "}" [] [] 1: (empty) 4: JS_CLASS_DECLARATION@160..227 - 0: (empty) - 1: CLASS_KW@160..167 "class" [Newline("\n")] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@167..169 + 0: JS_DECORATOR_LIST@160..160 + 1: (empty) + 2: CLASS_KW@160..167 "class" [Newline("\n")] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@167..169 0: IDENT@167..169 "D" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@169..171 "{" [] [Whitespace(" ")] - 7: JS_CLASS_MEMBER_LIST@171..226 + 6: (empty) + 7: L_CURLY@169..171 "{" [] [Whitespace(" ")] + 8: JS_CLASS_MEMBER_LIST@171..226 0: JS_METHOD_CLASS_MEMBER@171..226 0: JS_METHOD_MODIFIER_LIST@171..171 1: (empty) @@ -499,5 +501,5 @@ JsModule { 0: JS_STRING_LITERAL@214..222 "\"string\"" [] [] 2: SEMICOLON@222..224 ";" [] [Whitespace(" ")] 3: R_CURLY@224..226 "}" [] [Whitespace(" ")] - 8: R_CURLY@226..227 "}" [] [] + 9: R_CURLY@226..227 "}" [] [] 3: EOF@227..228 "" [Newline("\n")] [] diff --git a/crates/rome_js_parser/test_data/inline/ok/ts_this_type.rast b/crates/rome_js_parser/test_data/inline/ok/ts_this_type.rast index 6204eee779a..61c78ee2942 100644 --- a/crates/rome_js_parser/test_data/inline/ok/ts_this_type.rast +++ b/crates/rome_js_parser/test_data/inline/ok/ts_this_type.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@0..6 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -110,15 +111,16 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..135 0: JS_CLASS_DECLARATION@0..135 - 0: (empty) - 1: CLASS_KW@0..6 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@6..8 + 0: JS_DECORATOR_LIST@0..0 + 1: (empty) + 2: CLASS_KW@0..6 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@6..8 0: IDENT@6..8 "A" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@8..9 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@9..133 + 6: (empty) + 7: L_CURLY@8..9 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@9..133 0: JS_METHOD_CLASS_MEMBER@9..53 0: JS_METHOD_MODIFIER_LIST@9..9 1: (empty) @@ -182,5 +184,5 @@ JsModule { 0: JS_STRING_LITERAL@119..127 "\"string\"" [] [] 2: (empty) 3: R_CURLY@127..133 "}" [Newline("\n"), Whitespace(" ")] [] - 8: R_CURLY@133..135 "}" [Newline("\n")] [] + 9: R_CURLY@133..135 "}" [Newline("\n")] [] 3: EOF@135..136 "" [Newline("\n")] [] diff --git a/crates/rome_js_parser/test_data/inline/ok/type_parameter_modifier.rast b/crates/rome_js_parser/test_data/inline/ok/type_parameter_modifier.rast index 3dd3d4448c2..fb237332020 100644 --- a/crates/rome_js_parser/test_data/inline/ok/type_parameter_modifier.rast +++ b/crates/rome_js_parser/test_data/inline/ok/type_parameter_modifier.rast @@ -331,6 +331,7 @@ JsModule { semicolon_token: missing (optional), }, JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@228..235 "class" [Newline("\n")] [Whitespace(" ")], id: JsIdentifierBinding { @@ -361,6 +362,7 @@ JsModule { r_curly_token: R_CURLY@246..247 "}" [] [], }, JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@247..254 "class" [Newline("\n")] [Whitespace(" ")], id: JsIdentifierBinding { @@ -395,6 +397,7 @@ JsModule { export_clause: JsExportDefaultDeclarationClause { default_token: DEFAULT_KW@275..283 "default" [] [Whitespace(" ")], declaration: JsClassExportDefaultDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@283..289 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -428,6 +431,7 @@ JsModule { }, }, JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@301..308 "class" [Newline("\n")] [Whitespace(" ")], id: JsIdentifierBinding { @@ -516,6 +520,7 @@ JsModule { TsDeclareStatement { declare_token: DECLARE_KW@368..377 "declare" [Newline("\n")] [Whitespace(" ")], declaration: JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@377..383 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -549,6 +554,7 @@ JsModule { TsDeclareStatement { declare_token: DECLARE_KW@395..404 "declare" [Newline("\n")] [Whitespace(" ")], declaration: JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@404..410 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -1024,6 +1030,7 @@ JsModule { semicolon_token: SEMICOLON@730..731 ";" [] [], }, JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@731..738 "class" [Newline("\n")] [Whitespace(" ")], id: JsIdentifierBinding { @@ -1054,6 +1061,7 @@ JsModule { r_curly_token: R_CURLY@750..751 "}" [] [], }, JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@751..758 "class" [Newline("\n")] [Whitespace(" ")], id: JsIdentifierBinding { @@ -1092,6 +1100,7 @@ JsModule { r_curly_token: R_CURLY@780..781 "}" [] [], }, JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@781..788 "class" [Newline("\n")] [Whitespace(" ")], id: JsIdentifierBinding { @@ -1131,6 +1140,7 @@ JsModule { r_curly_token: R_CURLY@803..804 "}" [] [], }, JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@804..811 "class" [Newline("\n")] [Whitespace(" ")], id: JsIdentifierBinding { @@ -1164,6 +1174,7 @@ JsModule { r_curly_token: R_CURLY@826..827 "}" [] [], }, JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@827..834 "class" [Newline("\n")] [Whitespace(" ")], id: JsIdentifierBinding { @@ -1197,6 +1208,7 @@ JsModule { r_curly_token: R_CURLY@849..850 "}" [] [], }, JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@850..857 "class" [Newline("\n")] [Whitespace(" ")], id: JsIdentifierBinding { @@ -1236,6 +1248,7 @@ JsModule { expression: JsParenthesizedExpression { l_paren_token: L_PAREN@877..879 "(" [Newline("\n")] [], expression: JsClassExpression { + decorators: JsDecoratorList [], class_token: CLASS_KW@879..885 "class" [] [Whitespace(" ")], id: missing (optional), type_parameters: TsTypeParameters { @@ -1270,6 +1283,7 @@ JsModule { expression: JsParenthesizedExpression { l_paren_token: L_PAREN@899..901 "(" [Newline("\n")] [], expression: JsClassExpression { + decorators: JsDecoratorList [], class_token: CLASS_KW@901..907 "class" [] [Whitespace(" ")], id: missing (optional), type_parameters: TsTypeParameters { @@ -1312,6 +1326,7 @@ JsModule { expression: JsParenthesizedExpression { l_paren_token: L_PAREN@931..933 "(" [Newline("\n")] [], expression: JsClassExpression { + decorators: JsDecoratorList [], class_token: CLASS_KW@933..939 "class" [] [Whitespace(" ")], id: missing (optional), type_parameters: TsTypeParameters { @@ -1355,6 +1370,7 @@ JsModule { expression: JsParenthesizedExpression { l_paren_token: L_PAREN@956..958 "(" [Newline("\n")] [], expression: JsClassExpression { + decorators: JsDecoratorList [], class_token: CLASS_KW@958..964 "class" [] [Whitespace(" ")], id: missing (optional), type_parameters: TsTypeParameters { @@ -1392,6 +1408,7 @@ JsModule { expression: JsParenthesizedExpression { l_paren_token: L_PAREN@981..983 "(" [Newline("\n")] [], expression: JsClassExpression { + decorators: JsDecoratorList [], class_token: CLASS_KW@983..989 "class" [] [Whitespace(" ")], id: missing (optional), type_parameters: TsTypeParameters { @@ -1426,6 +1443,7 @@ JsModule { semicolon_token: SEMICOLON@1005..1006 ";" [] [], }, JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@1006..1013 "class" [Newline("\n")] [Whitespace(" ")], id: JsIdentifierBinding { @@ -1965,11 +1983,12 @@ JsModule { 2: R_CURLY@227..228 "}" [] [] 5: (empty) 9: JS_CLASS_DECLARATION@228..247 - 0: (empty) - 1: CLASS_KW@228..235 "class" [Newline("\n")] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@235..238 + 0: JS_DECORATOR_LIST@228..228 + 1: (empty) + 2: CLASS_KW@228..235 "class" [Newline("\n")] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@235..238 0: IDENT@235..238 "Foo" [] [] - 3: TS_TYPE_PARAMETERS@238..245 + 4: TS_TYPE_PARAMETERS@238..245 0: L_ANGLE@238..239 "<" [] [] 1: TS_TYPE_PARAMETER_LIST@239..243 0: TS_TYPE_PARAMETER@239..243 @@ -1981,17 +2000,18 @@ JsModule { 2: (empty) 3: (empty) 2: R_ANGLE@243..245 ">" [] [Whitespace(" ")] - 4: (empty) 5: (empty) - 6: L_CURLY@245..246 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@246..246 - 8: R_CURLY@246..247 "}" [] [] + 6: (empty) + 7: L_CURLY@245..246 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@246..246 + 9: R_CURLY@246..247 "}" [] [] 10: JS_CLASS_DECLARATION@247..267 - 0: (empty) - 1: CLASS_KW@247..254 "class" [Newline("\n")] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@254..257 + 0: JS_DECORATOR_LIST@247..247 + 1: (empty) + 2: CLASS_KW@247..254 "class" [Newline("\n")] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@254..257 0: IDENT@254..257 "Foo" [] [] - 3: TS_TYPE_PARAMETERS@257..265 + 4: TS_TYPE_PARAMETERS@257..265 0: L_ANGLE@257..258 "<" [] [] 1: TS_TYPE_PARAMETER_LIST@258..263 0: TS_TYPE_PARAMETER@258..263 @@ -2003,21 +2023,22 @@ JsModule { 2: (empty) 3: (empty) 2: R_ANGLE@263..265 ">" [] [Whitespace(" ")] - 4: (empty) 5: (empty) - 6: L_CURLY@265..266 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@266..266 - 8: R_CURLY@266..267 "}" [] [] + 6: (empty) + 7: L_CURLY@265..266 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@266..266 + 9: R_CURLY@266..267 "}" [] [] 11: JS_EXPORT@267..301 0: EXPORT_KW@267..275 "export" [Newline("\n")] [Whitespace(" ")] 1: JS_EXPORT_DEFAULT_DECLARATION_CLAUSE@275..301 0: DEFAULT_KW@275..283 "default" [] [Whitespace(" ")] 1: JS_CLASS_EXPORT_DEFAULT_DECLARATION@283..301 - 0: (empty) - 1: CLASS_KW@283..289 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@289..292 + 0: JS_DECORATOR_LIST@283..283 + 1: (empty) + 2: CLASS_KW@283..289 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@289..292 0: IDENT@289..292 "Foo" [] [] - 3: TS_TYPE_PARAMETERS@292..299 + 4: TS_TYPE_PARAMETERS@292..299 0: L_ANGLE@292..293 "<" [] [] 1: TS_TYPE_PARAMETER_LIST@293..297 0: TS_TYPE_PARAMETER@293..297 @@ -2029,18 +2050,19 @@ JsModule { 2: (empty) 3: (empty) 2: R_ANGLE@297..299 ">" [] [Whitespace(" ")] - 4: (empty) 5: (empty) - 6: L_CURLY@299..300 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@300..300 - 8: R_CURLY@300..301 "}" [] [] + 6: (empty) + 7: L_CURLY@299..300 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@300..300 + 9: R_CURLY@300..301 "}" [] [] 2: (empty) 12: JS_CLASS_DECLARATION@301..321 - 0: (empty) - 1: CLASS_KW@301..308 "class" [Newline("\n")] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@308..311 + 0: JS_DECORATOR_LIST@301..301 + 1: (empty) + 2: CLASS_KW@301..308 "class" [Newline("\n")] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@308..311 0: IDENT@308..311 "Foo" [] [] - 3: TS_TYPE_PARAMETERS@311..319 + 4: TS_TYPE_PARAMETERS@311..319 0: L_ANGLE@311..312 "<" [] [] 1: TS_TYPE_PARAMETER_LIST@312..317 0: TS_TYPE_PARAMETER@312..317 @@ -2052,11 +2074,11 @@ JsModule { 2: (empty) 3: (empty) 2: R_ANGLE@317..319 ">" [] [Whitespace(" ")] - 4: (empty) 5: (empty) - 6: L_CURLY@319..320 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@320..320 - 8: R_CURLY@320..321 "}" [] [] + 6: (empty) + 7: L_CURLY@319..320 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@320..320 + 9: R_CURLY@320..321 "}" [] [] 13: TS_INTERFACE_DECLARATION@321..344 0: INTERFACE_KW@321..332 "interface" [Newline("\n")] [Whitespace(" ")] 1: TS_IDENTIFIER_BINDING@332..335 @@ -2100,11 +2122,12 @@ JsModule { 15: TS_DECLARE_STATEMENT@368..395 0: DECLARE_KW@368..377 "declare" [Newline("\n")] [Whitespace(" ")] 1: JS_CLASS_DECLARATION@377..395 - 0: (empty) - 1: CLASS_KW@377..383 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@383..386 + 0: JS_DECORATOR_LIST@377..377 + 1: (empty) + 2: CLASS_KW@377..383 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@383..386 0: IDENT@383..386 "Foo" [] [] - 3: TS_TYPE_PARAMETERS@386..393 + 4: TS_TYPE_PARAMETERS@386..393 0: L_ANGLE@386..387 "<" [] [] 1: TS_TYPE_PARAMETER_LIST@387..391 0: TS_TYPE_PARAMETER@387..391 @@ -2116,19 +2139,20 @@ JsModule { 2: (empty) 3: (empty) 2: R_ANGLE@391..393 ">" [] [Whitespace(" ")] - 4: (empty) 5: (empty) - 6: L_CURLY@393..394 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@394..394 - 8: R_CURLY@394..395 "}" [] [] + 6: (empty) + 7: L_CURLY@393..394 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@394..394 + 9: R_CURLY@394..395 "}" [] [] 16: TS_DECLARE_STATEMENT@395..423 0: DECLARE_KW@395..404 "declare" [Newline("\n")] [Whitespace(" ")] 1: JS_CLASS_DECLARATION@404..423 - 0: (empty) - 1: CLASS_KW@404..410 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@410..413 + 0: JS_DECORATOR_LIST@404..404 + 1: (empty) + 2: CLASS_KW@404..410 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@410..413 0: IDENT@410..413 "Foo" [] [] - 3: TS_TYPE_PARAMETERS@413..421 + 4: TS_TYPE_PARAMETERS@413..421 0: L_ANGLE@413..414 "<" [] [] 1: TS_TYPE_PARAMETER_LIST@414..419 0: TS_TYPE_PARAMETER@414..419 @@ -2140,11 +2164,11 @@ JsModule { 2: (empty) 3: (empty) 2: R_ANGLE@419..421 ">" [] [Whitespace(" ")] - 4: (empty) 5: (empty) - 6: L_CURLY@421..422 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@422..422 - 8: R_CURLY@422..423 "}" [] [] + 6: (empty) + 7: L_CURLY@421..422 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@422..422 + 9: R_CURLY@422..423 "}" [] [] 17: TS_DECLARE_STATEMENT@423..454 0: DECLARE_KW@423..432 "declare" [Newline("\n")] [Whitespace(" ")] 1: TS_INTERFACE_DECLARATION@432..454 @@ -2471,11 +2495,12 @@ JsModule { 2: R_PAREN@729..730 ")" [] [] 1: SEMICOLON@730..731 ";" [] [] 28: JS_CLASS_DECLARATION@731..751 - 0: (empty) - 1: CLASS_KW@731..738 "class" [Newline("\n")] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@738..739 + 0: JS_DECORATOR_LIST@731..731 + 1: (empty) + 2: CLASS_KW@731..738 "class" [Newline("\n")] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@738..739 0: IDENT@738..739 "A" [] [] - 3: TS_TYPE_PARAMETERS@739..749 + 4: TS_TYPE_PARAMETERS@739..749 0: L_ANGLE@739..740 "<" [] [] 1: TS_TYPE_PARAMETER_LIST@740..747 0: TS_TYPE_PARAMETER@740..747 @@ -2487,17 +2512,18 @@ JsModule { 2: (empty) 3: (empty) 2: R_ANGLE@747..749 ">" [] [Whitespace(" ")] - 4: (empty) 5: (empty) - 6: L_CURLY@749..750 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@750..750 - 8: R_CURLY@750..751 "}" [] [] + 6: (empty) + 7: L_CURLY@749..750 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@750..750 + 9: R_CURLY@750..751 "}" [] [] 29: JS_CLASS_DECLARATION@751..781 - 0: (empty) - 1: CLASS_KW@751..758 "class" [Newline("\n")] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@758..759 + 0: JS_DECORATOR_LIST@751..751 + 1: (empty) + 2: CLASS_KW@751..758 "class" [Newline("\n")] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@758..759 0: IDENT@758..759 "B" [] [] - 3: TS_TYPE_PARAMETERS@759..779 + 4: TS_TYPE_PARAMETERS@759..779 0: L_ANGLE@759..760 "<" [] [] 1: TS_TYPE_PARAMETER_LIST@760..777 0: TS_TYPE_PARAMETER@760..777 @@ -2514,17 +2540,18 @@ JsModule { 1: (empty) 3: (empty) 2: R_ANGLE@777..779 ">" [] [Whitespace(" ")] - 4: (empty) 5: (empty) - 6: L_CURLY@779..780 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@780..780 - 8: R_CURLY@780..781 "}" [] [] + 6: (empty) + 7: L_CURLY@779..780 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@780..780 + 9: R_CURLY@780..781 "}" [] [] 30: JS_CLASS_DECLARATION@781..804 - 0: (empty) - 1: CLASS_KW@781..788 "class" [Newline("\n")] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@788..789 + 0: JS_DECORATOR_LIST@781..781 + 1: (empty) + 2: CLASS_KW@781..788 "class" [Newline("\n")] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@788..789 0: IDENT@788..789 "C" [] [] - 3: TS_TYPE_PARAMETERS@789..802 + 4: TS_TYPE_PARAMETERS@789..802 0: L_ANGLE@789..790 "<" [] [] 1: TS_TYPE_PARAMETER_LIST@790..800 0: TS_TYPE_PARAMETER@790..791 @@ -2543,17 +2570,18 @@ JsModule { 2: (empty) 3: (empty) 2: R_ANGLE@800..802 ">" [] [Whitespace(" ")] - 4: (empty) 5: (empty) - 6: L_CURLY@802..803 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@803..803 - 8: R_CURLY@803..804 "}" [] [] + 6: (empty) + 7: L_CURLY@802..803 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@803..803 + 9: R_CURLY@803..804 "}" [] [] 31: JS_CLASS_DECLARATION@804..827 - 0: (empty) - 1: CLASS_KW@804..811 "class" [Newline("\n")] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@811..812 + 0: JS_DECORATOR_LIST@804..804 + 1: (empty) + 2: CLASS_KW@804..811 "class" [Newline("\n")] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@811..812 0: IDENT@811..812 "D" [] [] - 3: TS_TYPE_PARAMETERS@812..825 + 4: TS_TYPE_PARAMETERS@812..825 0: L_ANGLE@812..813 "<" [] [] 1: TS_TYPE_PARAMETER_LIST@813..823 0: TS_TYPE_PARAMETER@813..823 @@ -2567,17 +2595,18 @@ JsModule { 2: (empty) 3: (empty) 2: R_ANGLE@823..825 ">" [] [Whitespace(" ")] - 4: (empty) 5: (empty) - 6: L_CURLY@825..826 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@826..826 - 8: R_CURLY@826..827 "}" [] [] + 6: (empty) + 7: L_CURLY@825..826 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@826..826 + 9: R_CURLY@826..827 "}" [] [] 32: JS_CLASS_DECLARATION@827..850 - 0: (empty) - 1: CLASS_KW@827..834 "class" [Newline("\n")] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@834..835 + 0: JS_DECORATOR_LIST@827..827 + 1: (empty) + 2: CLASS_KW@827..834 "class" [Newline("\n")] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@834..835 0: IDENT@834..835 "E" [] [] - 3: TS_TYPE_PARAMETERS@835..848 + 4: TS_TYPE_PARAMETERS@835..848 0: L_ANGLE@835..836 "<" [] [] 1: TS_TYPE_PARAMETER_LIST@836..846 0: TS_TYPE_PARAMETER@836..846 @@ -2591,17 +2620,18 @@ JsModule { 2: (empty) 3: (empty) 2: R_ANGLE@846..848 ">" [] [Whitespace(" ")] - 4: (empty) 5: (empty) - 6: L_CURLY@848..849 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@849..849 - 8: R_CURLY@849..850 "}" [] [] + 6: (empty) + 7: L_CURLY@848..849 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@849..849 + 9: R_CURLY@849..850 "}" [] [] 33: JS_CLASS_DECLARATION@850..877 - 0: (empty) - 1: CLASS_KW@850..857 "class" [Newline("\n")] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@857..858 + 0: JS_DECORATOR_LIST@850..850 + 1: (empty) + 2: CLASS_KW@850..857 "class" [Newline("\n")] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@857..858 0: IDENT@857..858 "F" [] [] - 3: TS_TYPE_PARAMETERS@858..875 + 4: TS_TYPE_PARAMETERS@858..875 0: L_ANGLE@858..859 "<" [] [] 1: TS_TYPE_PARAMETER_LIST@859..873 0: TS_TYPE_PARAMETER@859..873 @@ -2617,18 +2647,19 @@ JsModule { 2: (empty) 3: (empty) 2: R_ANGLE@873..875 ">" [] [Whitespace(" ")] - 4: (empty) 5: (empty) - 6: L_CURLY@875..876 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@876..876 - 8: R_CURLY@876..877 "}" [] [] + 6: (empty) + 7: L_CURLY@875..876 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@876..876 + 9: R_CURLY@876..877 "}" [] [] 34: JS_EXPRESSION_STATEMENT@877..899 0: JS_PARENTHESIZED_EXPRESSION@877..898 0: L_PAREN@877..879 "(" [Newline("\n")] [] 1: JS_CLASS_EXPRESSION@879..897 - 0: CLASS_KW@879..885 "class" [] [Whitespace(" ")] - 1: (empty) - 2: TS_TYPE_PARAMETERS@885..895 + 0: JS_DECORATOR_LIST@879..879 + 1: CLASS_KW@879..885 "class" [] [Whitespace(" ")] + 2: (empty) + 3: TS_TYPE_PARAMETERS@885..895 0: L_ANGLE@885..886 "<" [] [] 1: TS_TYPE_PARAMETER_LIST@886..893 0: TS_TYPE_PARAMETER@886..893 @@ -2640,20 +2671,21 @@ JsModule { 2: (empty) 3: (empty) 2: R_ANGLE@893..895 ">" [] [Whitespace(" ")] - 3: (empty) 4: (empty) - 5: L_CURLY@895..896 "{" [] [] - 6: JS_CLASS_MEMBER_LIST@896..896 - 7: R_CURLY@896..897 "}" [] [] + 5: (empty) + 6: L_CURLY@895..896 "{" [] [] + 7: JS_CLASS_MEMBER_LIST@896..896 + 8: R_CURLY@896..897 "}" [] [] 2: R_PAREN@897..898 ")" [] [] 1: SEMICOLON@898..899 ";" [] [] 35: JS_EXPRESSION_STATEMENT@899..931 0: JS_PARENTHESIZED_EXPRESSION@899..930 0: L_PAREN@899..901 "(" [Newline("\n")] [] 1: JS_CLASS_EXPRESSION@901..929 - 0: CLASS_KW@901..907 "class" [] [Whitespace(" ")] - 1: (empty) - 2: TS_TYPE_PARAMETERS@907..927 + 0: JS_DECORATOR_LIST@901..901 + 1: CLASS_KW@901..907 "class" [] [Whitespace(" ")] + 2: (empty) + 3: TS_TYPE_PARAMETERS@907..927 0: L_ANGLE@907..908 "<" [] [] 1: TS_TYPE_PARAMETER_LIST@908..925 0: TS_TYPE_PARAMETER@908..925 @@ -2670,20 +2702,21 @@ JsModule { 1: (empty) 3: (empty) 2: R_ANGLE@925..927 ">" [] [Whitespace(" ")] - 3: (empty) 4: (empty) - 5: L_CURLY@927..928 "{" [] [] - 6: JS_CLASS_MEMBER_LIST@928..928 - 7: R_CURLY@928..929 "}" [] [] + 5: (empty) + 6: L_CURLY@927..928 "{" [] [] + 7: JS_CLASS_MEMBER_LIST@928..928 + 8: R_CURLY@928..929 "}" [] [] 2: R_PAREN@929..930 ")" [] [] 1: SEMICOLON@930..931 ";" [] [] 36: JS_EXPRESSION_STATEMENT@931..956 0: JS_PARENTHESIZED_EXPRESSION@931..955 0: L_PAREN@931..933 "(" [Newline("\n")] [] 1: JS_CLASS_EXPRESSION@933..954 - 0: CLASS_KW@933..939 "class" [] [Whitespace(" ")] - 1: (empty) - 2: TS_TYPE_PARAMETERS@939..952 + 0: JS_DECORATOR_LIST@933..933 + 1: CLASS_KW@933..939 "class" [] [Whitespace(" ")] + 2: (empty) + 3: TS_TYPE_PARAMETERS@939..952 0: L_ANGLE@939..940 "<" [] [] 1: TS_TYPE_PARAMETER_LIST@940..950 0: TS_TYPE_PARAMETER@940..941 @@ -2702,20 +2735,21 @@ JsModule { 2: (empty) 3: (empty) 2: R_ANGLE@950..952 ">" [] [Whitespace(" ")] - 3: (empty) 4: (empty) - 5: L_CURLY@952..953 "{" [] [] - 6: JS_CLASS_MEMBER_LIST@953..953 - 7: R_CURLY@953..954 "}" [] [] + 5: (empty) + 6: L_CURLY@952..953 "{" [] [] + 7: JS_CLASS_MEMBER_LIST@953..953 + 8: R_CURLY@953..954 "}" [] [] 2: R_PAREN@954..955 ")" [] [] 1: SEMICOLON@955..956 ";" [] [] 37: JS_EXPRESSION_STATEMENT@956..981 0: JS_PARENTHESIZED_EXPRESSION@956..980 0: L_PAREN@956..958 "(" [Newline("\n")] [] 1: JS_CLASS_EXPRESSION@958..979 - 0: CLASS_KW@958..964 "class" [] [Whitespace(" ")] - 1: (empty) - 2: TS_TYPE_PARAMETERS@964..977 + 0: JS_DECORATOR_LIST@958..958 + 1: CLASS_KW@958..964 "class" [] [Whitespace(" ")] + 2: (empty) + 3: TS_TYPE_PARAMETERS@964..977 0: L_ANGLE@964..965 "<" [] [] 1: TS_TYPE_PARAMETER_LIST@965..975 0: TS_TYPE_PARAMETER@965..975 @@ -2729,20 +2763,21 @@ JsModule { 2: (empty) 3: (empty) 2: R_ANGLE@975..977 ">" [] [Whitespace(" ")] - 3: (empty) 4: (empty) - 5: L_CURLY@977..978 "{" [] [] - 6: JS_CLASS_MEMBER_LIST@978..978 - 7: R_CURLY@978..979 "}" [] [] + 5: (empty) + 6: L_CURLY@977..978 "{" [] [] + 7: JS_CLASS_MEMBER_LIST@978..978 + 8: R_CURLY@978..979 "}" [] [] 2: R_PAREN@979..980 ")" [] [] 1: SEMICOLON@980..981 ";" [] [] 38: JS_EXPRESSION_STATEMENT@981..1006 0: JS_PARENTHESIZED_EXPRESSION@981..1005 0: L_PAREN@981..983 "(" [Newline("\n")] [] 1: JS_CLASS_EXPRESSION@983..1004 - 0: CLASS_KW@983..989 "class" [] [Whitespace(" ")] - 1: (empty) - 2: TS_TYPE_PARAMETERS@989..1002 + 0: JS_DECORATOR_LIST@983..983 + 1: CLASS_KW@983..989 "class" [] [Whitespace(" ")] + 2: (empty) + 3: TS_TYPE_PARAMETERS@989..1002 0: L_ANGLE@989..990 "<" [] [] 1: TS_TYPE_PARAMETER_LIST@990..1000 0: TS_TYPE_PARAMETER@990..1000 @@ -2756,23 +2791,24 @@ JsModule { 2: (empty) 3: (empty) 2: R_ANGLE@1000..1002 ">" [] [Whitespace(" ")] - 3: (empty) 4: (empty) - 5: L_CURLY@1002..1003 "{" [] [] - 6: JS_CLASS_MEMBER_LIST@1003..1003 - 7: R_CURLY@1003..1004 "}" [] [] + 5: (empty) + 6: L_CURLY@1002..1003 "{" [] [] + 7: JS_CLASS_MEMBER_LIST@1003..1003 + 8: R_CURLY@1003..1004 "}" [] [] 2: R_PAREN@1004..1005 ")" [] [] 1: SEMICOLON@1005..1006 ";" [] [] 39: JS_CLASS_DECLARATION@1006..1100 - 0: (empty) - 1: CLASS_KW@1006..1013 "class" [Newline("\n")] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@1013..1015 + 0: JS_DECORATOR_LIST@1006..1006 + 1: (empty) + 2: CLASS_KW@1006..1013 "class" [Newline("\n")] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@1013..1015 0: IDENT@1013..1015 "_" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@1015..1016 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@1016..1098 + 6: (empty) + 7: L_CURLY@1015..1016 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@1016..1098 0: JS_METHOD_CLASS_MEMBER@1016..1039 0: JS_METHOD_MODIFIER_LIST@1016..1016 1: (empty) @@ -2872,7 +2908,7 @@ JsModule { 1: JS_DIRECTIVE_LIST@1097..1097 2: JS_STATEMENT_LIST@1097..1097 3: R_CURLY@1097..1098 "}" [] [] - 8: R_CURLY@1098..1100 "}" [Newline("\n")] [] + 9: R_CURLY@1098..1100 "}" [Newline("\n")] [] 40: TS_DECLARE_STATEMENT@1100..1152 0: DECLARE_KW@1100..1109 "declare" [Newline("\n")] [Whitespace(" ")] 1: TS_MODULE_DECLARATION@1109..1152 diff --git a/crates/rome_js_parser/test_data/inline/ok/typescript_export_default_abstract_class_case.rast b/crates/rome_js_parser/test_data/inline/ok/typescript_export_default_abstract_class_case.rast index a82a3860363..f5b26fe64c1 100644 --- a/crates/rome_js_parser/test_data/inline/ok/typescript_export_default_abstract_class_case.rast +++ b/crates/rome_js_parser/test_data/inline/ok/typescript_export_default_abstract_class_case.rast @@ -7,6 +7,7 @@ JsModule { export_clause: JsExportDefaultDeclarationClause { default_token: DEFAULT_KW@7..15 "default" [] [Whitespace(" ")], declaration: JsClassExportDefaultDeclaration { + decorators: JsDecoratorList [], abstract_token: ABSTRACT_KW@15..24 "abstract" [] [Whitespace(" ")], class_token: CLASS_KW@24..30 "class" [] [Whitespace(" ")], id: missing (optional), @@ -33,14 +34,15 @@ JsModule { 1: JS_EXPORT_DEFAULT_DECLARATION_CLAUSE@7..32 0: DEFAULT_KW@7..15 "default" [] [Whitespace(" ")] 1: JS_CLASS_EXPORT_DEFAULT_DECLARATION@15..32 - 0: ABSTRACT_KW@15..24 "abstract" [] [Whitespace(" ")] - 1: CLASS_KW@24..30 "class" [] [Whitespace(" ")] - 2: (empty) + 0: JS_DECORATOR_LIST@15..15 + 1: ABSTRACT_KW@15..24 "abstract" [] [Whitespace(" ")] + 2: CLASS_KW@24..30 "class" [] [Whitespace(" ")] 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@30..31 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@31..31 - 8: R_CURLY@31..32 "}" [] [] + 6: (empty) + 7: L_CURLY@30..31 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@31..31 + 9: R_CURLY@31..32 "}" [] [] 2: (empty) 3: EOF@32..33 "" [Newline("\n")] [] diff --git a/crates/rome_js_parser/test_data/inline/ok/typescript_members_can_have_no_body_in_ambient_context.rast b/crates/rome_js_parser/test_data/inline/ok/typescript_members_can_have_no_body_in_ambient_context.rast index a4c1b52c9a1..9d9305c926e 100644 --- a/crates/rome_js_parser/test_data/inline/ok/typescript_members_can_have_no_body_in_ambient_context.rast +++ b/crates/rome_js_parser/test_data/inline/ok/typescript_members_can_have_no_body_in_ambient_context.rast @@ -5,6 +5,7 @@ JsModule { TsDeclareStatement { declare_token: DECLARE_KW@0..8 "declare" [] [Whitespace(" ")], declaration: JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@8..14 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -92,6 +93,7 @@ JsModule { l_curly_token: L_CURLY@115..116 "{" [] [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@116..128 "class" [Newline("\n"), Whitespace(" ")] [Whitespace(" ")], id: JsIdentifierBinding { @@ -183,15 +185,16 @@ JsModule { 0: TS_DECLARE_STATEMENT@0..94 0: DECLARE_KW@0..8 "declare" [] [Whitespace(" ")] 1: JS_CLASS_DECLARATION@8..94 - 0: (empty) - 1: CLASS_KW@8..14 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@14..19 + 0: JS_DECORATOR_LIST@8..8 + 1: (empty) + 2: CLASS_KW@8..14 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@14..19 0: IDENT@14..19 "Test" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@19..20 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@20..92 + 6: (empty) + 7: L_CURLY@19..20 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@20..92 0: TS_CONSTRUCTOR_SIGNATURE_CLASS_MEMBER@20..39 0: JS_CONSTRUCTOR_MODIFIER_LIST@20..20 1: JS_LITERAL_MEMBER_NAME@20..36 @@ -240,7 +243,7 @@ JsModule { 3: (empty) 5: R_PAREN@90..91 ")" [] [] 6: SEMICOLON@91..92 ";" [] [] - 8: R_CURLY@92..94 "}" [Newline("\n")] [] + 9: R_CURLY@92..94 "}" [Newline("\n")] [] 1: TS_DECLARE_STATEMENT@94..231 0: DECLARE_KW@94..103 "declare" [Newline("\n")] [Whitespace(" ")] 1: TS_MODULE_DECLARATION@103..231 @@ -251,15 +254,16 @@ JsModule { 0: L_CURLY@115..116 "{" [] [] 1: JS_MODULE_ITEM_LIST@116..229 0: JS_CLASS_DECLARATION@116..229 - 0: (empty) - 1: CLASS_KW@116..128 "class" [Newline("\n"), Whitespace(" ")] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@128..133 + 0: JS_DECORATOR_LIST@116..116 + 1: (empty) + 2: CLASS_KW@116..128 "class" [Newline("\n"), Whitespace(" ")] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@128..133 0: IDENT@128..133 "Test" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@133..134 "{" [] [] - 7: JS_CLASS_MEMBER_LIST@134..222 + 6: (empty) + 7: L_CURLY@133..134 "{" [] [] + 8: JS_CLASS_MEMBER_LIST@134..222 0: TS_CONSTRUCTOR_SIGNATURE_CLASS_MEMBER@134..157 0: JS_CONSTRUCTOR_MODIFIER_LIST@134..134 1: JS_LITERAL_MEMBER_NAME@134..155 @@ -308,6 +312,6 @@ JsModule { 3: (empty) 5: R_PAREN@221..222 ")" [] [] 6: (empty) - 8: R_CURLY@222..229 "}" [Newline("\n"), Whitespace(" ")] [] + 9: R_CURLY@222..229 "}" [Newline("\n"), Whitespace(" ")] [] 2: R_CURLY@229..231 "}" [Newline("\n")] [] 3: EOF@231..232 "" [Newline("\n")] [] diff --git a/crates/rome_js_parser/test_data/inline/ok/unary_delete_nested.rast b/crates/rome_js_parser/test_data/inline/ok/unary_delete_nested.rast index ae65cc3c062..747e03bb7ad 100644 --- a/crates/rome_js_parser/test_data/inline/ok/unary_delete_nested.rast +++ b/crates/rome_js_parser/test_data/inline/ok/unary_delete_nested.rast @@ -3,6 +3,7 @@ JsModule { directives: JsDirectiveList [], items: JsModuleItemList [ JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@0..6 "class" [] [Whitespace(" ")], id: JsIdentifierBinding { @@ -86,6 +87,7 @@ JsModule { r_curly_token: R_CURLY@73..74 "}" [] [], }, JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@74..81 "class" [Newline("\n")] [Whitespace(" ")], id: JsIdentifierBinding { @@ -160,6 +162,7 @@ JsModule { r_curly_token: R_CURLY@144..145 "}" [] [], }, JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@145..152 "class" [Newline("\n")] [Whitespace(" ")], id: JsIdentifierBinding { @@ -240,6 +243,7 @@ JsModule { r_curly_token: R_CURLY@222..223 "}" [] [], }, JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@223..230 "class" [Newline("\n")] [Whitespace(" ")], id: JsIdentifierBinding { @@ -333,6 +337,7 @@ JsModule { r_curly_token: R_CURLY@304..305 "}" [] [], }, JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@305..312 "class" [Newline("\n")] [Whitespace(" ")], id: JsIdentifierBinding { @@ -424,6 +429,7 @@ JsModule { r_curly_token: R_CURLY@389..390 "}" [] [], }, JsClassDeclaration { + decorators: JsDecoratorList [], abstract_token: missing (optional), class_token: CLASS_KW@390..397 "class" [Newline("\n")] [Whitespace(" ")], id: JsIdentifierBinding { @@ -525,15 +531,16 @@ JsModule { 1: JS_DIRECTIVE_LIST@0..0 2: JS_MODULE_ITEM_LIST@0..478 0: JS_CLASS_DECLARATION@0..74 - 0: (empty) - 1: CLASS_KW@0..6 "class" [] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@6..16 + 0: JS_DECORATOR_LIST@0..0 + 1: (empty) + 2: CLASS_KW@0..6 "class" [] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@6..16 0: IDENT@6..16 "TestClass" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@16..18 "{" [] [Whitespace(" ")] - 7: JS_CLASS_MEMBER_LIST@18..73 + 6: (empty) + 7: L_CURLY@16..18 "{" [] [Whitespace(" ")] + 8: JS_CLASS_MEMBER_LIST@18..73 0: JS_PROPERTY_CLASS_MEMBER@18..34 0: JS_PROPERTY_MODIFIER_LIST@18..18 1: JS_PRIVATE_CLASS_MEMBER_NAME@18..26 @@ -584,17 +591,18 @@ JsModule { 2: R_PAREN@69..71 ")" [] [Whitespace(" ")] 1: (empty) 3: R_CURLY@71..73 "}" [] [Whitespace(" ")] - 8: R_CURLY@73..74 "}" [] [] + 9: R_CURLY@73..74 "}" [] [] 1: JS_CLASS_DECLARATION@74..145 - 0: (empty) - 1: CLASS_KW@74..81 "class" [Newline("\n")] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@81..91 + 0: JS_DECORATOR_LIST@74..74 + 1: (empty) + 2: CLASS_KW@74..81 "class" [Newline("\n")] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@81..91 0: IDENT@81..91 "TestClass" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@91..93 "{" [] [Whitespace(" ")] - 7: JS_CLASS_MEMBER_LIST@93..144 + 6: (empty) + 7: L_CURLY@91..93 "{" [] [Whitespace(" ")] + 8: JS_CLASS_MEMBER_LIST@93..144 0: JS_PROPERTY_CLASS_MEMBER@93..109 0: JS_PROPERTY_MODIFIER_LIST@93..93 1: JS_PRIVATE_CLASS_MEMBER_NAME@93..101 @@ -639,17 +647,18 @@ JsModule { 2: R_BRACK@140..142 "]" [] [Whitespace(" ")] 1: (empty) 3: R_CURLY@142..144 "}" [] [Whitespace(" ")] - 8: R_CURLY@144..145 "}" [] [] + 9: R_CURLY@144..145 "}" [] [] 2: JS_CLASS_DECLARATION@145..223 - 0: (empty) - 1: CLASS_KW@145..152 "class" [Newline("\n")] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@152..162 + 0: JS_DECORATOR_LIST@145..145 + 1: (empty) + 2: CLASS_KW@145..152 "class" [Newline("\n")] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@152..162 0: IDENT@152..162 "TestClass" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@162..164 "{" [] [Whitespace(" ")] - 7: JS_CLASS_MEMBER_LIST@164..222 + 6: (empty) + 7: L_CURLY@162..164 "{" [] [Whitespace(" ")] + 8: JS_CLASS_MEMBER_LIST@164..222 0: JS_PROPERTY_CLASS_MEMBER@164..180 0: JS_PROPERTY_MODIFIER_LIST@164..164 1: JS_PRIVATE_CLASS_MEMBER_NAME@164..172 @@ -698,17 +707,18 @@ JsModule { 2: R_CURLY@218..220 "}" [] [Whitespace(" ")] 1: (empty) 3: R_CURLY@220..222 "}" [] [Whitespace(" ")] - 8: R_CURLY@222..223 "}" [] [] + 9: R_CURLY@222..223 "}" [] [] 3: JS_CLASS_DECLARATION@223..305 - 0: (empty) - 1: CLASS_KW@223..230 "class" [Newline("\n")] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@230..240 + 0: JS_DECORATOR_LIST@223..223 + 1: (empty) + 2: CLASS_KW@223..230 "class" [Newline("\n")] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@230..240 0: IDENT@230..240 "TestClass" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@240..242 "{" [] [Whitespace(" ")] - 7: JS_CLASS_MEMBER_LIST@242..304 + 6: (empty) + 7: L_CURLY@240..242 "{" [] [Whitespace(" ")] + 8: JS_CLASS_MEMBER_LIST@242..304 0: JS_PROPERTY_CLASS_MEMBER@242..258 0: JS_PROPERTY_MODIFIER_LIST@242..242 1: JS_PRIVATE_CLASS_MEMBER_NAME@242..250 @@ -768,17 +778,18 @@ JsModule { 2: R_PAREN@300..302 ")" [] [Whitespace(" ")] 1: (empty) 3: R_CURLY@302..304 "}" [] [Whitespace(" ")] - 8: R_CURLY@304..305 "}" [] [] + 9: R_CURLY@304..305 "}" [] [] 4: JS_CLASS_DECLARATION@305..390 - 0: (empty) - 1: CLASS_KW@305..312 "class" [Newline("\n")] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@312..322 + 0: JS_DECORATOR_LIST@305..305 + 1: (empty) + 2: CLASS_KW@305..312 "class" [Newline("\n")] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@312..322 0: IDENT@312..322 "TestClass" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@322..324 "{" [] [Whitespace(" ")] - 7: JS_CLASS_MEMBER_LIST@324..389 + 6: (empty) + 7: L_CURLY@322..324 "{" [] [Whitespace(" ")] + 8: JS_CLASS_MEMBER_LIST@324..389 0: JS_PROPERTY_CLASS_MEMBER@324..340 0: JS_PROPERTY_MODIFIER_LIST@324..324 1: JS_PRIVATE_CLASS_MEMBER_NAME@324..332 @@ -836,17 +847,18 @@ JsModule { 2: R_PAREN@385..387 ")" [] [Whitespace(" ")] 1: (empty) 3: R_CURLY@387..389 "}" [] [Whitespace(" ")] - 8: R_CURLY@389..390 "}" [] [] + 9: R_CURLY@389..390 "}" [] [] 5: JS_CLASS_DECLARATION@390..478 - 0: (empty) - 1: CLASS_KW@390..397 "class" [Newline("\n")] [Whitespace(" ")] - 2: JS_IDENTIFIER_BINDING@397..407 + 0: JS_DECORATOR_LIST@390..390 + 1: (empty) + 2: CLASS_KW@390..397 "class" [Newline("\n")] [Whitespace(" ")] + 3: JS_IDENTIFIER_BINDING@397..407 0: IDENT@397..407 "TestClass" [] [Whitespace(" ")] - 3: (empty) 4: (empty) 5: (empty) - 6: L_CURLY@407..409 "{" [] [Whitespace(" ")] - 7: JS_CLASS_MEMBER_LIST@409..477 + 6: (empty) + 7: L_CURLY@407..409 "{" [] [Whitespace(" ")] + 8: JS_CLASS_MEMBER_LIST@409..477 0: JS_PROPERTY_CLASS_MEMBER@409..425 0: JS_PROPERTY_MODIFIER_LIST@409..409 1: JS_PRIVATE_CLASS_MEMBER_NAME@409..417 @@ -906,5 +918,5 @@ JsModule { 2: R_PAREN@473..475 ")" [] [Whitespace(" ")] 1: (empty) 3: R_CURLY@475..477 "}" [] [Whitespace(" ")] - 8: R_CURLY@477..478 "}" [] [] + 9: R_CURLY@477..478 "}" [] [] 3: EOF@478..479 "" [Newline("\n")] [] diff --git a/crates/rome_js_syntax/src/binding_ext.rs b/crates/rome_js_syntax/src/binding_ext.rs index 6ab51f67df2..339eb250394 100644 --- a/crates/rome_js_syntax/src/binding_ext.rs +++ b/crates/rome_js_syntax/src/binding_ext.rs @@ -82,6 +82,7 @@ impl AnyJsBindingDeclaration { /// /// let class_id = make::js_identifier_binding(make::ident("Order")); /// let class_decl: AnyJsBindingDeclaration = make::js_class_declaration( + /// make::js_decorator_list(std::iter::empty()), /// make::token(T![class]), /// class_id.into(), /// make::token(T!['{']), diff --git a/crates/rome_js_syntax/src/generated/kind.rs b/crates/rome_js_syntax/src/generated/kind.rs index 506843bff85..a94d5106978 100644 --- a/crates/rome_js_syntax/src/generated/kind.rs +++ b/crates/rome_js_syntax/src/generated/kind.rs @@ -365,6 +365,8 @@ pub enum JsSyntaxKind { TS_EXPORT_DECLARE_CLAUSE, JS_LITERAL_EXPORT_NAME, JS_AWAIT_EXPRESSION, + JS_DECORATOR, + JS_DECORATOR_LIST, TS_IDENTIFIER_BINDING, TS_ANY_TYPE, TS_UNKNOWN_TYPE, @@ -551,6 +553,7 @@ impl JsSyntaxKind { | JS_IMPORT_ATTRIBUTE_ENTRY_LIST | JS_EXPORT_NAMED_SPECIFIER_LIST | JS_EXPORT_NAMED_FROM_SPECIFIER_LIST + | JS_DECORATOR_LIST | TS_UNION_TYPE_VARIANT_LIST | TS_INTERSECTION_TYPE_ELEMENT_LIST | TS_TYPE_MEMBER_LIST diff --git a/crates/rome_js_syntax/src/generated/macros.rs b/crates/rome_js_syntax/src/generated/macros.rs index 85e6e9daad1..89e8a492d44 100644 --- a/crates/rome_js_syntax/src/generated/macros.rs +++ b/crates/rome_js_syntax/src/generated/macros.rs @@ -157,6 +157,10 @@ macro_rules! map_syntax_node { let $pattern = unsafe { $crate::JsDebuggerStatement::new_unchecked(node) }; $body } + $crate::JsSyntaxKind::JS_DECORATOR => { + let $pattern = unsafe { $crate::JsDecorator::new_unchecked(node) }; + $body + } $crate::JsSyntaxKind::JS_DEFAULT_CLAUSE => { let $pattern = unsafe { $crate::JsDefaultClause::new_unchecked(node) }; $body @@ -1293,6 +1297,10 @@ macro_rules! map_syntax_node { unsafe { $crate::JsConstructorParameterList::new_unchecked(node) }; $body } + $crate::JsSyntaxKind::JS_DECORATOR_LIST => { + let $pattern = unsafe { $crate::JsDecoratorList::new_unchecked(node) }; + $body + } $crate::JsSyntaxKind::JS_DIRECTIVE_LIST => { let $pattern = unsafe { $crate::JsDirectiveList::new_unchecked(node) }; $body diff --git a/crates/rome_js_syntax/src/generated/nodes.rs b/crates/rome_js_syntax/src/generated/nodes.rs index 14b1a278183..e6b1a170f2d 100644 --- a/crates/rome_js_syntax/src/generated/nodes.rs +++ b/crates/rome_js_syntax/src/generated/nodes.rs @@ -949,6 +949,7 @@ impl JsClassDeclaration { pub const unsafe fn new_unchecked(syntax: SyntaxNode) -> Self { Self { syntax } } pub fn as_fields(&self) -> JsClassDeclarationFields { JsClassDeclarationFields { + decorators: self.decorators(), abstract_token: self.abstract_token(), class_token: self.class_token(), id: self.id(), @@ -960,24 +961,25 @@ impl JsClassDeclaration { r_curly_token: self.r_curly_token(), } } - pub fn abstract_token(&self) -> Option { support::token(&self.syntax, 0usize) } + pub fn decorators(&self) -> JsDecoratorList { support::list(&self.syntax, 0usize) } + pub fn abstract_token(&self) -> Option { support::token(&self.syntax, 1usize) } pub fn class_token(&self) -> SyntaxResult { - support::required_token(&self.syntax, 1usize) + support::required_token(&self.syntax, 2usize) } - pub fn id(&self) -> SyntaxResult { support::required_node(&self.syntax, 2usize) } + pub fn id(&self) -> SyntaxResult { support::required_node(&self.syntax, 3usize) } pub fn type_parameters(&self) -> Option { - support::node(&self.syntax, 3usize) + support::node(&self.syntax, 4usize) } - pub fn extends_clause(&self) -> Option { support::node(&self.syntax, 4usize) } + pub fn extends_clause(&self) -> Option { support::node(&self.syntax, 5usize) } pub fn implements_clause(&self) -> Option { - support::node(&self.syntax, 5usize) + support::node(&self.syntax, 6usize) } pub fn l_curly_token(&self) -> SyntaxResult { - support::required_token(&self.syntax, 6usize) + support::required_token(&self.syntax, 7usize) } - pub fn members(&self) -> JsClassMemberList { support::list(&self.syntax, 7usize) } + pub fn members(&self) -> JsClassMemberList { support::list(&self.syntax, 8usize) } pub fn r_curly_token(&self) -> SyntaxResult { - support::required_token(&self.syntax, 8usize) + support::required_token(&self.syntax, 9usize) } } #[cfg(feature = "serde")] @@ -991,6 +993,7 @@ impl Serialize for JsClassDeclaration { } #[cfg_attr(feature = "serde", derive(Serialize))] pub struct JsClassDeclarationFields { + pub decorators: JsDecoratorList, pub abstract_token: Option, pub class_token: SyntaxResult, pub id: SyntaxResult, @@ -1015,6 +1018,7 @@ impl JsClassExportDefaultDeclaration { pub const unsafe fn new_unchecked(syntax: SyntaxNode) -> Self { Self { syntax } } pub fn as_fields(&self) -> JsClassExportDefaultDeclarationFields { JsClassExportDefaultDeclarationFields { + decorators: self.decorators(), abstract_token: self.abstract_token(), class_token: self.class_token(), id: self.id(), @@ -1026,24 +1030,25 @@ impl JsClassExportDefaultDeclaration { r_curly_token: self.r_curly_token(), } } - pub fn abstract_token(&self) -> Option { support::token(&self.syntax, 0usize) } + pub fn decorators(&self) -> JsDecoratorList { support::list(&self.syntax, 0usize) } + pub fn abstract_token(&self) -> Option { support::token(&self.syntax, 1usize) } pub fn class_token(&self) -> SyntaxResult { - support::required_token(&self.syntax, 1usize) + support::required_token(&self.syntax, 2usize) } - pub fn id(&self) -> Option { support::node(&self.syntax, 2usize) } + pub fn id(&self) -> Option { support::node(&self.syntax, 3usize) } pub fn type_parameters(&self) -> Option { - support::node(&self.syntax, 3usize) + support::node(&self.syntax, 4usize) } - pub fn extends_clause(&self) -> Option { support::node(&self.syntax, 4usize) } + pub fn extends_clause(&self) -> Option { support::node(&self.syntax, 5usize) } pub fn implements_clause(&self) -> Option { - support::node(&self.syntax, 5usize) + support::node(&self.syntax, 6usize) } pub fn l_curly_token(&self) -> SyntaxResult { - support::required_token(&self.syntax, 6usize) + support::required_token(&self.syntax, 7usize) } - pub fn members(&self) -> JsClassMemberList { support::list(&self.syntax, 7usize) } + pub fn members(&self) -> JsClassMemberList { support::list(&self.syntax, 8usize) } pub fn r_curly_token(&self) -> SyntaxResult { - support::required_token(&self.syntax, 8usize) + support::required_token(&self.syntax, 9usize) } } #[cfg(feature = "serde")] @@ -1057,6 +1062,7 @@ impl Serialize for JsClassExportDefaultDeclaration { } #[cfg_attr(feature = "serde", derive(Serialize))] pub struct JsClassExportDefaultDeclarationFields { + pub decorators: JsDecoratorList, pub abstract_token: Option, pub class_token: SyntaxResult, pub id: Option, @@ -1081,6 +1087,7 @@ impl JsClassExpression { pub const unsafe fn new_unchecked(syntax: SyntaxNode) -> Self { Self { syntax } } pub fn as_fields(&self) -> JsClassExpressionFields { JsClassExpressionFields { + decorators: self.decorators(), class_token: self.class_token(), id: self.id(), type_parameters: self.type_parameters(), @@ -1091,23 +1098,24 @@ impl JsClassExpression { r_curly_token: self.r_curly_token(), } } + pub fn decorators(&self) -> JsDecoratorList { support::list(&self.syntax, 0usize) } pub fn class_token(&self) -> SyntaxResult { - support::required_token(&self.syntax, 0usize) + support::required_token(&self.syntax, 1usize) } - pub fn id(&self) -> Option { support::node(&self.syntax, 1usize) } + pub fn id(&self) -> Option { support::node(&self.syntax, 2usize) } pub fn type_parameters(&self) -> Option { - support::node(&self.syntax, 2usize) + support::node(&self.syntax, 3usize) } - pub fn extends_clause(&self) -> Option { support::node(&self.syntax, 3usize) } + pub fn extends_clause(&self) -> Option { support::node(&self.syntax, 4usize) } pub fn implements_clause(&self) -> Option { - support::node(&self.syntax, 4usize) + support::node(&self.syntax, 5usize) } pub fn l_curly_token(&self) -> SyntaxResult { - support::required_token(&self.syntax, 5usize) + support::required_token(&self.syntax, 6usize) } - pub fn members(&self) -> JsClassMemberList { support::list(&self.syntax, 6usize) } + pub fn members(&self) -> JsClassMemberList { support::list(&self.syntax, 7usize) } pub fn r_curly_token(&self) -> SyntaxResult { - support::required_token(&self.syntax, 7usize) + support::required_token(&self.syntax, 8usize) } } #[cfg(feature = "serde")] @@ -1121,6 +1129,7 @@ impl Serialize for JsClassExpression { } #[cfg_attr(feature = "serde", derive(Serialize))] pub struct JsClassExpressionFields { + pub decorators: JsDecoratorList, pub class_token: SyntaxResult, pub id: Option, pub type_parameters: Option, @@ -1498,6 +1507,45 @@ pub struct JsDebuggerStatementFields { pub semicolon_token: Option, } #[derive(Clone, PartialEq, Eq, Hash)] +pub struct JsDecorator { + pub(crate) syntax: SyntaxNode, +} +impl JsDecorator { + #[doc = r" Create an AstNode from a SyntaxNode without checking its kind"] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function must be guarded with a call to [AstNode::can_cast]"] + #[doc = r" or a match on [SyntaxNode::kind]"] + #[inline] + pub const unsafe fn new_unchecked(syntax: SyntaxNode) -> Self { Self { syntax } } + pub fn as_fields(&self) -> JsDecoratorFields { + JsDecoratorFields { + at_token: self.at_token(), + expression: self.expression(), + } + } + pub fn at_token(&self) -> SyntaxResult { + support::required_token(&self.syntax, 0usize) + } + pub fn expression(&self) -> SyntaxResult { + support::required_node(&self.syntax, 1usize) + } +} +#[cfg(feature = "serde")] +impl Serialize for JsDecorator { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + self.as_fields().serialize(serializer) + } +} +#[cfg_attr(feature = "serde", derive(Serialize))] +pub struct JsDecoratorFields { + pub at_token: SyntaxResult, + pub expression: SyntaxResult, +} +#[derive(Clone, PartialEq, Eq, Hash)] pub struct JsDefaultClause { pub(crate) syntax: SyntaxNode, } @@ -12906,6 +12954,47 @@ impl AnyJsDeclarationClause { } #[derive(Clone, PartialEq, Eq, Hash)] #[cfg_attr(feature = "serde", derive(Serialize))] +pub enum AnyJsDecorator { + JsBogusExpression(JsBogusExpression), + JsCallExpression(JsCallExpression), + JsIdentifierExpression(JsIdentifierExpression), + JsParenthesizedExpression(JsParenthesizedExpression), + JsStaticMemberExpression(JsStaticMemberExpression), +} +impl AnyJsDecorator { + pub fn as_js_bogus_expression(&self) -> Option<&JsBogusExpression> { + match &self { + AnyJsDecorator::JsBogusExpression(item) => Some(item), + _ => None, + } + } + pub fn as_js_call_expression(&self) -> Option<&JsCallExpression> { + match &self { + AnyJsDecorator::JsCallExpression(item) => Some(item), + _ => None, + } + } + pub fn as_js_identifier_expression(&self) -> Option<&JsIdentifierExpression> { + match &self { + AnyJsDecorator::JsIdentifierExpression(item) => Some(item), + _ => None, + } + } + pub fn as_js_parenthesized_expression(&self) -> Option<&JsParenthesizedExpression> { + match &self { + AnyJsDecorator::JsParenthesizedExpression(item) => Some(item), + _ => None, + } + } + pub fn as_js_static_member_expression(&self) -> Option<&JsStaticMemberExpression> { + match &self { + AnyJsDecorator::JsStaticMemberExpression(item) => Some(item), + _ => None, + } + } +} +#[derive(Clone, PartialEq, Eq, Hash)] +#[cfg_attr(feature = "serde", derive(Serialize))] pub enum AnyJsExportClause { AnyJsDeclarationClause(AnyJsDeclarationClause), JsExportDefaultDeclarationClause(JsExportDefaultDeclarationClause), @@ -15911,6 +16000,7 @@ impl AstNode for JsClassDeclaration { impl std::fmt::Debug for JsClassDeclaration { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.debug_struct("JsClassDeclaration") + .field("decorators", &self.decorators()) .field( "abstract_token", &support::DebugOptionalElement(self.abstract_token()), @@ -15968,6 +16058,7 @@ impl AstNode for JsClassExportDefaultDeclaration { impl std::fmt::Debug for JsClassExportDefaultDeclaration { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.debug_struct("JsClassExportDefaultDeclaration") + .field("decorators", &self.decorators()) .field( "abstract_token", &support::DebugOptionalElement(self.abstract_token()), @@ -16025,6 +16116,7 @@ impl AstNode for JsClassExpression { impl std::fmt::Debug for JsClassExpression { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.debug_struct("JsClassExpression") + .field("decorators", &self.decorators()) .field( "class_token", &support::DebugSyntaxResult(self.class_token()), @@ -16353,6 +16445,35 @@ impl From for SyntaxNode { impl From for SyntaxElement { fn from(n: JsDebuggerStatement) -> SyntaxElement { n.syntax.into() } } +impl AstNode for JsDecorator { + type Language = Language; + const KIND_SET: SyntaxKindSet = + SyntaxKindSet::from_raw(RawSyntaxKind(JS_DECORATOR as u16)); + fn can_cast(kind: SyntaxKind) -> bool { kind == JS_DECORATOR } + fn cast(syntax: SyntaxNode) -> Option { + if Self::can_cast(syntax.kind()) { + Some(Self { syntax }) + } else { + None + } + } + fn syntax(&self) -> &SyntaxNode { &self.syntax } + fn into_syntax(self) -> SyntaxNode { self.syntax } +} +impl std::fmt::Debug for JsDecorator { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("JsDecorator") + .field("at_token", &support::DebugSyntaxResult(self.at_token())) + .field("expression", &support::DebugSyntaxResult(self.expression())) + .finish() + } +} +impl From for SyntaxNode { + fn from(n: JsDecorator) -> SyntaxNode { n.syntax } +} +impl From for SyntaxElement { + fn from(n: JsDecorator) -> SyntaxElement { n.syntax.into() } +} impl AstNode for JsDefaultClause { type Language = Language; const KIND_SET: SyntaxKindSet = @@ -26898,6 +27019,108 @@ impl From for SyntaxElement { node.into() } } +impl From for AnyJsDecorator { + fn from(node: JsBogusExpression) -> AnyJsDecorator { AnyJsDecorator::JsBogusExpression(node) } +} +impl From for AnyJsDecorator { + fn from(node: JsCallExpression) -> AnyJsDecorator { AnyJsDecorator::JsCallExpression(node) } +} +impl From for AnyJsDecorator { + fn from(node: JsIdentifierExpression) -> AnyJsDecorator { + AnyJsDecorator::JsIdentifierExpression(node) + } +} +impl From for AnyJsDecorator { + fn from(node: JsParenthesizedExpression) -> AnyJsDecorator { + AnyJsDecorator::JsParenthesizedExpression(node) + } +} +impl From for AnyJsDecorator { + fn from(node: JsStaticMemberExpression) -> AnyJsDecorator { + AnyJsDecorator::JsStaticMemberExpression(node) + } +} +impl AstNode for AnyJsDecorator { + type Language = Language; + const KIND_SET: SyntaxKindSet = JsBogusExpression::KIND_SET + .union(JsCallExpression::KIND_SET) + .union(JsIdentifierExpression::KIND_SET) + .union(JsParenthesizedExpression::KIND_SET) + .union(JsStaticMemberExpression::KIND_SET); + fn can_cast(kind: SyntaxKind) -> bool { + matches!( + kind, + JS_BOGUS_EXPRESSION + | JS_CALL_EXPRESSION + | JS_IDENTIFIER_EXPRESSION + | JS_PARENTHESIZED_EXPRESSION + | JS_STATIC_MEMBER_EXPRESSION + ) + } + fn cast(syntax: SyntaxNode) -> Option { + let res = match syntax.kind() { + JS_BOGUS_EXPRESSION => AnyJsDecorator::JsBogusExpression(JsBogusExpression { syntax }), + JS_CALL_EXPRESSION => AnyJsDecorator::JsCallExpression(JsCallExpression { syntax }), + JS_IDENTIFIER_EXPRESSION => { + AnyJsDecorator::JsIdentifierExpression(JsIdentifierExpression { syntax }) + } + JS_PARENTHESIZED_EXPRESSION => { + AnyJsDecorator::JsParenthesizedExpression(JsParenthesizedExpression { syntax }) + } + JS_STATIC_MEMBER_EXPRESSION => { + AnyJsDecorator::JsStaticMemberExpression(JsStaticMemberExpression { syntax }) + } + _ => return None, + }; + Some(res) + } + fn syntax(&self) -> &SyntaxNode { + match self { + AnyJsDecorator::JsBogusExpression(it) => &it.syntax, + AnyJsDecorator::JsCallExpression(it) => &it.syntax, + AnyJsDecorator::JsIdentifierExpression(it) => &it.syntax, + AnyJsDecorator::JsParenthesizedExpression(it) => &it.syntax, + AnyJsDecorator::JsStaticMemberExpression(it) => &it.syntax, + } + } + fn into_syntax(self) -> SyntaxNode { + match self { + AnyJsDecorator::JsBogusExpression(it) => it.syntax, + AnyJsDecorator::JsCallExpression(it) => it.syntax, + AnyJsDecorator::JsIdentifierExpression(it) => it.syntax, + AnyJsDecorator::JsParenthesizedExpression(it) => it.syntax, + AnyJsDecorator::JsStaticMemberExpression(it) => it.syntax, + } + } +} +impl std::fmt::Debug for AnyJsDecorator { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + AnyJsDecorator::JsBogusExpression(it) => std::fmt::Debug::fmt(it, f), + AnyJsDecorator::JsCallExpression(it) => std::fmt::Debug::fmt(it, f), + AnyJsDecorator::JsIdentifierExpression(it) => std::fmt::Debug::fmt(it, f), + AnyJsDecorator::JsParenthesizedExpression(it) => std::fmt::Debug::fmt(it, f), + AnyJsDecorator::JsStaticMemberExpression(it) => std::fmt::Debug::fmt(it, f), + } + } +} +impl From for SyntaxNode { + fn from(n: AnyJsDecorator) -> SyntaxNode { + match n { + AnyJsDecorator::JsBogusExpression(it) => it.into(), + AnyJsDecorator::JsCallExpression(it) => it.into(), + AnyJsDecorator::JsIdentifierExpression(it) => it.into(), + AnyJsDecorator::JsParenthesizedExpression(it) => it.into(), + AnyJsDecorator::JsStaticMemberExpression(it) => it.into(), + } + } +} +impl From for SyntaxElement { + fn from(n: AnyJsDecorator) -> SyntaxElement { + let node: SyntaxNode = n.into(); + node.into() + } +} impl From for AnyJsExportClause { fn from(node: JsExportDefaultDeclarationClause) -> AnyJsExportClause { AnyJsExportClause::JsExportDefaultDeclarationClause(node) @@ -32508,6 +32731,11 @@ impl std::fmt::Display for AnyJsDeclarationClause { std::fmt::Display::fmt(self.syntax(), f) } } +impl std::fmt::Display for AnyJsDecorator { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + std::fmt::Display::fmt(self.syntax(), f) + } +} impl std::fmt::Display for AnyJsExportClause { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { std::fmt::Display::fmt(self.syntax(), f) @@ -32943,6 +33171,11 @@ impl std::fmt::Display for JsDebuggerStatement { std::fmt::Display::fmt(self.syntax(), f) } } +impl std::fmt::Display for JsDecorator { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + std::fmt::Display::fmt(self.syntax(), f) + } +} impl std::fmt::Display for JsDefaultClause { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { std::fmt::Display::fmt(self.syntax(), f) @@ -35108,6 +35341,75 @@ impl IntoIterator for &JsConstructorParameterList { fn into_iter(self) -> Self::IntoIter { self.iter() } } #[derive(Clone, Eq, PartialEq, Hash)] +pub struct JsDecoratorList { + syntax_list: SyntaxList, +} +impl JsDecoratorList { + #[doc = r" Create an AstNode from a SyntaxNode without checking its kind"] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r" This function must be guarded with a call to [AstNode::can_cast]"] + #[doc = r" or a match on [SyntaxNode::kind]"] + #[inline] + pub unsafe fn new_unchecked(syntax: SyntaxNode) -> Self { + Self { + syntax_list: syntax.into_list(), + } + } +} +impl AstNode for JsDecoratorList { + type Language = Language; + const KIND_SET: SyntaxKindSet = + SyntaxKindSet::from_raw(RawSyntaxKind(JS_DECORATOR_LIST as u16)); + fn can_cast(kind: SyntaxKind) -> bool { kind == JS_DECORATOR_LIST } + fn cast(syntax: SyntaxNode) -> Option { + if Self::can_cast(syntax.kind()) { + Some(JsDecoratorList { + syntax_list: syntax.into_list(), + }) + } else { + None + } + } + fn syntax(&self) -> &SyntaxNode { self.syntax_list.node() } + fn into_syntax(self) -> SyntaxNode { self.syntax_list.into_node() } +} +#[cfg(feature = "serde")] +impl Serialize for JsDecoratorList { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + let mut seq = serializer.serialize_seq(Some(self.len()))?; + for e in self.iter() { + seq.serialize_element(&e)?; + } + seq.end() + } +} +impl AstNodeList for JsDecoratorList { + type Language = Language; + type Node = JsDecorator; + fn syntax_list(&self) -> &SyntaxList { &self.syntax_list } + fn into_syntax_list(self) -> SyntaxList { self.syntax_list } +} +impl Debug for JsDecoratorList { + fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { + f.write_str("JsDecoratorList ")?; + f.debug_list().entries(self.iter()).finish() + } +} +impl IntoIterator for &JsDecoratorList { + type Item = JsDecorator; + type IntoIter = AstNodeListIterator; + fn into_iter(self) -> Self::IntoIter { self.iter() } +} +impl IntoIterator for JsDecoratorList { + type Item = JsDecorator; + type IntoIter = AstNodeListIterator; + fn into_iter(self) -> Self::IntoIter { self.iter() } +} +#[derive(Clone, Eq, PartialEq, Hash)] pub struct JsDirectiveList { syntax_list: SyntaxList, } diff --git a/crates/rome_js_syntax/src/generated/nodes_mut.rs b/crates/rome_js_syntax/src/generated/nodes_mut.rs index a2bc844730e..9e356a62765 100644 --- a/crates/rome_js_syntax/src/generated/nodes_mut.rs +++ b/crates/rome_js_syntax/src/generated/nodes_mut.rs @@ -407,164 +407,182 @@ impl JsCatchDeclaration { } } impl JsClassDeclaration { + pub fn with_decorators(self, element: JsDecoratorList) -> Self { + Self::unwrap_cast( + self.syntax + .splice_slots(0usize..=0usize, once(Some(element.into_syntax().into()))), + ) + } pub fn with_abstract_token(self, element: Option) -> Self { Self::unwrap_cast( self.syntax - .splice_slots(0usize..=0usize, once(element.map(|element| element.into()))), + .splice_slots(1usize..=1usize, once(element.map(|element| element.into()))), ) } pub fn with_class_token(self, element: SyntaxToken) -> Self { Self::unwrap_cast( self.syntax - .splice_slots(1usize..=1usize, once(Some(element.into()))), + .splice_slots(2usize..=2usize, once(Some(element.into()))), ) } pub fn with_id(self, element: AnyJsBinding) -> Self { Self::unwrap_cast( self.syntax - .splice_slots(2usize..=2usize, once(Some(element.into_syntax().into()))), + .splice_slots(3usize..=3usize, once(Some(element.into_syntax().into()))), ) } pub fn with_type_parameters(self, element: Option) -> Self { Self::unwrap_cast(self.syntax.splice_slots( - 3usize..=3usize, + 4usize..=4usize, once(element.map(|element| element.into_syntax().into())), )) } pub fn with_extends_clause(self, element: Option) -> Self { Self::unwrap_cast(self.syntax.splice_slots( - 4usize..=4usize, + 5usize..=5usize, once(element.map(|element| element.into_syntax().into())), )) } pub fn with_implements_clause(self, element: Option) -> Self { Self::unwrap_cast(self.syntax.splice_slots( - 5usize..=5usize, + 6usize..=6usize, once(element.map(|element| element.into_syntax().into())), )) } pub fn with_l_curly_token(self, element: SyntaxToken) -> Self { Self::unwrap_cast( self.syntax - .splice_slots(6usize..=6usize, once(Some(element.into()))), + .splice_slots(7usize..=7usize, once(Some(element.into()))), ) } pub fn with_members(self, element: JsClassMemberList) -> Self { Self::unwrap_cast( self.syntax - .splice_slots(7usize..=7usize, once(Some(element.into_syntax().into()))), + .splice_slots(8usize..=8usize, once(Some(element.into_syntax().into()))), ) } pub fn with_r_curly_token(self, element: SyntaxToken) -> Self { Self::unwrap_cast( self.syntax - .splice_slots(8usize..=8usize, once(Some(element.into()))), + .splice_slots(9usize..=9usize, once(Some(element.into()))), ) } } impl JsClassExportDefaultDeclaration { + pub fn with_decorators(self, element: JsDecoratorList) -> Self { + Self::unwrap_cast( + self.syntax + .splice_slots(0usize..=0usize, once(Some(element.into_syntax().into()))), + ) + } pub fn with_abstract_token(self, element: Option) -> Self { Self::unwrap_cast( self.syntax - .splice_slots(0usize..=0usize, once(element.map(|element| element.into()))), + .splice_slots(1usize..=1usize, once(element.map(|element| element.into()))), ) } pub fn with_class_token(self, element: SyntaxToken) -> Self { Self::unwrap_cast( self.syntax - .splice_slots(1usize..=1usize, once(Some(element.into()))), + .splice_slots(2usize..=2usize, once(Some(element.into()))), ) } pub fn with_id(self, element: Option) -> Self { Self::unwrap_cast(self.syntax.splice_slots( - 2usize..=2usize, + 3usize..=3usize, once(element.map(|element| element.into_syntax().into())), )) } pub fn with_type_parameters(self, element: Option) -> Self { Self::unwrap_cast(self.syntax.splice_slots( - 3usize..=3usize, + 4usize..=4usize, once(element.map(|element| element.into_syntax().into())), )) } pub fn with_extends_clause(self, element: Option) -> Self { Self::unwrap_cast(self.syntax.splice_slots( - 4usize..=4usize, + 5usize..=5usize, once(element.map(|element| element.into_syntax().into())), )) } pub fn with_implements_clause(self, element: Option) -> Self { Self::unwrap_cast(self.syntax.splice_slots( - 5usize..=5usize, + 6usize..=6usize, once(element.map(|element| element.into_syntax().into())), )) } pub fn with_l_curly_token(self, element: SyntaxToken) -> Self { Self::unwrap_cast( self.syntax - .splice_slots(6usize..=6usize, once(Some(element.into()))), + .splice_slots(7usize..=7usize, once(Some(element.into()))), ) } pub fn with_members(self, element: JsClassMemberList) -> Self { Self::unwrap_cast( self.syntax - .splice_slots(7usize..=7usize, once(Some(element.into_syntax().into()))), + .splice_slots(8usize..=8usize, once(Some(element.into_syntax().into()))), ) } pub fn with_r_curly_token(self, element: SyntaxToken) -> Self { Self::unwrap_cast( self.syntax - .splice_slots(8usize..=8usize, once(Some(element.into()))), + .splice_slots(9usize..=9usize, once(Some(element.into()))), ) } } impl JsClassExpression { + pub fn with_decorators(self, element: JsDecoratorList) -> Self { + Self::unwrap_cast( + self.syntax + .splice_slots(0usize..=0usize, once(Some(element.into_syntax().into()))), + ) + } pub fn with_class_token(self, element: SyntaxToken) -> Self { Self::unwrap_cast( self.syntax - .splice_slots(0usize..=0usize, once(Some(element.into()))), + .splice_slots(1usize..=1usize, once(Some(element.into()))), ) } pub fn with_id(self, element: Option) -> Self { Self::unwrap_cast(self.syntax.splice_slots( - 1usize..=1usize, + 2usize..=2usize, once(element.map(|element| element.into_syntax().into())), )) } pub fn with_type_parameters(self, element: Option) -> Self { Self::unwrap_cast(self.syntax.splice_slots( - 2usize..=2usize, + 3usize..=3usize, once(element.map(|element| element.into_syntax().into())), )) } pub fn with_extends_clause(self, element: Option) -> Self { Self::unwrap_cast(self.syntax.splice_slots( - 3usize..=3usize, + 4usize..=4usize, once(element.map(|element| element.into_syntax().into())), )) } pub fn with_implements_clause(self, element: Option) -> Self { Self::unwrap_cast(self.syntax.splice_slots( - 4usize..=4usize, + 5usize..=5usize, once(element.map(|element| element.into_syntax().into())), )) } pub fn with_l_curly_token(self, element: SyntaxToken) -> Self { Self::unwrap_cast( self.syntax - .splice_slots(5usize..=5usize, once(Some(element.into()))), + .splice_slots(6usize..=6usize, once(Some(element.into()))), ) } pub fn with_members(self, element: JsClassMemberList) -> Self { Self::unwrap_cast( self.syntax - .splice_slots(6usize..=6usize, once(Some(element.into_syntax().into()))), + .splice_slots(7usize..=7usize, once(Some(element.into_syntax().into()))), ) } pub fn with_r_curly_token(self, element: SyntaxToken) -> Self { Self::unwrap_cast( self.syntax - .splice_slots(7usize..=7usize, once(Some(element.into()))), + .splice_slots(8usize..=8usize, once(Some(element.into()))), ) } } @@ -758,6 +776,20 @@ impl JsDebuggerStatement { ) } } +impl JsDecorator { + pub fn with_at_token(self, element: SyntaxToken) -> Self { + Self::unwrap_cast( + self.syntax + .splice_slots(0usize..=0usize, once(Some(element.into()))), + ) + } + pub fn with_expression(self, element: AnyJsDecorator) -> Self { + Self::unwrap_cast( + self.syntax + .splice_slots(1usize..=1usize, once(Some(element.into_syntax().into()))), + ) + } +} impl JsDefaultClause { pub fn with_default_token(self, element: SyntaxToken) -> Self { Self::unwrap_cast( diff --git a/crates/rome_js_syntax/src/union_ext.rs b/crates/rome_js_syntax/src/union_ext.rs index 50cd03f7474..a6a782b0d2c 100644 --- a/crates/rome_js_syntax/src/union_ext.rs +++ b/crates/rome_js_syntax/src/union_ext.rs @@ -1,12 +1,20 @@ use crate::{ AnyJsArrowFunctionParameters, AnyJsBinding, AnyJsClass, AnyJsClassMember, AnyJsClassMemberName, AnyJsFunction, AnyJsFunctionBody, AnyTsPropertyAnnotation, AnyTsVariableAnnotation, - JsClassMemberList, JsExtendsClause, JsSyntaxToken, TsImplementsClause, TsReturnTypeAnnotation, - TsTypeAnnotation, TsTypeParameters, + JsClassMemberList, JsDecoratorList, JsExtendsClause, JsSyntaxToken, TsImplementsClause, + TsReturnTypeAnnotation, TsTypeAnnotation, TsTypeParameters, }; use rome_rowan::{AstSeparatedList, SyntaxResult}; impl AnyJsClass { + pub fn decorators(&self) -> JsDecoratorList { + match self { + AnyJsClass::JsClassDeclaration(declaration) => declaration.decorators(), + AnyJsClass::JsClassExpression(expression) => expression.decorators(), + AnyJsClass::JsClassExportDefaultDeclaration(declaration) => declaration.decorators(), + } + } + pub fn abstract_token(&self) -> Option { match self { AnyJsClass::JsClassDeclaration(declaration) => declaration.abstract_token(), diff --git a/xtask/codegen/js.ungram b/xtask/codegen/js.ungram index 82096256256..e318aa1ddc1 100644 --- a/xtask/codegen/js.ungram +++ b/xtask/codegen/js.ungram @@ -578,6 +578,7 @@ JsShorthandPropertyObjectMember = name: JsReferenceIdentifier /////////////// JsClassDeclaration = + decorators: JsDecoratorList 'abstract'? 'class' id: AnyJsBinding @@ -589,6 +590,7 @@ JsClassDeclaration = '}' JsClassExpression = + decorators: JsDecoratorList 'class' id: AnyJsBinding? type_parameters: TsTypeParameters? @@ -1403,6 +1405,7 @@ AnyJsExportDefaultDeclaration = // export default class {} // ^^^^^^^^ JsClassExportDefaultDeclaration = + decorators: JsDecoratorList 'abstract'? 'class' id: AnyJsBinding? @@ -1629,6 +1632,19 @@ JsFunctionBody = statements: JsStatementList '}' +JsDecoratorList = JsDecorator* + +JsDecorator = + '@' + expression: AnyJsDecorator + +AnyJsDecorator = + JsParenthesizedExpression + | JsCallExpression + | JsStaticMemberExpression + | JsIdentifierExpression + | JsBogusExpression + /////////////// // TYPESCRIPT /////////////// diff --git a/xtask/codegen/src/kinds_src.rs b/xtask/codegen/src/kinds_src.rs index c62cb903688..9129f2ea7cb 100644 --- a/xtask/codegen/src/kinds_src.rs +++ b/xtask/codegen/src/kinds_src.rs @@ -384,6 +384,8 @@ pub const JS_KINDS_SRC: KindsSrc = KindsSrc { "TS_EXPORT_DECLARE_CLAUSE", "JS_LITERAL_EXPORT_NAME", "JS_AWAIT_EXPRESSION", + "JS_DECORATOR", + "JS_DECORATOR_LIST", // TypeScript "TS_IDENTIFIER_BINDING", "TS_ANY_TYPE",