@@ -276,7 +276,7 @@ defmodule Code.Formatter do
276276 end
277277
278278 defp quoted_to_algebra ( { var , _meta , var_context } , _context , state ) when is_atom ( var_context ) do
279- { var |> Atom . to_string ( ) |> string ( ) |> color ( :variable , state . inspect_opts ) , state }
279+ { var |> Atom . to_string ( ) |> string ( ) |> color_doc ( :variable , state . inspect_opts ) , state }
280280 end
281281
282282 defp quoted_to_algebra ( { :<<>> , meta , entries } , _context , state ) do
@@ -407,15 +407,15 @@ defmodule Code.Formatter do
407407 { @ double_heredoc
408408 |> concat ( string )
409409 |> concat ( @ double_heredoc )
410- |> color ( :string , state . inspect_opts )
410+ |> color_doc ( :string , state . inspect_opts )
411411 |> force_unfit ( ) , state }
412412 else
413413 string = escape_string ( string , @ double_quote )
414414
415415 { @ double_quote
416416 |> concat ( string )
417417 |> concat ( @ double_quote )
418- |> color ( :string , state . inspect_opts ) , state }
418+ |> color_doc ( :string , state . inspect_opts ) , state }
419419 end
420420 end
421421
@@ -447,7 +447,7 @@ defmodule Code.Formatter do
447447 end
448448
449449 defp quoted_to_algebra ( { :__block__ , _meta , [ ] } , _context , state ) do
450- { color ( "nil" , nil , state . inspect_opts ) , state }
450+ { color_doc ( "nil" , nil , state . inspect_opts ) , state }
451451 end
452452
453453 defp quoted_to_algebra ( { :__block__ , meta , args } = block , _context , state ) when is_list ( args ) do
@@ -464,7 +464,7 @@ defmodule Code.Formatter do
464464 end
465465
466466 { Enum . reduce ( tail , doc , & concat ( & 2 , "." <> Atom . to_string ( & 1 ) ) )
467- |> color ( :atom , state . inspect_opts ) , state }
467+ |> color_doc ( :atom , state . inspect_opts ) , state }
468468 end
469469
470470 # &1
@@ -589,8 +589,10 @@ defmodule Code.Formatter do
589589 [ ?" , atom |> Atom . to_string ( ) |> String . replace ( "\" " , "\\ \" " ) , ?" , ?: ]
590590 end
591591
592- { iodata |> IO . iodata_to_binary ( ) |> string ( ) |> color ( :atom , state . inspect_opts ) ,
593- state }
592+ { iodata
593+ |> IO . iodata_to_binary ( )
594+ |> string ( )
595+ |> color_doc ( :atom , state . inspect_opts ) , state }
594596
595597 { { :. , _ , [ :erlang , :binary_to_atom ] } , _ , [ { :<<>> , _ , entries } , :utf8 ] } ->
596598 interpolation_to_algebra ( entries , @ double_quote , state , "\" " , "\" :" )
@@ -688,7 +690,7 @@ defmodule Code.Formatter do
688690 Atom . to_string ( op )
689691 end
690692
691- { color ( op_string , :operator , state . inspect_opts ) |> concat ( doc ) , state }
693+ { color_doc ( op_string , :operator , state . inspect_opts ) |> concat ( doc ) , state }
692694 end
693695
694696 defp maybe_binary_op_to_algebra ( fun , meta , args , context , state ) do
@@ -794,11 +796,11 @@ defmodule Code.Formatter do
794796 doc =
795797 cond do
796798 op in @ no_space_binary_operators ->
797- op_doc = color ( op_string , :operator , state . inspect_opts )
799+ op_doc = color_doc ( op_string , :operator , state . inspect_opts )
798800 concat ( concat ( group ( left ) , op_doc ) , group ( right ) )
799801
800802 op in @ no_newline_binary_operators ->
801- op_doc = color ( " " <> op_string <> " " , :operator , state . inspect_opts )
803+ op_doc = color_doc ( " " <> op_string <> " " , :operator , state . inspect_opts )
802804 concat ( concat ( group ( left ) , op_doc ) , group ( right ) )
803805
804806 true ->
@@ -808,7 +810,7 @@ defmodule Code.Formatter do
808810 op in @ next_break_fits_operators and next_break_fits? ( right_arg , state ) and not eol?
809811
810812 with_next_break_fits ( next_break_fits? , right , fn right ->
811- op_doc = color ( " " <> op_string , :operator , state . inspect_opts )
813+ op_doc = color_doc ( " " <> op_string , :operator , state . inspect_opts )
812814 right = nest ( glue ( op_doc , group ( right ) ) , nesting , :break )
813815 right = if eol? , do: force_unfit ( right ) , else: right
814816 concat ( group ( left ) , group ( right ) )
@@ -1055,7 +1057,7 @@ defmodule Code.Formatter do
10551057 { target_doc , state } = remote_target_to_algebra ( target , state )
10561058
10571059 fun_doc =
1058- Macro . inspect_atom ( :remote_call , fun ) |> string ( ) |> color ( :call , state . inspect_opts )
1060+ Macro . inspect_atom ( :remote_call , fun ) |> string ( ) |> color_doc ( :call , state . inspect_opts )
10591061
10601062 remote_doc = target_doc |> concat ( "." ) |> concat ( fun_doc )
10611063
@@ -1123,7 +1125,7 @@ defmodule Code.Formatter do
11231125 fun
11241126 |> Atom . to_string ( )
11251127 |> string ( )
1126- |> color ( :call , state . inspect_opts )
1128+ |> color_doc ( :call , state . inspect_opts )
11271129 |> concat ( call_doc )
11281130
11291131 doc = if wrap_in_parens? , do: wrap_in_parens ( doc ) , else: doc
@@ -1564,8 +1566,8 @@ defmodule Code.Formatter do
15641566 { args_doc , _join , state } =
15651567 args_to_algebra_with_comments ( args , meta , false , :none , join , state , fun )
15661568
1567- left_bracket = color ( "[" , :list , state . inspect_opts )
1568- right_bracket = color ( "]" , :list , state . inspect_opts )
1569+ left_bracket = color_doc ( "[" , :list , state . inspect_opts )
1570+ right_bracket = color_doc ( "]" , :list , state . inspect_opts )
15691571
15701572 { surround ( left_bracket , args_doc , right_bracket ) , state }
15711573 end
@@ -1597,8 +1599,8 @@ defmodule Code.Formatter do
15971599 end
15981600
15991601 defp do_map_to_algebra ( name_doc , args_doc , state ) do
1600- name_doc = "%" |> concat ( name_doc ) |> concat ( "{" ) |> color ( :map , state . inspect_opts )
1601- { surround ( name_doc , args_doc , color ( "}" , :map , state . inspect_opts ) ) , state }
1602+ name_doc = "%" |> concat ( name_doc ) |> concat ( "{" ) |> color_doc ( :map , state . inspect_opts )
1603+ { surround ( name_doc , args_doc , color_doc ( "}" , :map , state . inspect_opts ) ) , state }
16021604 end
16031605
16041606 defp tuple_to_algebra ( meta , args , join , state ) do
@@ -1608,8 +1610,8 @@ defmodule Code.Formatter do
16081610 { args_doc , join , state } =
16091611 args_to_algebra_with_comments ( args , meta , false , :none , join , state , fun )
16101612
1611- left_bracket = color ( "{" , :tuple , state . inspect_opts )
1612- right_bracket = color ( "}" , :tuple , state . inspect_opts )
1613+ left_bracket = color_doc ( "{" , :tuple , state . inspect_opts )
1614+ right_bracket = color_doc ( "}" , :tuple , state . inspect_opts )
16131615
16141616 if join == :flex_break do
16151617 { left_bracket |> concat ( args_doc ) |> nest ( 1 ) |> concat ( right_bracket ) |> group ( ) , state }
@@ -1619,11 +1621,11 @@ defmodule Code.Formatter do
16191621 end
16201622
16211623 defp atom_to_algebra ( atom , _ , inspect_opts ) when atom in [ true , false ] do
1622- Atom . to_string ( atom ) |> color ( :boolean , inspect_opts )
1624+ Atom . to_string ( atom ) |> color_doc ( :boolean , inspect_opts )
16231625 end
16241626
16251627 defp atom_to_algebra ( nil , _ , inspect_opts ) do
1626- Atom . to_string ( nil ) |> color ( nil , inspect_opts )
1628+ Atom . to_string ( nil ) |> color_doc ( nil , inspect_opts )
16271629 end
16281630
16291631 defp atom_to_algebra ( :\\ , meta , inspect_opts ) do
@@ -1636,7 +1638,7 @@ defmodule Code.Formatter do
16361638 _ -> ":\\ \\ "
16371639 end
16381640
1639- string ( string ) |> color ( :atom , inspect_opts )
1641+ string ( string ) |> color_doc ( :atom , inspect_opts )
16401642 end
16411643
16421644 defp atom_to_algebra ( atom , _ , inspect_opts ) do
@@ -1649,7 +1651,7 @@ defmodule Code.Formatter do
16491651 [ ?: , ?" , String . replace ( string , "\" " , "\\ \" " ) , ?" ]
16501652 end
16511653
1652- iodata |> IO . iodata_to_binary ( ) |> string ( ) |> color ( :atom , inspect_opts )
1654+ iodata |> IO . iodata_to_binary ( ) |> string ( ) |> color_doc ( :atom , inspect_opts )
16531655 end
16541656
16551657 defp integer_to_algebra ( text , inspect_otps ) do
@@ -1666,15 +1668,15 @@ defmodule Code.Formatter do
16661668 decimal ->
16671669 insert_underscores ( decimal )
16681670 end
1669- |> color ( :number , inspect_otps )
1671+ |> color_doc ( :number , inspect_otps )
16701672 end
16711673
16721674 defp float_to_algebra ( text , inspect_otps ) do
16731675 [ int_part , decimal_part ] = :binary . split ( text , "." )
16741676 decimal_part = String . downcase ( decimal_part )
16751677
16761678 string = insert_underscores ( int_part ) <> "." <> decimal_part
1677- color ( string , :number , inspect_otps )
1679+ color_doc ( string , :number , inspect_otps )
16781680 end
16791681
16801682 defp insert_underscores ( "-" <> digits ) do
0 commit comments