-
-
Notifications
You must be signed in to change notification settings - Fork 715
refactor(format): use specialised tokens #7052
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
Conversation
|
4a9f3fa
to
d161316
Compare
CodSpeed Performance ReportMerging #7052 will not alter performanceComparing Summary
Footnotes |
d161316
to
48e43b3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While this is good, I think the massive diff could be avoidable. See below.
crates/biome_html_formatter/src/html/auxiliary/self_closing_element.rs
Outdated
Show resolved
Hide resolved
48e43b3
to
c662a38
Compare
c662a38
to
7676748
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! The contributing docs for the formatter will likely need to be updated too. Not going to block on that for this PR.
Summary
This PR refactors how the formatter formats trivias. Up until now, all sorts of trivia were formatted using generic functions such as:
format_replaced
,format_removed
,format_skipped_token_trivia
, etc.These functions, however, have a shared logic that can't be overridden by specialised formatters.
In this PR, we introduce a trait called
FormatToken
, which exposes functions such asformat_replaced
and more. Those functions, now, must be implemented within the language formatters, which means thatbiome_formatter
no longer knows how to do that.This refactor has some small repercussions on the separated lists, where now we need to pass generic functions
on_skipped
andon_removed
, because the generic formatter doesn't know how to print their trivia anymore.With this change, we can implement a specialised version of
fmt_skipped
that doesn't rely on the nestle logic: #5356Test Plan
The current CI should stay all green
Docs