refactor(format): use specialised tokens#7052
Conversation
|
4a9f3fa to
d161316
Compare
CodSpeed Performance ReportMerging #7052 will not alter performanceComparing Summary
Footnotes |
d161316 to
48e43b3
Compare
dyc3
left a comment
There was a problem hiding this comment.
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
dyc3
left a comment
There was a problem hiding this comment.
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_replacedand more. Those functions, now, must be implemented within the language formatters, which means thatbiome_formatterno 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_skippedandon_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_skippedthat doesn't rely on the nestle logic: #5356Test Plan
The current CI should stay all green
Docs