Skip to content

Commit

Permalink
elbrujohalcon.otp_formatter.update- Get all formatters to work on OTP26
Browse files Browse the repository at this point in the history
  • Loading branch information
elbrujohalcon committed Oct 24, 2024
1 parent 8ffc18b commit 070fccd
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/erlang.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:

strategy:
matrix:
otp: ['25']
otp: ['26']
rebar: ['3.24']

steps:
Expand Down
3 changes: 2 additions & 1 deletion rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
{rebar3_sheldon, "~> 0.4.3"},
{rebar3_ex_doc, "~> 0.2.24"}]}.

{dialyzer, [{warnings, [no_return, unmatched_returns, error_handling, underspecs]}]}.
{dialyzer,
[{warnings, [no_unknown, no_return, unmatched_returns, error_handling, underspecs]}]}.

{edoc_opts, [{todo, true}, {overview, "priv/overview.edoc"}]}.

Expand Down
11 changes: 11 additions & 0 deletions src/formatters/default_formatter.erl
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,11 @@ lay_no_comments(Node, Ctxt) ->
prettypr:beside(
prettypr:text("<= "), D2)],
Ctxt1#ctxt.break_indent);
map_generator ->
Ctxt1 = reset_prec(Ctxt),
D1 = lay(erl_syntax:map_generator_pattern(Node), Ctxt1),
D2 = lay(erl_syntax:map_generator_body(Node), Ctxt1),
prettypr:par([D1, prettypr:beside(prettypr:text("<- "), D2)], Ctxt1#ctxt.break_indent);
implicit_fun ->
D = lay(erl_syntax:implicit_fun_name(Node), reset_prec(Ctxt)),
prettypr:beside(lay_text_float("fun "), D);
Expand All @@ -621,6 +626,12 @@ lay_no_comments(Node, Ctxt) ->
D2 = lay_items(erl_syntax:binary_comp_body(Node), Ctxt1, fun lay/2),
D3 = prettypr:beside(lay_text_float("|| "), prettypr:beside(D2, lay_text_float(" >>"))),
prettypr:beside(lay_text_float("<< "), prettypr:par([D1, D3]));
map_comp ->
Ctxt1 = reset_prec(Ctxt),
D1 = lay(erl_syntax:map_comp_template(Node), Ctxt1),
D2 = lay_items(erl_syntax:map_comp_body(Node), Ctxt1, fun lay/2),
D3 = prettypr:beside(lay_text_float("|| "), prettypr:beside(D2, lay_text_float("}"))),
prettypr:beside(lay_text_float("#{"),prettypr:par([D1, D3]));
macro ->
%% This is formatted similar to a normal function call or a variable
N = macro_name(Node, variable),
Expand Down
2 changes: 1 addition & 1 deletion test_app/after/src/brackets.erl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-module(brackets).

-format #{inline_items => all, paper => 50}.
-format #{paper => 50, inline_items => all}.

-compile(export_all).

Expand Down
2 changes: 1 addition & 1 deletion test_app/after/src/inline_items/inline_items_when_over.erl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
%% per line if they're larger than 5 elements.
-module(inline_items_when_over).

-format #{inline_items => {when_over, 5}, paper => 80}.
-format #{paper => 80, inline_items => {when_over, 5}}.

-export([short_tuple/0, short_list/0, short_fun/0]).
-export([short_bin/0, short_guard/1, short_lc/0]).
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-module(inline_items_when_under).

-format #{inline_items => {when_under, 5}, paper => 80}.
-format #{paper => 80, inline_items => {when_under, 5}}.

-export([short_tuple/0, short_list/0, short_fun/0]).
-export([short_bin/0, short_guard/1, short_lc/0]).
Expand Down
2 changes: 1 addition & 1 deletion test_app/after/src/inline_items/inline_no_items.erl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
%% per line if they're large.
-module(inline_no_items).

-format #{inline_items => none, paper => 80}.
-format #{paper => 80, inline_items => none}.

-export([short_tuple/0, short_list/0, short_fun/0]).
-export([short_bin/0, short_guard/1, short_lc/0]).
Expand Down
6 changes: 3 additions & 3 deletions test_app/after/src/paper_and_ribbon/indent_18.erl
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
-module(indent_18).

-format #{break_indent => 1,
inline_clause_bodies => true,
-format #{sub_indent => 8,
break_indent => 1,
paper => 50,
sub_indent => 8}.
inline_clause_bodies => true}.

-record(record,
{fields =
Expand Down
6 changes: 3 additions & 3 deletions test_app/after/src/paper_and_ribbon/indent_81.erl
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
-module(indent_81).

-format #{break_indent => 8,
paper => 50,
sub_indent => 1}.
-format #{sub_indent => 1,
break_indent => 8,
paper => 50}.
-format #{inline_clause_bodies => true}.

-record(record,
Expand Down

0 comments on commit 070fccd

Please sign in to comment.