From b0ff097706e064e11bac076c351e66cd28031d4d Mon Sep 17 00:00:00 2001 From: Denis Bezrukov <6227442+denbezrukov@users.noreply.github.com> Date: Sun, 30 Apr 2023 17:59:43 +0300 Subject: [PATCH] feat(rome_js_parser): EcmaScript @decorators #4252 --- crates/rome_js_formatter/src/comments.rs | 4 +--- crates/rome_js_formatter/tests/quick_test.rs | 7 +++---- crates/rome_js_formatter/tests/specs/ts/decoartors.ts.snap | 3 +++ 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/crates/rome_js_formatter/src/comments.rs b/crates/rome_js_formatter/src/comments.rs index 777a8036bb0..583937fe91e 100644 --- a/crates/rome_js_formatter/src/comments.rs +++ b/crates/rome_js_formatter/src/comments.rs @@ -526,9 +526,7 @@ fn handle_property_comments(comment: DecoratedComment) -> CommentPla if let (Some(preceding), Some(following)) = (comment.preceding_node(), comment.following_node()) { if preceding.kind() == JsSyntaxKind::JS_DECORATOR { - if let Some(modifier) = AnyJsPropertyModifier::cast_ref(following) { - return CommentPlacement::leading(modifier.into_syntax(), comment); - } + return CommentPlacement::leading(following.clone(), comment); } } diff --git a/crates/rome_js_formatter/tests/quick_test.rs b/crates/rome_js_formatter/tests/quick_test.rs index 9e36ff20ea9..a7432e4f160 100644 --- a/crates/rome_js_formatter/tests/quick_test.rs +++ b/crates/rome_js_formatter/tests/quick_test.rs @@ -13,10 +13,9 @@ mod language { // use this test check if your snippet prints as you wish, without using a snapshot fn quick_test() { let src = r#" -abstract class Something3 { - @foo() - // comment - abstract method(): Array +class Test2 { + @anotherDecorator() // leading comment + prop: string; } 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 485a8a4d444..6db5ce451da 100644 --- a/crates/rome_js_formatter/tests/specs/ts/decoartors.ts.snap +++ b/crates/rome_js_formatter/tests/specs/ts/decoartors.ts.snap @@ -113,6 +113,9 @@ class Test2 { ## Unimplemented nodes/tokens +"\t\t@par" => 61..67 +"\t\t@readon" => 76..85 +"\t\t@aVeryLongDecoratorNameLetsSeeWhatHappensWith" => 103..150 "@param" => 174..180 "@param" => 218..224