marcandre / freedom_formatter

A fork of Elixir's code formatter, with added freedom.
Apache License 2.0
24 stars 3 forks source link

Support Elixir 1.14 #4

Closed ryvasquez closed 2 years ago

ryvasquez commented 2 years ago

Hi team!

1st of all thankyou very much for this formatter. Since the Elixir 1.14 is release, when trying to compile and format the formatter is throwing the following error

** (UndefinedFunctionError) function Code.Identifier.classify/1 is undefined or private
    (elixir 1.14.0) Code.Identifier.classify(:live_component)
    (freedom_formatter 2.0.0) lib/freedom_formatter/formatter.ex:1531: FreedomFormatter.Formatter.atom_to_algebra/1
    (freedom_formatter 2.0.0) lib/freedom_formatter/formatter.ex:385: FreedomFormatter.Formatter.quoted_to_algebra/3
    (freedom_formatter 2.0.0) lib/freedom_formatter/formatter.ex:1628: anonymous fn/6 in FreedomFormatter.Formatter.args_to_algebra_with_comments/7
    (freedom_formatter 2.0.0) lib/freedom_formatter/formatter.ex:1952: FreedomFormatter.Formatter.each_quoted_to_algebra_with_comments/6
    (freedom_formatter 2.0.0) lib/freedom_formatter/formatter.ex:1930: FreedomFormatter.Formatter.quoted_to_algebra_with_comments/6
    (freedom_formatter 2.0.0) lib/freedom_formatter/formatter.ex:1674: FreedomFormatter.Formatter.args_to_algebra_with_comments/7
    (freedom_formatter 2.0.0) lib/freedom_formatter/formatter.ex:1142: FreedomFormatter.Formatter.call_args_to_algebra_no_blocks/6
    (freedom_formatter 2.0.0) lib/freedom_formatter/formatter.ex:1075: FreedomFormatter.Formatter.call_args_to_algebra/6
    (freedom_formatter 2.0.0) lib/freedom_formatter/formatter.ex:1023: FreedomFormatter.Formatter.local_to_algebra/5
    (freedom_formatter 2.0.0) lib/freedom_formatter/formatter.ex:551: anonymous fn/3 in FreedomFormatter.Formatter.block_args_to_algebra/4
    (freedom_formatter 2.0.0) lib/freedom_formatter/formatter.ex:1952: FreedomFormatter.Formatter.each_quoted_to_algebra_with_comments/6
    (freedom_formatter 2.0.0) lib/freedom_formatter/formatter.ex:1930: FreedomFormatter.Formatter.quoted_to_algebra_with_comments/6
    (freedom_formatter 2.0.0) lib/freedom_formatter/formatter.ex:556: FreedomFormatter.Formatter.block_args_to_algebra/4
    (freedom_formatter 2.0.0) lib/freedom_formatter/formatter.ex:1850: FreedomFormatter.Formatter.clauses_to_algebra/4
    (freedom_formatter 2.0.0) lib/freedom_formatter/formatter.ex:1256: FreedomFormatter.Formatter.do_end_block_to_algebra/5
    (freedom_formatter 2.0.0) lib/freedom_formatter/formatter.ex:1234: FreedomFormatter.Formatter.do_end_blocks_to_algebra/2
    (freedom_formatter 2.0.0) lib/freedom_formatter/formatter.ex:1066: FreedomFormatter.Formatter.call_args_to_algebra/6
    (freedom_formatter 2.0.0) lib/freedom_formatter/formatter.ex:1023: FreedomFormatter.Formatter.local_to_algebra/5
    (freedom_formatter 2.0.0) lib/freedom_formatter/formatter.ex:551: anonymous fn/3 in FreedomFormatter.Formatter.block_args_to_algebra/4
marcandre commented 2 years ago

Hi! Sorry I missed the notification, and thanks for creating the PR, especially since it's not obvious how to update this project.

What I do is I rewrite history, and the commit "Import stock Elixir formatter" is a simple copy from the updated source code, and then the git rebase will apply the subsequent patches for the new features.

Anyways, I've added release 2.1.0 for Elixir 1.14. It also adds a new option local_pipe_with_parens which will format foo |> bar to foo |> bar() (check the README). Enjoy, let me know if you run into issues.