From 4efdfe186607b0b073edec6e78e9561f3063349a Mon Sep 17 00:00:00 2001 From: Micha Reiser Date: Tue, 7 Jun 2022 09:33:55 +0200 Subject: [PATCH] fix(syntax): Remove quotes from tokens in `JsSyntaxKind::to_string` `JsSyntaxKind::to_string` should return the token's string representation without any additional quotes. Quoting should happen at the call side if necessary. This fixes some double-quoting of parentheses inside of parser diagnostic messages for different parentheses. --- crates/rome_css_syntax/src/generated/kind.rs | 14 +++++++------- .../prettier/js/arrows-bind/arrows-bind.js.snap | 4 +--- .../async-do-expressions.js.snap | 6 ++---- .../prettier/js/babel-plugins/decimal.js.snap | 3 +-- .../js/bind-expressions/bind_parens.js.snap | 12 +++++------- .../prettier/js/bind-expressions/unary.js.snap | 12 +++++------- .../tests/specs/prettier/js/do/do.js.snap | 10 +++++----- .../specs/prettier/js/objects/expression.js.snap | 4 ++-- .../fsharp_style_pipeline_operator.js.snap | 8 +++----- .../hack_pipeline_operator.js.snap | 4 +--- .../error-recovery/index-signature.ts.snap | 10 +++++----- crates/rome_js_parser/src/syntax/pattern.rs | 2 +- .../inline/err/array_expr_incomplete.rast | 2 +- .../test_data/inline/err/assign_expr_left.rast | 2 +- .../inline/err/class_member_method_parameters.rast | 2 +- .../inline/err/do_while_no_continue_break.rast | 4 ++-- .../test_data/inline/err/do_while_stmt_err.rast | 4 ++-- .../test_data/inline/err/enum_no_l_curly.rast | 4 ++-- .../test_data/inline/err/for_stmt_err.rast | 12 ++++++------ .../test_data/inline/err/function_broken.rast | 2 +- .../test_data/inline/err/if_stmt_err.rast | 2 +- .../test_data/inline/err/import_assertion_err.rast | 4 ++-- ...complete_parenthesized_sequence_expression.rast | 2 +- .../inline/err/invalid_assignment_target.rast | 2 +- .../inline/err/js_invalid_assignment.rast | 2 +- .../inline/err/js_rewind_at_eof_token.rast | 4 ++-- .../err/jsx_child_expression_missing_r_curly.rast | 2 +- .../jsx_children_expression_missing_r_curly.rast | 2 +- .../inline/err/jsx_spread_attribute_error.rast | 4 ++-- .../test_data/inline/err/object_expr_err.rast | 2 +- .../test_data/inline/err/switch_stmt_err.rast | 10 +++++----- .../test_data/inline/err/template_literal.rast | 2 +- .../test_data/inline/err/ts_module_err.rast | 2 +- .../err/ts_named_import_specifier_error.rast | 2 +- .../inline/err/ts_template_literal_error.rast | 4 ++-- .../inline/err/typescript_enum_incomplete.rast | 2 +- .../test_data/inline/err/while_stmt_err.rast | 10 +++++----- crates/rome_js_syntax/src/generated/kind.rs | 14 +++++++------- crates/rome_json_syntax/src/generated/kind.rs | 12 ++++++------ xtask/codegen/src/generate_syntax_kinds.rs | 2 +- 40 files changed, 97 insertions(+), 110 deletions(-) diff --git a/crates/rome_css_syntax/src/generated/kind.rs b/crates/rome_css_syntax/src/generated/kind.rs index 6644a47a5fa..c0251107d9f 100644 --- a/crates/rome_css_syntax/src/generated/kind.rs +++ b/crates/rome_css_syntax/src/generated/kind.rs @@ -457,12 +457,12 @@ impl CssSyntaxKind { let tok = match self { SEMICOLON => ";", COMMA => ",", - L_PAREN => "'('", - R_PAREN => "')'", - L_CURLY => "'{'", - R_CURLY => "'}'", - L_BRACK => "'['", - R_BRACK => "']'", + L_PAREN => "(", + R_PAREN => ")", + L_CURLY => "{", + R_CURLY => "}", + L_BRACK => "[", + R_BRACK => "]", L_ANGLE => "<", R_ANGLE => ">", TILDE => "~", @@ -490,7 +490,7 @@ impl CssSyntaxKind { STAREQ => "*=", PERCENTEQ => "%=", AT => "@", - DOLLAR_EQ => "\"$=\"", + DOLLAR_EQ => "$=", TILDE_EQ => "~=", ALICEBLUE_KW => "aliceblue", ANTIQUEWHITE_KW => "antiquewhite", diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/arrows-bind/arrows-bind.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/arrows-bind/arrows-bind.js.snap index eee4667f4c5..83c08069f4b 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/arrows-bind/arrows-bind.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/arrows-bind/arrows-bind.js.snap @@ -1,8 +1,6 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs -assertion_line: 121 expression: arrows-bind.js - --- # Input ```js @@ -25,7 +23,7 @@ a: # Errors ``` -error[SyntaxError]: expected `')'` but instead found `:` +error[SyntaxError]: expected `)` but instead found `:` ┌─ arrows-bind.js:1:9 │ 1 │ a => ({}::b()``[''].c++ && 0 ? 0 : 0); diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/async-do-expressions/async-do-expressions.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/async-do-expressions/async-do-expressions.js.snap index d2f4e5a2abb..1f043ae1c1a 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/async-do-expressions/async-do-expressions.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/async-do-expressions/async-do-expressions.js.snap @@ -1,8 +1,6 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs -assertion_line: 125 expression: async-do-expressions.js - --- # Input ```js @@ -88,7 +86,7 @@ error[SyntaxError]: expected `while` but instead found `;` 3 │ }; │ ^ unexpected -error[SyntaxError]: expected `')'` but instead found `do` +error[SyntaxError]: expected `)` but instead found `do` ┌─ async-do-expressions.js:5:8 │ 5 │ (async do {}); @@ -144,7 +142,7 @@ error[SyntaxError]: expected `while` but instead found `}` 21 │ }; │ ^ unexpected -error[SyntaxError]: expected `')'` but instead found `;` +error[SyntaxError]: expected `)` but instead found `;` ┌─ async-do-expressions.js:21:2 │ 21 │ }; diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/babel-plugins/decimal.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/babel-plugins/decimal.js.snap index b42a1214ac6..1204af25c7e 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/babel-plugins/decimal.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/babel-plugins/decimal.js.snap @@ -1,6 +1,5 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs -assertion_line: 175 expression: decimal.js --- # Input @@ -127,7 +126,7 @@ error[SyntaxError]: expected a property, a shorthand property, a getter, a sette 9 │ ({ 0m: 0, .1m() {}, get 0.2m(){}, set 3m(_){}, async 4m() {}, *.5m() {} }); │ ^^^^^^^ Expected a property, a shorthand property, a getter, a setter, or a method here -error[SyntaxError]: expected `')'` but instead found `0.2m` +error[SyntaxError]: expected `)` but instead found `0.2m` ┌─ decimal.js:9:25 │ 9 │ ({ 0m: 0, .1m() {}, get 0.2m(){}, set 3m(_){}, async 4m() {}, *.5m() {} }); diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/bind-expressions/bind_parens.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/bind-expressions/bind_parens.js.snap index d38ee8db611..0f1b3c9cede 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/bind-expressions/bind_parens.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/bind-expressions/bind_parens.js.snap @@ -1,8 +1,6 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs -assertion_line: 144 expression: bind_parens.js - --- # Input ```js @@ -125,7 +123,7 @@ error[SyntaxError]: Expected a semicolon or an implicit semicolon after a statem │ │ An explicit or implicit semicolon is expected here... │ ...Which is required to end this statement -error[SyntaxError]: expected `')'` but instead found `:` +error[SyntaxError]: expected `)` but instead found `:` ┌─ bind_parens.js:2:8 │ 2 │ a || (b::c); @@ -296,7 +294,7 @@ error[SyntaxError]: Expected a semicolon or an implicit semicolon after a statem │ │ An explicit or implicit semicolon is expected here... │ ...Which is required to end this statement -error[SyntaxError]: expected `')'` but instead found `:` +error[SyntaxError]: expected `)` but instead found `:` ┌─ bind_parens.js:29:5 │ 29 │ (b.c::d).e; @@ -344,7 +342,7 @@ error[SyntaxError]: expected `=>` but instead found `.` 30 │ (b::c::d).e; │ ^ unexpected -error[SyntaxError]: expected `')'` but instead found `:` +error[SyntaxError]: expected `)` but instead found `:` ┌─ bind_parens.js:31:7 │ 31 │ new (a::b)(); @@ -356,13 +354,13 @@ error[SyntaxError]: expected `,` but instead found `:` 32 │ new f(a::b); │ ^ unexpected -error[SyntaxError]: expected `']'` but instead found `:` +error[SyntaxError]: expected `]` but instead found `:` ┌─ bind_parens.js:33:4 │ 33 │ f[a::b]; │ ^ unexpected -error[SyntaxError]: expected `']'` but instead found `:` +error[SyntaxError]: expected `]` but instead found `:` ┌─ bind_parens.js:34:4 │ 34 │ f[a::b()]; diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/bind-expressions/unary.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/bind-expressions/unary.js.snap index 76a08a8aeea..633f4f75f9a 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/bind-expressions/unary.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/bind-expressions/unary.js.snap @@ -1,8 +1,6 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs -assertion_line: 83 expression: unary.js - --- # Input ```js @@ -59,31 +57,31 @@ error[SyntaxError]: Expected a semicolon or an implicit semicolon after a statem │ │ An explicit or implicit semicolon is expected here... │ ...Which is required to end this statement -error[SyntaxError]: expected `')'` but instead found `:` +error[SyntaxError]: expected `)` but instead found `:` ┌─ unary.js:2:4 │ 2 │ !(x::y /* foo */); │ ^ unexpected -error[SyntaxError]: expected `')'` but instead found `:` +error[SyntaxError]: expected `)` but instead found `:` ┌─ unary.js:3:14 │ 3 │ !(/* foo */ x::y); │ ^ unexpected -error[SyntaxError]: expected `')'` but instead found `:` +error[SyntaxError]: expected `)` but instead found `:` ┌─ unary.js:6:4 │ 6 │ x::y │ ^ unexpected -error[SyntaxError]: expected `')'` but instead found `:` +error[SyntaxError]: expected `)` but instead found `:` ┌─ unary.js:9:4 │ 9 │ x::y │ ^ unexpected -error[SyntaxError]: expected `')'` but instead found `:` +error[SyntaxError]: expected `)` but instead found `:` ┌─ unary.js:13:4 │ 13 │ x::y // foo diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/do/do.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/do/do.js.snap index e4d6296af40..3449e03fb60 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/do/do.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/do/do.js.snap @@ -201,19 +201,19 @@ error[SyntaxError]: expected `while` but instead found `;` 18 │ }; │ ^ unexpected -error[SyntaxError]: expected `'}'` but instead found `do` +error[SyntaxError]: expected `}` but instead found `do` ┌─ do.js:25:9 │ 25 │ do { │ ^^ unexpected -error[SyntaxError]: expected `'}'` but instead found `if` +error[SyntaxError]: expected `}` but instead found `if` ┌─ do.js:26:11 │ 26 │ if (loggedIn) { │ ^^ unexpected -error[SyntaxError]: expected `')'` but instead found `do` +error[SyntaxError]: expected `)` but instead found `do` ┌─ do.js:37:2 │ 37 │ (do {}); @@ -225,7 +225,7 @@ error[SyntaxError]: expected `while` but instead found `)` 37 │ (do {}); │ ^ unexpected -error[SyntaxError]: expected `')'` but instead found `do` +error[SyntaxError]: expected `)` but instead found `do` ┌─ do.js:38:2 │ 38 │ (do {} + 1); @@ -261,7 +261,7 @@ error[SyntaxError]: expected `while` but instead found `;` 40 │ () => do {}; │ ^ unexpected -error[SyntaxError]: expected `')'` but instead found `do` +error[SyntaxError]: expected `)` but instead found `do` ┌─ do.js:42:2 │ 42 │ (do { diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/objects/expression.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/objects/expression.js.snap index b9d8df42928..b34a1feaea3 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/objects/expression.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/objects/expression.js.snap @@ -67,13 +67,13 @@ const a3 = { # Errors ``` -error[SyntaxError]: expected `')'` but instead found `:` +error[SyntaxError]: expected `)` but instead found `:` ┌─ expression.js:5:4 │ 5 │ ({}::b, 0); │ ^ unexpected -error[SyntaxError]: expected `')'` but instead found `:` +error[SyntaxError]: expected `)` but instead found `:` ┌─ expression.js:6:4 │ 6 │ ({}::b()``[''].c++ && 0 ? 0 : 0, 0); diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/pipeline-operator/fsharp_style_pipeline_operator.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/pipeline-operator/fsharp_style_pipeline_operator.js.snap index 6a7c7da18ef..f57c2f7518f 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/pipeline-operator/fsharp_style_pipeline_operator.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/pipeline-operator/fsharp_style_pipeline_operator.js.snap @@ -1,8 +1,6 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs -assertion_line: 125 expression: fsharp_style_pipeline_operator.js - --- # Input ```js @@ -228,7 +226,7 @@ error[SyntaxError]: Expected an expression for the left hand side of the `>` ope 28 │ const f = (x) => (x |> (y) => y + 1) │ ^ This operator requires a left hand side value -error[SyntaxError]: expected `')'` but instead found `=>` +error[SyntaxError]: expected `)` but instead found `=>` ┌─ fsharp_style_pipeline_operator.js:28:28 │ 28 │ const f = (x) => (x |> (y) => y + 1) @@ -274,7 +272,7 @@ error[SyntaxError]: Expected an expression for the left hand side of the `>` ope 39 │ |> (y => (y + 1 |> (z) => z * y)) │ ^ This operator requires a left hand side value -error[SyntaxError]: expected `')'` but instead found `=>` +error[SyntaxError]: expected `)` but instead found `=>` ┌─ fsharp_style_pipeline_operator.js:39:26 │ 39 │ |> (y => (y + 1 |> (z) => z * y)) @@ -292,7 +290,7 @@ error[SyntaxError]: Expected an expression for the left hand side of the `>` ope 44 │ return (y + 1 |> (z) => z * y); │ ^ This operator requires a left hand side value -error[SyntaxError]: expected `')'` but instead found `=>` +error[SyntaxError]: expected `)` but instead found `=>` ┌─ fsharp_style_pipeline_operator.js:44:28 │ 44 │ return (y + 1 |> (z) => z * y); diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/pipeline-operator/hack_pipeline_operator.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/pipeline-operator/hack_pipeline_operator.js.snap index 4699aa8b960..847608a3ec3 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/pipeline-operator/hack_pipeline_operator.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/pipeline-operator/hack_pipeline_operator.js.snap @@ -1,8 +1,6 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs -assertion_line: 125 expression: hack_pipeline_operator.js - --- # Input ```js @@ -580,7 +578,7 @@ error[SyntaxError]: Expected an expression for the left hand side of the `>` ope 44 │ |> (yield %) │ ^ This operator requires a left hand side value -error[SyntaxError]: expected `')'` but instead found `%` +error[SyntaxError]: expected `)` but instead found `%` ┌─ hack_pipeline_operator.js:44:15 │ 44 │ |> (yield %) diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/error-recovery/index-signature.ts.snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/error-recovery/index-signature.ts.snap index cf8f6088644..5dd906d8d73 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/typescript/error-recovery/index-signature.ts.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/error-recovery/index-signature.ts.snap @@ -60,7 +60,7 @@ error[SyntaxError]: An index signature must have a type annotation 1 │ type A = { [key: string] }; │ ^ -error[SyntaxError]: expected `']'` but instead found `,` +error[SyntaxError]: expected `]` but instead found `,` ┌─ index-signature.ts:4:13 │ 4 │ [a: string, b: string]: string; @@ -84,7 +84,7 @@ error[SyntaxError]: expected a statement but instead found '}' 5 │ }; │ ^ Expected a statement here -error[SyntaxError]: expected `']'` but instead found `,` +error[SyntaxError]: expected `]` but instead found `,` ┌─ index-signature.ts:7:13 │ 7 │ [a: string, b: string, c: string]: string; @@ -108,7 +108,7 @@ error[SyntaxError]: expected a statement but instead found '}' 8 │ }; │ ^ Expected a statement here -error[SyntaxError]: expected `']'` but instead found `,` +error[SyntaxError]: expected `]` but instead found `,` ┌─ index-signature.ts:11:41 │ 11 │ [loooooooooooooooooooooooooong: string, looooooooooooooooooooooooooooooooooooooong: string]: string; @@ -132,7 +132,7 @@ error[SyntaxError]: expected a statement but instead found '}' 12 │ } │ ^ Expected a statement here -error[SyntaxError]: expected `']'` but instead found `,` +error[SyntaxError]: expected `]` but instead found `,` ┌─ index-signature.ts:13:58 │ 13 │ type TooLong81 = { [loooooooooooooooooooooooooong: string, loooooooooooooooooong: string]: string; } @@ -156,7 +156,7 @@ error[SyntaxError]: expected a statement but instead found '}' 13 │ type TooLong81 = { [loooooooooooooooooooooooooong: string, loooooooooooooooooong: string]: string; } │ ^ Expected a statement here -error[SyntaxError]: expected `']'` but instead found `,` +error[SyntaxError]: expected `]` but instead found `,` ┌─ index-signature.ts:14:58 │ 14 │ type TooLong80 = { [loooooooooooooooooooooooooong: string, looooooooooooooooong: string]: string; } diff --git a/crates/rome_js_parser/src/syntax/pattern.rs b/crates/rome_js_parser/src/syntax/pattern.rs index 29e8e1987c7..d23eae52365 100644 --- a/crates/rome_js_parser/src/syntax/pattern.rs +++ b/crates/rome_js_parser/src/syntax/pattern.rs @@ -262,7 +262,7 @@ fn validate_rest_pattern( .primary( rest.range(p), &format!( - "Move the rest element to the end of the pattern, right before the closing {}", + "Move the rest element to the end of the pattern, right before the closing '{}'", end_token.to_string().unwrap(), ), ), diff --git a/crates/rome_js_parser/test_data/inline/err/array_expr_incomplete.rast b/crates/rome_js_parser/test_data/inline/err/array_expr_incomplete.rast index 91b0b454666..3765364a059 100644 --- a/crates/rome_js_parser/test_data/inline/err/array_expr_incomplete.rast +++ b/crates/rome_js_parser/test_data/inline/err/array_expr_incomplete.rast @@ -49,7 +49,7 @@ JsModule { 1: (empty) 3: EOF@9..10 "" [Newline("\n")] [] -- -error[SyntaxError]: expected `']'` but instead the file ends +error[SyntaxError]: expected `]` but instead the file ends ┌─ array_expr_incomplete.js:2:1 │ 2 │ diff --git a/crates/rome_js_parser/test_data/inline/err/assign_expr_left.rast b/crates/rome_js_parser/test_data/inline/err/assign_expr_left.rast index 316156d6f76..9eb493f5b1e 100644 --- a/crates/rome_js_parser/test_data/inline/err/assign_expr_left.rast +++ b/crates/rome_js_parser/test_data/inline/err/assign_expr_left.rast @@ -51,7 +51,7 @@ JsModule { 0: SEMICOLON@8..9 ";" [] [] 3: EOF@9..10 "" [Newline("\n")] [] -- -error[SyntaxError]: expected `')'` but instead found `=` +error[SyntaxError]: expected `)` but instead found `=` ┌─ assign_expr_left.js:1:3 │ 1 │ ( = foo); 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 4d61e64d52f..7b5ee303126 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 @@ -126,7 +126,7 @@ error[SyntaxError]: expected `,` but instead found `}` │ ^ unexpected -- -error[SyntaxError]: expected `')'` but instead the file ends +error[SyntaxError]: expected `)` but instead the file ends ┌─ class_member_method_parameters.js:2:1 │ 2 │ diff --git a/crates/rome_js_parser/test_data/inline/err/do_while_no_continue_break.rast b/crates/rome_js_parser/test_data/inline/err/do_while_no_continue_break.rast index 13ec5112eb5..1a7379873df 100644 --- a/crates/rome_js_parser/test_data/inline/err/do_while_no_continue_break.rast +++ b/crates/rome_js_parser/test_data/inline/err/do_while_no_continue_break.rast @@ -154,7 +154,7 @@ error[SyntaxError]: A `break` statement can only be used within an enclosing ite │ ^^^^^ -- -error[SyntaxError]: expected `')'` but instead found `continue` +error[SyntaxError]: expected `)` but instead found `continue` ┌─ do_while_no_continue_break.js:1:15 │ 1 │ do { } break (continue) @@ -209,7 +209,7 @@ error[SyntaxError]: A `continue` statement can only be used within an enclosing │ ^^^^^^^^ -- -error[SyntaxError]: expected `')'` but instead found `break` +error[SyntaxError]: expected `)` but instead found `break` ┌─ do_while_no_continue_break.js:2:18 │ 2 │ do { } continue (break) diff --git a/crates/rome_js_parser/test_data/inline/err/do_while_stmt_err.rast b/crates/rome_js_parser/test_data/inline/err/do_while_stmt_err.rast index 220485b2e99..1a62d0e8480 100644 --- a/crates/rome_js_parser/test_data/inline/err/do_while_stmt_err.rast +++ b/crates/rome_js_parser/test_data/inline/err/do_while_stmt_err.rast @@ -105,14 +105,14 @@ error[SyntaxError]: expected an expression but instead found ')' │ ^ Expected an expression here -- -error[SyntaxError]: expected `'('` but instead found `true` +error[SyntaxError]: expected `(` but instead found `true` ┌─ do_while_stmt_err.js:3:10 │ 3 │ do while true │ ^^^^ unexpected -- -error[SyntaxError]: expected `')'` but instead the file ends +error[SyntaxError]: expected `)` but instead the file ends ┌─ do_while_stmt_err.js:4:1 │ 4 │ diff --git a/crates/rome_js_parser/test_data/inline/err/enum_no_l_curly.rast b/crates/rome_js_parser/test_data/inline/err/enum_no_l_curly.rast index 9f9aece84a2..c3dd95d2fb6 100644 --- a/crates/rome_js_parser/test_data/inline/err/enum_no_l_curly.rast +++ b/crates/rome_js_parser/test_data/inline/err/enum_no_l_curly.rast @@ -62,14 +62,14 @@ error[SyntaxError]: `enum` statements must have a name │ ^^^^ -- -error[SyntaxError]: expected `'{'` but instead found `;` +error[SyntaxError]: expected `{` but instead found `;` ┌─ enum_no_l_curly.ts:1:5 │ 1 │ enum; │ ^ unexpected -- -error[SyntaxError]: expected `'{'` but instead found `;` +error[SyntaxError]: expected `{` but instead found `;` ┌─ enum_no_l_curly.ts:2:7 │ 2 │ enum A; diff --git a/crates/rome_js_parser/test_data/inline/err/for_stmt_err.rast b/crates/rome_js_parser/test_data/inline/err/for_stmt_err.rast index 1fca23aa99b..542eb9acb84 100644 --- a/crates/rome_js_parser/test_data/inline/err/for_stmt_err.rast +++ b/crates/rome_js_parser/test_data/inline/err/for_stmt_err.rast @@ -485,42 +485,42 @@ JsModule { 2: R_CURLY@195..196 "}" [] [] 3: EOF@196..197 "" [Newline("\n")] [] -- -error[SyntaxError]: expected `'('` but instead found `;` +error[SyntaxError]: expected `(` but instead found `;` ┌─ for_stmt_err.js:1:5 │ 1 │ for ;; {} │ ^ unexpected -- -error[SyntaxError]: expected `')'` but instead found `for` +error[SyntaxError]: expected `)` but instead found `for` ┌─ for_stmt_err.js:2:1 │ 2 │ for let i = 5; i < 10; i++ {} │ ^^^ unexpected -- -error[SyntaxError]: expected `'('` but instead found `let` +error[SyntaxError]: expected `(` but instead found `let` ┌─ for_stmt_err.js:2:5 │ 2 │ for let i = 5; i < 10; i++ {} │ ^^^ unexpected -- -error[SyntaxError]: expected `')'` but instead found `{` +error[SyntaxError]: expected `)` but instead found `{` ┌─ for_stmt_err.js:2:28 │ 2 │ for let i = 5; i < 10; i++ {} │ ^ unexpected -- -error[SyntaxError]: expected `'('` but instead found `let` +error[SyntaxError]: expected `(` but instead found `let` ┌─ for_stmt_err.js:3:5 │ 3 │ for let i = 5; i < 10; ++i {} │ ^^^ unexpected -- -error[SyntaxError]: expected `')'` but instead found `{` +error[SyntaxError]: expected `)` but instead found `{` ┌─ for_stmt_err.js:3:28 │ 3 │ for let i = 5; i < 10; ++i {} diff --git a/crates/rome_js_parser/test_data/inline/err/function_broken.rast b/crates/rome_js_parser/test_data/inline/err/function_broken.rast index eee89e80e99..6a301a58148 100644 --- a/crates/rome_js_parser/test_data/inline/err/function_broken.rast +++ b/crates/rome_js_parser/test_data/inline/err/function_broken.rast @@ -100,7 +100,7 @@ error[SyntaxError]: expected a function body but instead found ')' │ ^ Expected a function body here -- -error[SyntaxError]: expected `'}'` but instead the file ends +error[SyntaxError]: expected `}` but instead the file ends ┌─ function_broken.js:2:1 │ 2 │ diff --git a/crates/rome_js_parser/test_data/inline/err/if_stmt_err.rast b/crates/rome_js_parser/test_data/inline/err/if_stmt_err.rast index 7d3d89a9713..015cea07fae 100644 --- a/crates/rome_js_parser/test_data/inline/err/if_stmt_err.rast +++ b/crates/rome_js_parser/test_data/inline/err/if_stmt_err.rast @@ -178,7 +178,7 @@ error[SyntaxError]: expected a statement but instead found 'else' │ ^^^^ Expected a statement here -- -error[SyntaxError]: expected `'('` but instead found `else` +error[SyntaxError]: expected `(` but instead found `else` ┌─ if_stmt_err.js:3:4 │ 3 │ if else {} diff --git a/crates/rome_js_parser/test_data/inline/err/import_assertion_err.rast b/crates/rome_js_parser/test_data/inline/err/import_assertion_err.rast index b5eb99f924a..a980cc929f3 100644 --- a/crates/rome_js_parser/test_data/inline/err/import_assertion_err.rast +++ b/crates/rome_js_parser/test_data/inline/err/import_assertion_err.rast @@ -500,7 +500,7 @@ error[SyntaxError]: Duplicate assertion keys are not allowed │ First use of the key `type` -- -error[SyntaxError]: expected `'{'` but instead found `;` +error[SyntaxError]: expected `{` but instead found `;` ┌─ import_assertion_err.js:7:18 │ 7 │ import "x" assert; @@ -528,7 +528,7 @@ error[SyntaxError]: expected `string literal` but instead found `1` │ ^ unexpected -- -error[SyntaxError]: expected `'{'` but instead the file ends +error[SyntaxError]: expected `{` but instead the file ends ┌─ import_assertion_err.js:10:1 │ 10 │ diff --git a/crates/rome_js_parser/test_data/inline/err/incomplete_parenthesized_sequence_expression.rast b/crates/rome_js_parser/test_data/inline/err/incomplete_parenthesized_sequence_expression.rast index 16ce2a62d6c..4b8f63669c8 100644 --- a/crates/rome_js_parser/test_data/inline/err/incomplete_parenthesized_sequence_expression.rast +++ b/crates/rome_js_parser/test_data/inline/err/incomplete_parenthesized_sequence_expression.rast @@ -92,7 +92,7 @@ error[SyntaxError]: expected an expression but instead found ';' │ ^ Expected an expression here -- -error[SyntaxError]: expected `')'` but instead found `;` +error[SyntaxError]: expected `)` but instead found `;` ┌─ incomplete_parenthesized_sequence_expression.js:2:9 │ 2 │ (a, b, c; diff --git a/crates/rome_js_parser/test_data/inline/err/invalid_assignment_target.rast b/crates/rome_js_parser/test_data/inline/err/invalid_assignment_target.rast index 1236e75fa22..d4c1fbe8b17 100644 --- a/crates/rome_js_parser/test_data/inline/err/invalid_assignment_target.rast +++ b/crates/rome_js_parser/test_data/inline/err/invalid_assignment_target.rast @@ -243,7 +243,7 @@ error[SyntaxError]: Invalid assignment to `++a` │ ^^^ This expression cannot be assigned to -- -error[SyntaxError]: expected `')'` but instead found `;` +error[SyntaxError]: expected `)` but instead found `;` ┌─ invalid_assignment_target.js:3:7 │ 3 │ (a = b; diff --git a/crates/rome_js_parser/test_data/inline/err/js_invalid_assignment.rast b/crates/rome_js_parser/test_data/inline/err/js_invalid_assignment.rast index 68366aa0c5e..38395005e7f 100644 --- a/crates/rome_js_parser/test_data/inline/err/js_invalid_assignment.rast +++ b/crates/rome_js_parser/test_data/inline/err/js_invalid_assignment.rast @@ -252,7 +252,7 @@ error[SyntaxError]: expected an expression but instead found '=' │ ^ Expected an expression here -- -error[SyntaxError]: expected `')'` but instead the file ends +error[SyntaxError]: expected `)` but instead the file ends ┌─ js_invalid_assignment.js:2:1 │ 2 │ diff --git a/crates/rome_js_parser/test_data/inline/err/js_rewind_at_eof_token.rast b/crates/rome_js_parser/test_data/inline/err/js_rewind_at_eof_token.rast index 67f849b8699..f6bb1860d17 100644 --- a/crates/rome_js_parser/test_data/inline/err/js_rewind_at_eof_token.rast +++ b/crates/rome_js_parser/test_data/inline/err/js_rewind_at_eof_token.rast @@ -128,7 +128,7 @@ error[SyntaxError]: expected `,` but instead found `(` │ ^ unexpected -- -error[SyntaxError]: expected `')'` but instead found `{` +error[SyntaxError]: expected `)` but instead found `{` ┌─ js_rewind_at_eof_token.js:1:15 │ 1 │ (([zAgRvz=[=(e{V{ @@ -142,7 +142,7 @@ error[SyntaxError]: expected `,` but instead found `{` │ ^ unexpected -- -error[SyntaxError]: expected `'}'` but instead the file ends +error[SyntaxError]: expected `}` but instead the file ends ┌─ js_rewind_at_eof_token.js:2:1 │ 2 │ diff --git a/crates/rome_js_parser/test_data/inline/err/jsx_child_expression_missing_r_curly.rast b/crates/rome_js_parser/test_data/inline/err/jsx_child_expression_missing_r_curly.rast index ee509551e9b..d41992644da 100644 --- a/crates/rome_js_parser/test_data/inline/err/jsx_child_expression_missing_r_curly.rast +++ b/crates/rome_js_parser/test_data/inline/err/jsx_child_expression_missing_r_curly.rast @@ -78,7 +78,7 @@ JsModule { 1: (empty) 3: EOF@20..21 "" [Newline("\n")] [] -- -error[SyntaxError]: expected `'}'` but instead found `<` +error[SyntaxError]: expected `}` but instead found `<` ┌─ jsx_child_expression_missing_r_curly.jsx:1:14 │ 1 │ { 4 + 3 diff --git a/crates/rome_js_parser/test_data/inline/err/jsx_children_expression_missing_r_curly.rast b/crates/rome_js_parser/test_data/inline/err/jsx_children_expression_missing_r_curly.rast index 74c8bf0f1e3..2216e115827 100644 --- a/crates/rome_js_parser/test_data/inline/err/jsx_children_expression_missing_r_curly.rast +++ b/crates/rome_js_parser/test_data/inline/err/jsx_children_expression_missing_r_curly.rast @@ -88,7 +88,7 @@ JsModule { 1: (empty) 3: EOF@36..37 "" [Newline("\n")] [] -- -error[SyntaxError]: expected `'}'` but instead found `some` +error[SyntaxError]: expected `}` but instead found `some` ┌─ jsx_children_expression_missing_r_curly.jsx:3:3 │ 3 │ some text diff --git a/crates/rome_js_parser/test_data/inline/err/jsx_spread_attribute_error.rast b/crates/rome_js_parser/test_data/inline/err/jsx_spread_attribute_error.rast index 0273d5e62af..bb3614a78f7 100644 --- a/crates/rome_js_parser/test_data/inline/err/jsx_spread_attribute_error.rast +++ b/crates/rome_js_parser/test_data/inline/err/jsx_spread_attribute_error.rast @@ -266,7 +266,7 @@ error[SyntaxError]: Comma operator isn't a valid value for a JSX spread argument │ ^^^^^^^^^^ -- -error[SyntaxError]: expected `'{'` but instead found `...` +error[SyntaxError]: expected `{` but instead found `...` ┌─ jsx_spread_attribute_error.jsx:3:4 │ 3 │ ; @@ -280,7 +280,7 @@ error[SyntaxError]: expected `...` but instead found `obj` │ ^^^ unexpected -- -error[SyntaxError]: expected `'}'` but instead found `invalidProp` +error[SyntaxError]: expected `}` but instead found `invalidProp` ┌─ jsx_spread_attribute_error.jsx:8:7 │ 8 │ invalidProp="HelloWorld" diff --git a/crates/rome_js_parser/test_data/inline/err/object_expr_err.rast b/crates/rome_js_parser/test_data/inline/err/object_expr_err.rast index 61e25cfe01d..d84bb059fd9 100644 --- a/crates/rome_js_parser/test_data/inline/err/object_expr_err.rast +++ b/crates/rome_js_parser/test_data/inline/err/object_expr_err.rast @@ -171,7 +171,7 @@ error[SyntaxError]: expected `,` but instead found `bar` │ ^^^ unexpected -- -error[SyntaxError]: expected `'}'` but instead the file ends +error[SyntaxError]: expected `}` but instead the file ends ┌─ object_expr_err.js:4:1 │ 4 │ diff --git a/crates/rome_js_parser/test_data/inline/err/switch_stmt_err.rast b/crates/rome_js_parser/test_data/inline/err/switch_stmt_err.rast index 850c5178f40..245ab4c41fb 100644 --- a/crates/rome_js_parser/test_data/inline/err/switch_stmt_err.rast +++ b/crates/rome_js_parser/test_data/inline/err/switch_stmt_err.rast @@ -268,28 +268,28 @@ JsModule { 6: R_CURLY@149..150 "}" [] [] 3: EOF@150..151 "" [Newline("\n")] [] -- -error[SyntaxError]: expected `'('` but instead found `foo` +error[SyntaxError]: expected `(` but instead found `foo` ┌─ switch_stmt_err.js:1:8 │ 1 │ switch foo {} │ ^^^ unexpected -- -error[SyntaxError]: expected `')'` but instead found `{` +error[SyntaxError]: expected `)` but instead found `{` ┌─ switch_stmt_err.js:1:12 │ 1 │ switch foo {} │ ^ unexpected -- -error[SyntaxError]: expected `'('` but instead found `{` +error[SyntaxError]: expected `(` but instead found `{` ┌─ switch_stmt_err.js:2:8 │ 2 │ switch {} │ ^ unexpected -- -error[SyntaxError]: expected `'('` but instead found `{` +error[SyntaxError]: expected `(` but instead found `{` ┌─ switch_stmt_err.js:3:8 │ 3 │ switch { var i = 0 } @@ -303,7 +303,7 @@ error[SyntaxError]: expected a default, or a case but instead found 'var i = 0' │ ^^^^^^^^^ Expected a default, or a case here -- -error[SyntaxError]: expected `'('` but instead found `{` +error[SyntaxError]: expected `(` but instead found `{` ┌─ switch_stmt_err.js:4:8 │ 4 │ switch { var i = 0; case "bar": {} } diff --git a/crates/rome_js_parser/test_data/inline/err/template_literal.rast b/crates/rome_js_parser/test_data/inline/err/template_literal.rast index 2d2ced8bbc3..6d2f400cdeb 100644 --- a/crates/rome_js_parser/test_data/inline/err/template_literal.rast +++ b/crates/rome_js_parser/test_data/inline/err/template_literal.rast @@ -141,7 +141,7 @@ error[SyntaxError]: expected an expression but instead found '}' │ ^ Expected an expression here -- -error[SyntaxError]: expected `'}'` but instead found `a` +error[SyntaxError]: expected `}` but instead found `a` ┌─ template_literal.js:2:14 │ 2 │ let b = `${a a}` diff --git a/crates/rome_js_parser/test_data/inline/err/ts_module_err.rast b/crates/rome_js_parser/test_data/inline/err/ts_module_err.rast index fa59eb19c24..41626dfb53e 100644 --- a/crates/rome_js_parser/test_data/inline/err/ts_module_err.rast +++ b/crates/rome_js_parser/test_data/inline/err/ts_module_err.rast @@ -74,7 +74,7 @@ JsModule { 0: SEMICOLON@71..88 ";" [] [Whitespace(" "), Comments("// missing semi")] 3: EOF@88..89 "" [Newline("\n")] [] -- -error[SyntaxError]: expected `'{'` but instead found `;` +error[SyntaxError]: expected `{` but instead found `;` ┌─ ts_module_err.ts:1:17 │ 1 │ declare module a; // missing body diff --git a/crates/rome_js_parser/test_data/inline/err/ts_named_import_specifier_error.rast b/crates/rome_js_parser/test_data/inline/err/ts_named_import_specifier_error.rast index c7b9158f09e..e09ec3388aa 100644 --- a/crates/rome_js_parser/test_data/inline/err/ts_named_import_specifier_error.rast +++ b/crates/rome_js_parser/test_data/inline/err/ts_named_import_specifier_error.rast @@ -257,7 +257,7 @@ error[SyntaxError]: expected `as` but instead found `}` │ ^ unexpected -- -error[SyntaxError]: expected `'}'` but instead the file ends +error[SyntaxError]: expected `}` but instead the file ends ┌─ ts_named_import_specifier_error.ts:6:1 │ 6 │ diff --git a/crates/rome_js_parser/test_data/inline/err/ts_template_literal_error.rast b/crates/rome_js_parser/test_data/inline/err/ts_template_literal_error.rast index 36a75cf9004..f9831e62617 100644 --- a/crates/rome_js_parser/test_data/inline/err/ts_template_literal_error.rast +++ b/crates/rome_js_parser/test_data/inline/err/ts_template_literal_error.rast @@ -165,14 +165,14 @@ JsModule { 2: BACKTICK@63..64 "`" [] [] 3: EOF@64..65 "" [Newline("\n")] [] -- -error[SyntaxError]: expected `'}'` but instead found `B` +error[SyntaxError]: expected `}` but instead found `B` ┌─ ts_template_literal_error.ts:3:15 │ 3 │ type C = `${A B}bcd` │ ^ unexpected -- -error[SyntaxError]: expected `'}'` but instead found `B` +error[SyntaxError]: expected `}` but instead found `B` ┌─ ts_template_literal_error.ts:4:15 │ 4 │ type D = `${A B` diff --git a/crates/rome_js_parser/test_data/inline/err/typescript_enum_incomplete.rast b/crates/rome_js_parser/test_data/inline/err/typescript_enum_incomplete.rast index 95df574142e..9677cc16d38 100644 --- a/crates/rome_js_parser/test_data/inline/err/typescript_enum_incomplete.rast +++ b/crates/rome_js_parser/test_data/inline/err/typescript_enum_incomplete.rast @@ -30,7 +30,7 @@ JsModule { 5: (empty) 3: EOF@8..9 "" [Newline("\n")] [] -- -error[SyntaxError]: expected `'}'` but instead the file ends +error[SyntaxError]: expected `}` but instead the file ends ┌─ typescript_enum_incomplete.ts:2:1 │ 2 │ diff --git a/crates/rome_js_parser/test_data/inline/err/while_stmt_err.rast b/crates/rome_js_parser/test_data/inline/err/while_stmt_err.rast index 10bed0be9bf..6267a3f1ef6 100644 --- a/crates/rome_js_parser/test_data/inline/err/while_stmt_err.rast +++ b/crates/rome_js_parser/test_data/inline/err/while_stmt_err.rast @@ -101,35 +101,35 @@ JsModule { 0: R_CURLY@50..51 "}" [] [] 3: EOF@51..52 "" [Newline("\n")] [] -- -error[SyntaxError]: expected `'('` but instead found `true` +error[SyntaxError]: expected `(` but instead found `true` ┌─ while_stmt_err.js:1:7 │ 1 │ while true {} │ ^^^^ unexpected -- -error[SyntaxError]: expected `')'` but instead found `{` +error[SyntaxError]: expected `)` but instead found `{` ┌─ while_stmt_err.js:1:12 │ 1 │ while true {} │ ^ unexpected -- -error[SyntaxError]: expected `'('` but instead found `{` +error[SyntaxError]: expected `(` but instead found `{` ┌─ while_stmt_err.js:2:7 │ 2 │ while {} │ ^ unexpected -- -error[SyntaxError]: expected `')'` but instead found `{` +error[SyntaxError]: expected `)` but instead found `{` ┌─ while_stmt_err.js:3:13 │ 3 │ while (true {} │ ^ unexpected -- -error[SyntaxError]: expected `'('` but instead found `true` +error[SyntaxError]: expected `(` but instead found `true` ┌─ while_stmt_err.js:4:7 │ 4 │ while true) } diff --git a/crates/rome_js_syntax/src/generated/kind.rs b/crates/rome_js_syntax/src/generated/kind.rs index a9994788b92..3a64f255ed9 100644 --- a/crates/rome_js_syntax/src/generated/kind.rs +++ b/crates/rome_js_syntax/src/generated/kind.rs @@ -644,12 +644,12 @@ impl JsSyntaxKind { let tok = match self { SEMICOLON => ";", COMMA => ",", - L_PAREN => "'('", - R_PAREN => "')'", - L_CURLY => "'{'", - R_CURLY => "'}'", - L_BRACK => "'['", - R_BRACK => "']'", + L_PAREN => "(", + R_PAREN => ")", + L_CURLY => "{", + R_CURLY => "}", + L_BRACK => "[", + R_BRACK => "]", L_ANGLE => "<", R_ANGLE => ">", TILDE => "~", @@ -700,7 +700,7 @@ impl JsSyntaxKind { STAR2EQ => "**=", QUESTION2EQ => "??=", AT => "@", - BACKTICK => "'`'", + BACKTICK => "`", BREAK_KW => "break", CASE_KW => "case", CATCH_KW => "catch", diff --git a/crates/rome_json_syntax/src/generated/kind.rs b/crates/rome_json_syntax/src/generated/kind.rs index c11289ceee3..4b687873214 100644 --- a/crates/rome_json_syntax/src/generated/kind.rs +++ b/crates/rome_json_syntax/src/generated/kind.rs @@ -74,12 +74,12 @@ impl JsonSyntaxKind { let tok = match self { COLON => ":", COMMA => ",", - L_PAREN => "'('", - R_PAREN => "')'", - L_CURLY => "'{'", - R_CURLY => "'}'", - L_BRACK => "'['", - R_BRACK => "']'", + L_PAREN => "(", + R_PAREN => ")", + L_CURLY => "{", + R_CURLY => "}", + L_BRACK => "[", + R_BRACK => "]", NULL_KW => "null", TRUE_KW => "true", FALSE_KW => "false", diff --git a/xtask/codegen/src/generate_syntax_kinds.rs b/xtask/codegen/src/generate_syntax_kinds.rs index b4556896d22..0f27ad3c689 100644 --- a/xtask/codegen/src/generate_syntax_kinds.rs +++ b/xtask/codegen/src/generate_syntax_kinds.rs @@ -21,7 +21,7 @@ pub fn generate_syntax_kinds(grammar: KindsSrc, language_kind: LanguageKind) -> quote! { #(#cs)* } } }); - let punctuation_strings = punctuation_values.clone().map(|name| name.to_string()); + let punctuation_strings = grammar.punct.iter().map(|(token, _name)| token); let punctuation = grammar .punct