Skip to content
This repository has been archived by the owner on Aug 31, 2023. It is now read-only.

Commit

Permalink
feat(rome_js_parser): EcmaScript @decorators #4252
Browse files Browse the repository at this point in the history
  • Loading branch information
denbezrukov committed Apr 30, 2023
1 parent c8ba346 commit b0ff097
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 1 addition & 3 deletions crates/rome_js_formatter/src/comments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -526,9 +526,7 @@ fn handle_property_comments(comment: DecoratedComment<JsLanguage>) -> 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);
}
}

Expand Down
7 changes: 3 additions & 4 deletions crates/rome_js_formatter/tests/quick_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>
class Test2 {
@anotherDecorator() // leading comment
prop: string;
}
Expand Down
3 changes: 3 additions & 0 deletions crates/rome_js_formatter/tests/specs/ts/decoartors.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit b0ff097

Please sign in to comment.