Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions crates/biome_html_parser/src/lexer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1327,6 +1327,7 @@ impl<'src> Lexer<'src> for HtmlLexer<'src> {
self.current_kind
}

#[inline]
fn current_start(&self) -> TextSize {
self.current_start
}
Expand Down Expand Up @@ -1428,11 +1429,13 @@ impl<'src> Lexer<'src> for HtmlLexer<'src> {
self.diagnostics.push(diagnostic);
}

#[inline]
fn advance_char_unchecked(&mut self) {
let c = self.current_char_unchecked();
self.position += c.len_utf8();
}

#[inline]
fn advance(&mut self, n: usize) {
self.position += n;
}
Expand Down
2 changes: 2 additions & 0 deletions crates/biome_html_parser/src/syntax/astro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,12 @@ pub const ASTRO_DIRECTIVE_TOKEN_SET: TokenSet<HtmlSyntaxKind> = token_set![
T![define],
];

#[inline]
pub(crate) fn is_at_astro_directive_keyword(p: &mut HtmlParser) -> bool {
p.at_ts(ASTRO_DIRECTIVE_TOKEN_SET)
}

#[inline]
pub(crate) fn is_astro_directive_keyword(token: HtmlSyntaxKind) -> bool {
ASTRO_DIRECTIVE_TOKEN_SET.contains(token)
}
Expand Down
8 changes: 8 additions & 0 deletions crates/biome_html_parser/src/syntax/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ fn inside_tag_context(p: &HtmlParser) -> HtmlLexContext {
}
}

#[inline]
fn is_possible_component(p: &HtmlParser, tag_name: &str) -> bool {
tag_name
.chars()
Expand Down Expand Up @@ -352,6 +353,7 @@ fn parse_closing_tag(p: &mut HtmlParser) -> ParsedSyntax {
Present(m.complete(p, HTML_CLOSING_ELEMENT))
}

#[inline]
pub(crate) fn parse_html_element(p: &mut HtmlParser) -> ParsedSyntax {
match p.cur() {
T!["<![CDATA["] => parse_cdata_section(p),
Expand Down Expand Up @@ -540,6 +542,7 @@ fn parse_attribute(p: &mut HtmlParser) -> ParsedSyntax {
}
}

#[inline]
fn is_at_attribute_start(p: &mut HtmlParser) -> bool {
p.at_ts(token_set![
HTML_LITERAL,
Expand All @@ -552,6 +555,7 @@ fn is_at_attribute_start(p: &mut HtmlParser) -> bool {
|| (Astro.is_supported(p) && is_at_astro_directive_keyword(p))
}

#[inline]
fn parse_literal(p: &mut HtmlParser, kind: HtmlSyntaxKind) -> ParsedSyntax {
if !is_at_start_literal(p) {
return Absent;
Expand Down Expand Up @@ -596,6 +600,7 @@ fn parse_literal(p: &mut HtmlParser, kind: HtmlSyntaxKind) -> ParsedSyntax {
Present(m.complete(p, kind))
}

#[inline]
fn is_at_start_literal(p: &mut HtmlParser) -> bool {
p.at(HTML_LITERAL) || p.at(T!["{{"]) || p.at(T!["}}"])
}
Expand Down Expand Up @@ -720,6 +725,7 @@ fn parse_double_text_expression(p: &mut HtmlParser, context: HtmlLexContext) ->
}
}

#[inline]
pub(crate) fn is_at_opening_double_expression(p: &mut HtmlParser) -> bool {
p.at(T!["{{"])
}
Expand Down Expand Up @@ -840,10 +846,12 @@ impl TextExpression {
}
}

#[inline]
fn is_at_keyword(p: &mut HtmlParser) -> bool {
is_at_svelte_keyword(p) || is_at_html_keyword(p)
}

#[inline]
fn is_at_html_keyword(p: &mut HtmlParser) -> bool {
matches!(p.cur(), T![html] | T![doctype])
}
4 changes: 4 additions & 0 deletions crates/biome_html_parser/src/syntax/svelte.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1255,18 +1255,22 @@ const SVELTE_DIRECTIVE_KEYWORDS: TokenSet<HtmlSyntaxKind> = token_set!(
T![animate]
);

#[inline]
pub(crate) fn is_at_svelte_keyword(p: &HtmlParser) -> bool {
p.at_ts(SVELTE_KEYWORDS)
}

#[inline]
fn is_at_svelte_directive_keyword(token: HtmlSyntaxKind) -> bool {
SVELTE_DIRECTIVE_KEYWORDS.contains(token)
}

#[inline]
fn is_at_else_opening_block(p: &mut HtmlParser) -> bool {
p.at(T!["{:"]) && p.nth_at(1, T![else])
}

#[inline]
fn is_at_then_or_catch_block(p: &mut HtmlParser) -> bool {
p.at(T!["{:"]) && (p.nth_at(1, T![then]) || p.nth_at(1, T![catch]))
}
Expand Down