feat(codegen,css_formatter): autogenerate property formattting boilerplate #1452
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
As we start to implement exact parsing for all of the properties, we're going to start having formatter files for each one (multiple actually. an
any
, aproperty
, and at least oneproperty_value
file to cover each added node.Each of the overall Property nodes will have exactly the same structure and get formatted exactly the same way:
It simply destructures the
name
,colon_token
, andvalue
fields, then formats them with a space between the colon and the value. Every property value will do this exactly. So why not put it in the code generation by default!We can detect that a property node is being generated by checking the language, node concept, and name, and then use this template rather than the
format_verbatim_node
one. This way adding a new property should only require devs to implement the value formatting. That could also be autogenerated most of the time, but I think it's best left as-is.If we decide to implement the general
CssKeyword
node for values, that'll also make it quite a bit easier to manage since most of the time there will only be one node type to format.Test Plan
I deleted one of the existing property formatter files, ran the codegen, and got the exact same output, so it works!