This repository has been archived by the owner on Aug 31, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(rome_js_formatter): Move node formatting into its own trait
Today, the formatting that must happen for each JS node happens inside `Formatter.format_syntax_node` and the `formatter_traits`. This PR moves the common logic applied by all nodes and tokens into the `ToFormatElement` implementation and renames it to `Format`. * Rename `ToFormatElement` to `Format` and `to_format_element` to `format` * Implement `Format` for `JsSyntaxToken`. CSS, JSON etc. can implement their own generic token formatting logic * Introduce a new `FormatNode` trait (language specific) that implements the formatting of a node and calls into `format_fields` that is implemented for each field. * Make the `FormatterTraits` node and language independent. Rename to `FormatTraits`. `Format`, `FormatterTraits`, `FormatResult`, and `FormatError` are now all language independent. However, some still depend on the `Formatter`. The next step is to move many of the `Formatter`'s helper function out of the Formatter so that it becomes language independent.
- Loading branch information