Skip to content

Commit ad50823

Browse files
committed
feedback
1 parent 0900e23 commit ad50823

File tree

5 files changed

+48
-8
lines changed

5 files changed

+48
-8
lines changed

crates/biome_html_parser/src/lexer/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ impl<'src> HtmlLexer<'src> {
428428
b"doctype" | b"DOCTYPE" if !context.is_svelte() => DOCTYPE_KW,
429429
b"html" | b"HTML" if context.is_doctype() => HTML_KW,
430430
buffer if context.is_svelte() => match buffer {
431-
b"debug" => DEBUG_KW,
431+
b"debug" if self.current_kind == T!["{@"] => DEBUG_KW,
432432
_ => SVELTE_IDENT,
433433
},
434434
_ => HTML_LITERAL,

crates/biome_html_parser/src/lexer/tests.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,9 +367,26 @@ fn svelte_openings() {
367367
fn svelte_keywords() {
368368
assert_lex!(
369369
HtmlLexContext::Svelte,
370-
" debug ",
370+
"{@debug ",
371+
SV_CURLY_AT: 2,
372+
DEBUG_KW: 5,
371373
WHITESPACE: 2,
374+
);
375+
376+
assert_lex!(
377+
HtmlLexContext::Svelte,
378+
"{@debug debug",
379+
SV_CURLY_AT: 2,
372380
DEBUG_KW: 5,
381+
WHITESPACE: 1,
382+
SVELTE_IDENT: 5,
383+
);
384+
385+
assert_lex!(
386+
HtmlLexContext::Svelte,
387+
" debug ",
388+
WHITESPACE: 2,
389+
SVELTE_IDENT: 5,
373390
WHITESPACE: 2,
374391
)
375392
}

crates/biome_html_parser/src/syntax/svelte.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ pub(crate) fn parse_svelte_at_block(p: &mut HtmlParser) -> ParsedSyntax {
2020

2121
match p.cur() {
2222
T![debug] => parse_debug_block(p, m),
23-
_ => Absent,
23+
_ => {
24+
m.abandon(p);
25+
Absent
26+
}
2427
}
2528
}
2629
pub(crate) fn parse_debug_block(p: &mut HtmlParser, marker: Marker) -> ParsedSyntax {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
{@debug
22
{@debug something}
3+
{@debug debug}

crates/biome_html_parser/tests/html_specs/error/svelte/debug.svelte.snap

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ expression: snapshot
77
```svelte
88
{@debug
99
{@debug something}
10+
{@debug debug}
1011
1112
```
1213
@@ -35,19 +36,29 @@ HtmlRoot {
3536
],
3637
r_curly_token: R_CURLY@25..26 "}" [] [],
3738
},
39+
SvelteDebugBlock {
40+
sv_curly_at_token: SV_CURLY_AT@26..29 "{@" [Newline("\n")] [],
41+
debug_token: DEBUG_KW@29..35 "debug" [] [Whitespace(" ")],
42+
bindings: SvelteBindingList [
43+
SvelteName {
44+
svelte_ident_token: SVELTE_IDENT@35..40 "debug" [] [],
45+
},
46+
],
47+
r_curly_token: R_CURLY@40..41 "}" [] [],
48+
},
3849
],
39-
eof_token: EOF@26..27 "" [Newline("\n")] [],
50+
eof_token: EOF@41..42 "" [Newline("\n")] [],
4051
}
4152
```
4253
4354
## CST
4455
4556
```
46-
0: HTML_ROOT@0..27
57+
0: HTML_ROOT@0..42
4758
0: (empty)
4859
1: (empty)
4960
2: (empty)
50-
3: HTML_ELEMENT_LIST@0..26
61+
3: HTML_ELEMENT_LIST@0..41
5162
0: SVELTE_DEBUG_BLOCK@0..7
5263
0: SV_CURLY_AT@0..2 "{@" [] []
5364
1: DEBUG_KW@2..7 "debug" [] []
@@ -60,7 +71,14 @@ HtmlRoot {
6071
0: SVELTE_NAME@16..25
6172
0: SVELTE_IDENT@16..25 "something" [] []
6273
3: R_CURLY@25..26 "}" [] []
63-
4: EOF@26..27 "" [Newline("\n")] []
74+
2: SVELTE_DEBUG_BLOCK@26..41
75+
0: SV_CURLY_AT@26..29 "{@" [Newline("\n")] []
76+
1: DEBUG_KW@29..35 "debug" [] [Whitespace(" ")]
77+
2: SVELTE_BINDING_LIST@35..40
78+
0: SVELTE_NAME@35..40
79+
0: SVELTE_IDENT@35..40 "debug" [] []
80+
3: R_CURLY@40..41 "}" [] []
81+
4: EOF@41..42 "" [Newline("\n")] []
6482
6583
```
6684
@@ -74,6 +92,7 @@ debug.svelte:2:1 parse ━━━━━━━━━━━━━━━━━━━
7492
1 │ {@debug
7593
> 2 │ {@debug something}
7694
^^
77-
3
95+
3 │ {@debug debug}
96+
4
7897
7998
```

0 commit comments

Comments
 (0)