[Proposal] Optional callback quoted_to_algebra/2 in Mix.Tasks.Format

30 views
Skip to first unread message

esurk....@gmail.com

unread,
Feb 4, 2023, 8:42:52 AM2/4/23
to elixir-lang-core

Hi Everyone.

I would like to suggest to extend the behavior `Mix.Tasks.Format` with the optional callback `quote_to_string/2`. This would have the advantage that you could format a changed AST with a formatter plugin.

I would need something like this in my `rewrite` project. The `rewrite` tool changes the AST of some Elixir code with the help of the great `sourceror` lib. Afterwards I need to format this AST back to code. To support the formatter plugin `FreedomFormatter` I need the `quoted_to_algebra` function form `FreedomFormatter`. For now I have created a workaround for that. With the optional callback I could ask the maintainer of `FreedomFormatter` to implement the callback and in `rewrite` I could check whether the behaviour implements the function.

BR, Marcus

Reply all
Reply to author
Forward
0 new messages