This repository has been archived by the owner on Aug 31, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 656
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(rslint_parser): Restructure simple statements (#1769)
Renames and restructures the following statements as we agreed to in our new JS grammar (#1719): * BlockStatement: Rename node and rename `stmts` child to `statements` * DebuggerStatement: Rename node * EmptyStatement: Rename node * ExpressionStatement: Rename node, `expr` child to `expression`, and add optional trailing semicolon * ReturnStatement: Rename node, and rename 'value' child to 'argument' * LabeledStatement: Rename node, change type of `label` child to a token, and rename `stmt` child to `body` * WithStatement: * Rename node * inline "condition" (it's not a condition) * rename `condition` to `object` * rename `cons` to `body` * Add parser test
- Loading branch information
1 parent
7dca80b
commit 8bdbafe
Showing
88 changed files
with
626 additions
and
476 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
crates/rome_formatter/src/ts/statements/debugger_statement.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
crates/rome_formatter/src/ts/statements/expression_statement.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 7 additions & 5 deletions
12
crates/rome_formatter/src/ts/statements/return_statement.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 11 additions & 10 deletions
21
crates/rome_formatter/src/ts/statements/with_statement.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,21 @@ | ||
use crate::{ | ||
format_elements, space_token, FormatElement, FormatResult, Formatter, ToFormatElement, | ||
format_elements, group_elements, soft_indent, space_token, FormatElement, FormatResult, | ||
Formatter, ToFormatElement, | ||
}; | ||
use rslint_parser::ast::WithStmt; | ||
use rslint_parser::ast::JsWithStatement; | ||
|
||
impl ToFormatElement for WithStmt { | ||
impl ToFormatElement for JsWithStatement { | ||
fn to_format_element(&self, formatter: &Formatter) -> FormatResult<FormatElement> { | ||
let with_token = formatter.format_token(&self.with_token()?)?; | ||
let condition = formatter.format_node(self.condition()?)?; | ||
let cons = formatter.format_node(self.cons()?)?; | ||
|
||
Ok(format_elements![ | ||
with_token, | ||
formatter.format_token(&self.with_token()?)?, | ||
space_token(), | ||
condition, | ||
group_elements(format_elements![ | ||
formatter.format_token(&self.l_paren_token()?)?, | ||
soft_indent(formatter.format_node(self.object()?)?), | ||
formatter.format_token(&self.r_paren_token()?)? | ||
]), | ||
space_token(), | ||
cons | ||
formatter.format_node(self.body()?)? | ||
]) | ||
} | ||
} |
Oops, something went wrong.