Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(parse/html): split HtmlName into HtmlTagName and HtmlAttributeName #5267

Merged
merged 1 commit into from
Mar 3, 2025
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
30 changes: 18 additions & 12 deletions crates/biome_html_factory/src/generated/node_factory.rs

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

65 changes: 42 additions & 23 deletions crates/biome_html_factory/src/generated/syntax_factory.rs

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

108 changes: 76 additions & 32 deletions crates/biome_html_formatter/src/generated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,44 @@ impl IntoFormat<HtmlFormatContext> for biome_html_syntax::HtmlAttributeInitializ
FormatOwnedWithRule :: new (self , crate :: html :: auxiliary :: attribute_initializer_clause :: FormatHtmlAttributeInitializerClause :: default ())
}
}
impl FormatRule<biome_html_syntax::HtmlAttributeName>
for crate::html::auxiliary::attribute_name::FormatHtmlAttributeName
{
type Context = HtmlFormatContext;
#[inline(always)]
fn fmt(
&self,
node: &biome_html_syntax::HtmlAttributeName,
f: &mut HtmlFormatter,
) -> FormatResult<()> {
FormatNodeRule::<biome_html_syntax::HtmlAttributeName>::fmt(self, node, f)
}
}
impl AsFormat<HtmlFormatContext> for biome_html_syntax::HtmlAttributeName {
type Format<'a> = FormatRefWithRule<
'a,
biome_html_syntax::HtmlAttributeName,
crate::html::auxiliary::attribute_name::FormatHtmlAttributeName,
>;
fn format(&self) -> Self::Format<'_> {
FormatRefWithRule::new(
self,
crate::html::auxiliary::attribute_name::FormatHtmlAttributeName::default(),
)
}
}
impl IntoFormat<HtmlFormatContext> for biome_html_syntax::HtmlAttributeName {
type Format = FormatOwnedWithRule<
biome_html_syntax::HtmlAttributeName,
crate::html::auxiliary::attribute_name::FormatHtmlAttributeName,
>;
fn into_format(self) -> Self::Format {
FormatOwnedWithRule::new(
self,
crate::html::auxiliary::attribute_name::FormatHtmlAttributeName::default(),
)
}
}
impl FormatRule<biome_html_syntax::HtmlCdataSection>
for crate::html::auxiliary::cdata_section::FormatHtmlCdataSection
{
Expand Down Expand Up @@ -303,38 +341,6 @@ impl IntoFormat<HtmlFormatContext> for biome_html_syntax::HtmlElement {
)
}
}
impl FormatRule<biome_html_syntax::HtmlName> for crate::html::auxiliary::name::FormatHtmlName {
type Context = HtmlFormatContext;
#[inline(always)]
fn fmt(&self, node: &biome_html_syntax::HtmlName, f: &mut HtmlFormatter) -> FormatResult<()> {
FormatNodeRule::<biome_html_syntax::HtmlName>::fmt(self, node, f)
}
}
impl AsFormat<HtmlFormatContext> for biome_html_syntax::HtmlName {
type Format<'a> = FormatRefWithRule<
'a,
biome_html_syntax::HtmlName,
crate::html::auxiliary::name::FormatHtmlName,
>;
fn format(&self) -> Self::Format<'_> {
FormatRefWithRule::new(
self,
crate::html::auxiliary::name::FormatHtmlName::default(),
)
}
}
impl IntoFormat<HtmlFormatContext> for biome_html_syntax::HtmlName {
type Format = FormatOwnedWithRule<
biome_html_syntax::HtmlName,
crate::html::auxiliary::name::FormatHtmlName,
>;
fn into_format(self) -> Self::Format {
FormatOwnedWithRule::new(
self,
crate::html::auxiliary::name::FormatHtmlName::default(),
)
}
}
impl FormatRule<biome_html_syntax::HtmlOpeningElement>
for crate::html::auxiliary::opening_element::FormatHtmlOpeningElement
{
Expand Down Expand Up @@ -477,6 +483,44 @@ impl IntoFormat<HtmlFormatContext> for biome_html_syntax::HtmlString {
)
}
}
impl FormatRule<biome_html_syntax::HtmlTagName>
for crate::html::auxiliary::tag_name::FormatHtmlTagName
{
type Context = HtmlFormatContext;
#[inline(always)]
fn fmt(
&self,
node: &biome_html_syntax::HtmlTagName,
f: &mut HtmlFormatter,
) -> FormatResult<()> {
FormatNodeRule::<biome_html_syntax::HtmlTagName>::fmt(self, node, f)
}
}
impl AsFormat<HtmlFormatContext> for biome_html_syntax::HtmlTagName {
type Format<'a> = FormatRefWithRule<
'a,
biome_html_syntax::HtmlTagName,
crate::html::auxiliary::tag_name::FormatHtmlTagName,
>;
fn format(&self) -> Self::Format<'_> {
FormatRefWithRule::new(
self,
crate::html::auxiliary::tag_name::FormatHtmlTagName::default(),
)
}
}
impl IntoFormat<HtmlFormatContext> for biome_html_syntax::HtmlTagName {
type Format = FormatOwnedWithRule<
biome_html_syntax::HtmlTagName,
crate::html::auxiliary::tag_name::FormatHtmlTagName,
>;
fn into_format(self) -> Self::Format {
FormatOwnedWithRule::new(
self,
crate::html::auxiliary::tag_name::FormatHtmlTagName::default(),
)
}
}
impl AsFormat<HtmlFormatContext> for biome_html_syntax::HtmlAttributeList {
type Format<'a> = FormatRefWithRule<
'a,
Expand Down
12 changes: 12 additions & 0 deletions crates/biome_html_formatter/src/html/auxiliary/attribute_name.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
use crate::prelude::*;
use biome_formatter::write;
use biome_html_syntax::{HtmlAttributeName, HtmlAttributeNameFields};
#[derive(Debug, Clone, Default)]
pub(crate) struct FormatHtmlAttributeName;
impl FormatNodeRule<HtmlAttributeName> for FormatHtmlAttributeName {
fn fmt_fields(&self, node: &HtmlAttributeName, f: &mut HtmlFormatter) -> FormatResult<()> {
let HtmlAttributeNameFields { value_token } = node.as_fields();

write![f, [value_token.format()]]
}
}
3 changes: 2 additions & 1 deletion crates/biome_html_formatter/src/html/auxiliary/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

pub(crate) mod attribute;
pub(crate) mod attribute_initializer_clause;
pub(crate) mod attribute_name;
pub(crate) mod cdata_section;
pub(crate) mod closing_element;
pub(crate) mod comment;
pub(crate) mod content;
pub(crate) mod directive;
pub(crate) mod element;
pub(crate) mod name;
pub(crate) mod opening_element;
pub(crate) mod root;
pub(crate) mod self_closing_element;
pub(crate) mod string;
pub(crate) mod tag_name;
12 changes: 0 additions & 12 deletions crates/biome_html_formatter/src/html/auxiliary/name.rs

This file was deleted.

12 changes: 12 additions & 0 deletions crates/biome_html_formatter/src/html/auxiliary/tag_name.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
use crate::prelude::*;
use biome_formatter::write;
use biome_html_syntax::{HtmlTagName, HtmlTagNameFields};
#[derive(Debug, Clone, Default)]
pub(crate) struct FormatHtmlTagName;
impl FormatNodeRule<HtmlTagName> for FormatHtmlTagName {
fn fmt_fields(&self, node: &HtmlTagName, f: &mut HtmlFormatter) -> FormatResult<()> {
let HtmlTagNameFields { value_token } = node.as_fields();

write![f, [value_token.format()]]
}
}
Loading
Loading