diff --git a/.github/workflows/erlang.yml b/.github/workflows/erlang.yml index 91ffcd5..e4dd9d5 100644 --- a/.github/workflows/erlang.yml +++ b/.github/workflows/erlang.yml @@ -13,23 +13,23 @@ jobs: strategy: matrix: - otp: ['24.3', '25.2.1'] - rebar: ['3.20.0'] + otp: ['25', '26'] + rebar: ['3.24'] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - uses: erlef/setup-beam@v1 id: setup-beam with: otp-version: ${{matrix.otp}} rebar3-version: ${{matrix.rebar}} - name: Restore _build - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: _build key: _build-cache-for-os-${{runner.os}}-otp-${{steps.setup-beam.outputs.otp-version}}-rebar3-${{steps.setup-beam.outputs.rebar3-version}}-hash-${{hashFiles('rebar.lock')}} - name: Restore rebar3's cache - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: ~/.cache/rebar3 key: rebar3-cache-for-os-${{runner.os}}-otp-${{steps.setup-beam.outputs.otp-version}}-rebar3-${{steps.setup-beam.outputs.rebar3-version}}-hash-${{hashFiles('rebar.lock')}} diff --git a/nextroll.dict b/nextroll.dict index 580276f..af41619 100644 --- a/nextroll.dict +++ b/nextroll.dict @@ -35,6 +35,8 @@ lay_clauses lay_items old-reliable otp25 +otp26 +otp27 paragraph-format per-file plugin diff --git a/rebar.config b/rebar.config index 80a70ad..7f77978 100644 --- a/rebar.config +++ b/rebar.config @@ -1,8 +1,8 @@ {erl_opts, [warn_unused_import, warn_export_vars, verbose, report, debug_info]}. -{minimum_otp_vsn, "24"}. +{minimum_otp_vsn, "25"}. -{deps, [{katana_code, "~> 2.1.0"}]}. +{deps, [{katana_code, "~> 2.2.0"}]}. {ex_doc, [{source_url, <<"https://github.com/AdRoll/rebar3_format">>}, @@ -13,12 +13,13 @@ {project_plugins, [{rebar3_hex, "~> 7.0.8"}, - {rebar3_hank, "~> 1.4.0"}, - {rebar3_lint, "~> 3.2.5"}, + {rebar3_hank, "~> 1.4.1"}, + {rebar3_lint, "~> 3.2.6"}, {rebar3_sheldon, "~> 0.4.3"}, - {rebar3_ex_doc, "~> 0.2.23"}]}. + {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"}]}. diff --git a/rebar.lock b/rebar.lock index 31c3009..6d13613 100644 --- a/rebar.lock +++ b/rebar.lock @@ -1,8 +1,8 @@ {"1.2.0", -[{<<"katana_code">>,{pkg,<<"katana_code">>,<<"2.1.0">>},0}]}. +[{<<"katana_code">>,{pkg,<<"katana_code">>,<<"2.2.0">>},0}]}. [ {pkg_hash,[ - {<<"katana_code">>, <<"0C42BDCD7E59995876AED9F678CF62E3D12EF42E0FBB2190556E64BFEBDD15C6">>}]}, + {<<"katana_code">>, <<"B67EAA70022702AFEC2803E33C89ABE3D817197E7A16246614FED42E03AA8753">>}]}, {pkg_hash_ext,[ - {<<"katana_code">>, <<"AE3BBACA187511588F69695A9FF22251CB2CC672FDCCC180289779BDD25175EF">>}]} + {<<"katana_code">>, <<"A01F9FDBA838478FDFDE183A324FA12ECE9BA127935065395D01427FC5110CBB">>}]} ]. diff --git a/src/formatters/default_formatter.erl b/src/formatters/default_formatter.erl index ba37528..9ca4c67 100644 --- a/src/formatters/default_formatter.erl +++ b/src/formatters/default_formatter.erl @@ -594,18 +594,17 @@ lay_no_comments(Node, Ctxt) -> Ctxt1 = reset_prec(Ctxt), D1 = lay(erl_syntax:generator_pattern(Node), Ctxt1), D2 = lay(erl_syntax:generator_body(Node), Ctxt1), - prettypr:par([D1, - prettypr:beside( - prettypr:text("<- "), D2)], - Ctxt1#ctxt.break_indent); + lay_generator(D1, D2, "<- ", Ctxt1); binary_generator -> Ctxt1 = reset_prec(Ctxt), D1 = lay(erl_syntax:binary_generator_pattern(Node), Ctxt1), D2 = lay(erl_syntax:binary_generator_body(Node), Ctxt1), - prettypr:par([D1, - prettypr:beside( - prettypr:text("<= "), D2)], - Ctxt1#ctxt.break_indent); + lay_generator(D1, D2, "<= ", Ctxt1); + map_generator -> + Ctxt1 = reset_prec(Ctxt), + D1 = lay(erl_syntax:map_generator_pattern(Node), Ctxt1), + D2 = lay(erl_syntax:map_generator_body(Node), Ctxt1), + lay_generator(D1, D2, "<- ", Ctxt1); implicit_fun -> D = lay(erl_syntax:implicit_fun_name(Node), reset_prec(Ctxt)), prettypr:beside(lay_text_float("fun "), D); @@ -621,6 +620,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), @@ -1084,6 +1089,12 @@ maybe_convert_to_qualifier(Node, #ctxt{force_arity_qualifiers = true}) -> Node end. +lay_generator(D1, D2, Connector, Ctxt) -> + prettypr:par([D1, + prettypr:beside( + prettypr:text(Connector), D2)], + Ctxt#ctxt.break_indent). + lay_nested_infix_expr(Node, #ctxt{parenthesize_infix_operations = false} = Ctxt) -> lay(Node, Ctxt); lay_nested_infix_expr(Node, #ctxt{parenthesize_infix_operations = true} = Ctxt) -> diff --git a/src/formatters/otp_formatter.erl b/src/formatters/otp_formatter.erl index 2302e8d..56e1bd5 100644 --- a/src/formatters/otp_formatter.erl +++ b/src/formatters/otp_formatter.erl @@ -664,6 +664,11 @@ lay_no_comments(Node, Ctxt) -> D1 = lay(erl_syntax:binary_generator_pattern(Node), Ctxt1), D2 = lay(erl_syntax:binary_generator_body(Node), Ctxt1), par([D1, beside(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), + par([D1, beside(text("<- "), D2)], Ctxt1#ctxt.break_indent); implicit_fun -> D = lay(erl_syntax:implicit_fun_name(Node), reset_prec(Ctxt)), beside(lay_text_float("fun "), D); @@ -679,6 +684,12 @@ lay_no_comments(Node, Ctxt) -> D2 = par(seq(erl_syntax:binary_comp_body(Node), lay_text_float(","), Ctxt1, fun lay/2)), beside(lay_text_float("<< "), par([D1, beside(lay_text_float(" || "), beside(D2, lay_text_float(" >>")))])); + map_comp -> + Ctxt1 = set_prec(Ctxt, max_prec()), + D1 = lay(erl_syntax:map_comp_template(Node), Ctxt1), + D2 = par(seq(erl_syntax:map_comp_body(Node), lay_text_float(","), Ctxt1, fun lay/2)), + beside(lay_text_float("#{"), + par([D1, beside(lay_text_float("|| "), beside(D2, lay_text_float("}")))])); macro -> %% This is formatted similar to a normal function call, but %% prefixed with a "?". diff --git a/test/otp_formatter_SUITE.erl b/test/otp_formatter_SUITE.erl index 55e9f4f..8f918aa 100644 --- a/test/otp_formatter_SUITE.erl +++ b/test/otp_formatter_SUITE.erl @@ -17,14 +17,24 @@ test_app(_Config) -> case string:to_integer( erlang:system_info(otp_release)) of - {N, _} when N >= 25 -> + {N, _} when N >= 26 -> {ignore, - ["src/*_ignore.erl", + ["src/strings/non_heredoc.erl", %% newlines in strings are treated differently since OTP26 + "src/*_ignore.erl", "src/comments.erl", "src/ignored_file_config.erl", "src/dodge_macros.erl", "src/macros_in_specs.erl", "src/receive_after.erl"]}; + {25, _} -> + {ignore, + ["src/*_ignore.erl", + "src/comments.erl", + "src/ignored_file_config.erl", + "src/dodge_macros.erl", + "src/macros_in_specs.erl", + "src/receive_after.erl", + "src/otp26.erl"]}; _ -> {ignore, ["src/*_ignore.erl", @@ -33,6 +43,7 @@ test_app(_Config) -> "src/dodge_macros.erl", "src/macros_in_specs.erl", "src/receive_after.erl", + "src/otp26.erl", "src/otp25.erl"]} end, State2 = rebar_state:set(State1, format, [Files, Formatter, IgnoredFiles]), diff --git a/test/test_app_SUITE.erl b/test/test_app_SUITE.erl index 0917321..533ceca 100644 --- a/test/test_app_SUITE.erl +++ b/test/test_app_SUITE.erl @@ -50,10 +50,20 @@ init_test_app() -> case string:to_integer( erlang:system_info(otp_release)) of - {N, []} when N >= 25 -> - {ignore, ["src/*_ignore.erl", "src/ignored_file_config.erl"]}; + {N, _} when N >= 26 -> + %% newlines in strings are treated differently since OTP26 + {ignore, + ["src/strings/non_heredoc.erl", + "src/*_ignore.erl", + "src/ignored_file_config.erl"]}; + {25, _} -> + {ignore, ["src/*_ignore.erl", "src/ignored_file_config.erl", "src/otp26.erl"]}; _ -> - {ignore, ["src/*_ignore.erl", "src/ignored_file_config.erl", "src/otp25.erl"]} + {ignore, + ["src/*_ignore.erl", + "src/ignored_file_config.erl", + "src/otp26.erl", + "src/otp25.erl"]} end, rebar_state:set(State1, format, [Files, IgnoredFiles]). diff --git a/test_app/after/src/brackets.erl b/test_app/after/src/brackets.erl index 7c9a386..a130179 100644 --- a/test_app/after/src/brackets.erl +++ b/test_app/after/src/brackets.erl @@ -1,6 +1,7 @@ -module(brackets). --format #{inline_items => all, paper => 50}. +-format #{inline_items => all}. +-format #{paper => 50}. -compile(export_all). diff --git a/test_app/after/src/brackets_ignore.erl b/test_app/after/src/brackets_ignore.erl index 6b08080..6877fa0 100644 --- a/test_app/after/src/brackets_ignore.erl +++ b/test_app/after/src/brackets_ignore.erl @@ -1,7 +1,8 @@ %% This module should not be formatted since it's in the list of ignored modules -module(brackets_ignore). --format(#{paper => 50, inline_items => all}). +-format(#{paper => 50}). +-format(#{inline_items => all}). -compile(export_all). diff --git a/test_app/after/src/inline_items/inline_items_when_over.erl b/test_app/after/src/inline_items/inline_items_when_over.erl index c77e270..4ad7a16 100644 --- a/test_app/after/src/inline_items/inline_items_when_over.erl +++ b/test_app/after/src/inline_items/inline_items_when_over.erl @@ -3,7 +3,8 @@ %% 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}. +-format #{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]). diff --git a/test_app/after/src/inline_items/inline_items_when_under.erl b/test_app/after/src/inline_items/inline_items_when_under.erl index 55bc77c..d4d9fb4 100644 --- a/test_app/after/src/inline_items/inline_items_when_under.erl +++ b/test_app/after/src/inline_items/inline_items_when_under.erl @@ -1,6 +1,7 @@ -module(inline_items_when_under). --format #{inline_items => {when_under, 5}, paper => 80}. +-format #{paper => 80}. +-format #{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]). diff --git a/test_app/after/src/inline_items/inline_no_items.erl b/test_app/after/src/inline_items/inline_no_items.erl index 0ab7b30..a097236 100644 --- a/test_app/after/src/inline_items/inline_no_items.erl +++ b/test_app/after/src/inline_items/inline_no_items.erl @@ -3,7 +3,8 @@ %% per line if they're large. -module(inline_no_items). --format #{inline_items => none, paper => 80}. +-format #{inline_items => none}. +-format #{paper => 80}. -export([short_tuple/0, short_list/0, short_fun/0]). -export([short_bin/0, short_guard/1, short_lc/0]). diff --git a/test_app/after/src/inline_qualified_function_composition/function_composition_spaces.erl b/test_app/after/src/inline_qualified_function_composition/function_composition_spaces.erl index 753be77..3d54dbe 100644 --- a/test_app/after/src/inline_qualified_function_composition/function_composition_spaces.erl +++ b/test_app/after/src/inline_qualified_function_composition/function_composition_spaces.erl @@ -1,6 +1,7 @@ -module(function_composition_spaces). --format #{inline_qualified_function_composition => true, spaces_around_arguments => true}. +-format #{inline_qualified_function_composition => true}. +-format #{spaces_around_arguments => true}. -export([local_calls/3, external_calls/0]). diff --git a/test_app/after/src/matches.erl b/test_app/after/src/matches.erl index 4c11c7e..3723362 100644 --- a/test_app/after/src/matches.erl +++ b/test_app/after/src/matches.erl @@ -1,6 +1,7 @@ -compile(export_all). --format #{paper => 80, ribbon => 75}. +-format #{paper => 80}. +-format #{ribbon => 75}. matches() -> % Short diff --git a/test_app/after/src/otp26.erl b/test_app/after/src/otp26.erl new file mode 100644 index 0000000..1046753 --- /dev/null +++ b/test_app/after/src/otp26.erl @@ -0,0 +1,24 @@ +%% @doc New stuff introduced in OTP26. +-module(otp26). + +-export([map_comprehensions/3]). + +map_comprehensions(Map, List, Binary) -> + MapFromList = #{{k, Key} => {value, Value} || Key <- List, Value <- List}, + MapFromBinary = + #{{k, Key} => {value, Value} + || <> <- Binary, Key >= 8.24551123345, <> <- Binary}, + MapFromMap = + #{#{key => Key} => [value, Value, is_a_value] + || {k, Key} := {value, Value} <- MapFromList, is_integer(Key)}, + MapFromCombo = #{Key => binary_to_atom(Value) || Key <- List, <> <= Binary}, + ListFromMap = + [{Key, Value} + || {k, Key} := Value <- MapFromBinary, + with:one_filter(Key), + with:another_filter(Value) == <<"a good value">>], + BinaryFromMap = + << <> + || #{key := Key} := [value, Value | _] <- MapFromMap, is_binary(Value) >>, + NoGenerator = #{k => v || this:is_true()}, + #{MapFromCombo => ListFromMap, BinaryFromMap => NoGenerator}. diff --git a/test_app/after/src/paper_and_ribbon/indent_18.erl b/test_app/after/src/paper_and_ribbon/indent_18.erl index c342542..e2c62e1 100644 --- a/test_app/after/src/paper_and_ribbon/indent_18.erl +++ b/test_app/after/src/paper_and_ribbon/indent_18.erl @@ -1,9 +1,9 @@ -module(indent_18). --format #{break_indent => 1, - inline_clause_bodies => true, - paper => 50, - sub_indent => 8}. +-format #{break_indent => 1}. +-format #{inline_clause_bodies => true}. +-format #{paper => 50}. +-format #{sub_indent => 8}. -record(record, {fields = diff --git a/test_app/after/src/paper_and_ribbon/indent_81.erl b/test_app/after/src/paper_and_ribbon/indent_81.erl index 4b00c9d..fe9d3a7 100644 --- a/test_app/after/src/paper_and_ribbon/indent_81.erl +++ b/test_app/after/src/paper_and_ribbon/indent_81.erl @@ -1,8 +1,8 @@ -module(indent_81). --format #{break_indent => 8, - paper => 50, - sub_indent => 1}. +-format #{break_indent => 8}. +-format #{paper => 50}. +-format #{sub_indent => 1}. -format #{inline_clause_bodies => true}. -record(record, diff --git a/test_app/after/src/strings/non_heredoc.erl b/test_app/after/src/strings/non_heredoc.erl new file mode 100644 index 0000000..9de6ef5 --- /dev/null +++ b/test_app/after/src/strings/non_heredoc.erl @@ -0,0 +1,15 @@ +-module(strings). + +-export([heredoc/0]). + +-format #{inline_expressions => true}. + +heredoc() -> + {ok, + "" " +This is +a multiline +heredoc but there are +no multiline heredocs in Erlang :'( +" + ""}. diff --git a/test_app/after/src/strings/strings.erl b/test_app/after/src/strings/strings.erl index d08e8fd..027f81a 100644 --- a/test_app/after/src/strings/strings.erl +++ b/test_app/after/src/strings/strings.erl @@ -7,22 +7,12 @@ -attr({with, "a string"}). all() -> - heredoc(), superlong(), repeat(), multiple_calls(), characters(), multiline_with_spaces(). + superlong(), repeat(), multiple_calls(), characters(), multiline_with_spaces(). superlong() -> "This is a super super super super super super super super super super super super super super super super super super super super super super super super super super super super super long string!" "Shouldn't be truncated since truncate_strings => false by default". -heredoc() -> - {ok, - "" " -This is -a multiline -heredoc but there are -no multiline heredocs in Erlang :'( -" - ""}. - repeat() -> ["hello", "there", "hello", "there", "hello", "there" | repeat_more()]. diff --git a/test_app/src/brackets.erl b/test_app/src/brackets.erl index ff9a912..f78373e 100644 --- a/test_app/src/brackets.erl +++ b/test_app/src/brackets.erl @@ -1,6 +1,7 @@ -module(brackets). --format(#{paper => 50, inline_items => all}). +-format(#{inline_items => all}). +-format(#{paper => 50}). -compile(export_all). diff --git a/test_app/src/brackets_ignore.erl b/test_app/src/brackets_ignore.erl index 6b08080..6877fa0 100644 --- a/test_app/src/brackets_ignore.erl +++ b/test_app/src/brackets_ignore.erl @@ -1,7 +1,8 @@ %% This module should not be formatted since it's in the list of ignored modules -module(brackets_ignore). --format(#{paper => 50, inline_items => all}). +-format(#{paper => 50}). +-format(#{inline_items => all}). -compile(export_all). diff --git a/test_app/src/inline_items/inline_items_when_over.erl b/test_app/src/inline_items/inline_items_when_over.erl index bf9f5d7..a60ae84 100644 --- a/test_app/src/inline_items/inline_items_when_over.erl +++ b/test_app/src/inline_items/inline_items_when_over.erl @@ -3,7 +3,8 @@ %% per line if they're larger than 5 elements. -module inline_items_when_over. --format #{paper => 80, inline_items => {when_over, 5}}. +-format #{paper => 80}. +-format #{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]. @@ -106,4 +107,3 @@ exact() -> long() -> [these, items, should, be, inlined, they, are, more, than, 25, $., 'We', can, be, sure, about, that, because, we, added, a, very, long, number, 'of', items, to, this, list]. - diff --git a/test_app/src/inline_items/inline_items_when_under.erl b/test_app/src/inline_items/inline_items_when_under.erl index c3f3186..8443a8f 100644 --- a/test_app/src/inline_items/inline_items_when_under.erl +++ b/test_app/src/inline_items/inline_items_when_under.erl @@ -1,6 +1,7 @@ -module inline_items_when_under. --format #{paper => 80, inline_items => {when_under, 5}}. +-format #{paper => 80}. +-format #{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]. @@ -103,4 +104,3 @@ exact() -> long() -> [these, items, should, be, inlined, they, are, more, than, 25, $., 'We', can, be, sure, about, that, because, we, added, a, very, long, number, 'of', items, to, this, list]. - diff --git a/test_app/src/inline_items/inline_no_items.erl b/test_app/src/inline_items/inline_no_items.erl index 5195c4e..c8f135b 100644 --- a/test_app/src/inline_items/inline_no_items.erl +++ b/test_app/src/inline_items/inline_no_items.erl @@ -3,7 +3,8 @@ %% per line if they're large. -module inline_no_items. --format #{paper => 80, inline_items => none}. +-format #{inline_items => none}. +-format #{paper => 80}. -export [short_tuple/0, short_list/0, short_fun/0]. -export [short_bin/0, short_guard/1, short_lc/0]. @@ -106,4 +107,3 @@ exact() -> long() -> [these, items, should, be, inlined, they, are, more, than, 25, $., 'We', can, be, sure, about, that, because, we, added, a, very, long, number, 'of', items, to, this, list]. - diff --git a/test_app/src/inline_qualified_function_composition/function_composition_spaces.erl b/test_app/src/inline_qualified_function_composition/function_composition_spaces.erl index 108d977..6d969c1 100644 --- a/test_app/src/inline_qualified_function_composition/function_composition_spaces.erl +++ b/test_app/src/inline_qualified_function_composition/function_composition_spaces.erl @@ -1,6 +1,7 @@ -module(function_composition_spaces). --format #{spaces_around_arguments => true, inline_qualified_function_composition => true}. +-format #{inline_qualified_function_composition => true}. +-format #{spaces_around_arguments => true}. -export([local_calls/3, external_calls/0]). diff --git a/test_app/src/matches.erl b/test_app/src/matches.erl index f745eb9..2c336e8 100644 --- a/test_app/src/matches.erl +++ b/test_app/src/matches.erl @@ -1,6 +1,7 @@ -compile(export_all). --format #{paper => 80, ribbon => 75}. +-format #{paper => 80}. +-format #{ribbon => 75}. matches() -> % Short diff --git a/test_app/src/otp26.erl b/test_app/src/otp26.erl new file mode 100644 index 0000000..1046753 --- /dev/null +++ b/test_app/src/otp26.erl @@ -0,0 +1,24 @@ +%% @doc New stuff introduced in OTP26. +-module(otp26). + +-export([map_comprehensions/3]). + +map_comprehensions(Map, List, Binary) -> + MapFromList = #{{k, Key} => {value, Value} || Key <- List, Value <- List}, + MapFromBinary = + #{{k, Key} => {value, Value} + || <> <- Binary, Key >= 8.24551123345, <> <- Binary}, + MapFromMap = + #{#{key => Key} => [value, Value, is_a_value] + || {k, Key} := {value, Value} <- MapFromList, is_integer(Key)}, + MapFromCombo = #{Key => binary_to_atom(Value) || Key <- List, <> <= Binary}, + ListFromMap = + [{Key, Value} + || {k, Key} := Value <- MapFromBinary, + with:one_filter(Key), + with:another_filter(Value) == <<"a good value">>], + BinaryFromMap = + << <> + || #{key := Key} := [value, Value | _] <- MapFromMap, is_binary(Value) >>, + NoGenerator = #{k => v || this:is_true()}, + #{MapFromCombo => ListFromMap, BinaryFromMap => NoGenerator}. diff --git a/test_app/src/paper_and_ribbon/indent_18.erl b/test_app/src/paper_and_ribbon/indent_18.erl index fa528a8..421942a 100644 --- a/test_app/src/paper_and_ribbon/indent_18.erl +++ b/test_app/src/paper_and_ribbon/indent_18.erl @@ -1,9 +1,9 @@ -module(indent_18). --format(#{break_indent => 1, - sub_indent => 8, - paper => 50, - inline_clause_bodies => true}). +-format(#{break_indent => 1}). +-format(#{inline_clause_bodies => true}). +-format(#{paper => 50}). +-format(#{sub_indent => 8}). -record( record, {fields = should:be(indented_using:break_indent(1)), diff --git a/test_app/src/paper_and_ribbon/indent_81.erl b/test_app/src/paper_and_ribbon/indent_81.erl index ecf2a63..82a8048 100644 --- a/test_app/src/paper_and_ribbon/indent_81.erl +++ b/test_app/src/paper_and_ribbon/indent_81.erl @@ -1,6 +1,8 @@ -module(indent_81). --format(#{break_indent => 8, sub_indent => 1, paper => 50}). +-format(#{break_indent => 8}). +-format(#{paper => 50}). +-format(#{sub_indent => 1}). -format(#{inline_clause_bodies => true}). -record( diff --git a/test_app/src/strings/non_heredoc.erl b/test_app/src/strings/non_heredoc.erl new file mode 100644 index 0000000..9de6ef5 --- /dev/null +++ b/test_app/src/strings/non_heredoc.erl @@ -0,0 +1,15 @@ +-module(strings). + +-export([heredoc/0]). + +-format #{inline_expressions => true}. + +heredoc() -> + {ok, + "" " +This is +a multiline +heredoc but there are +no multiline heredocs in Erlang :'( +" + ""}. diff --git a/test_app/src/strings/strings.erl b/test_app/src/strings/strings.erl index 50e2347..87048ee 100644 --- a/test_app/src/strings/strings.erl +++ b/test_app/src/strings/strings.erl @@ -7,7 +7,6 @@ -attr({with, "a string"}). all() -> - heredoc(), superlong(), repeat(), multiple_calls(), @@ -19,14 +18,6 @@ superlong() -> "This is a super super super super super super super super super super super super super super super super super super super super super super super super super super super super super long string!" "Shouldn't be truncated since truncate_strings => false by default". -heredoc() -> -{ok, """ -This is -a multiline -heredoc but there are -no multiline heredocs in Erlang :'( -"""}. - repeat() -> ["hello", "there", "hello", "there",