-module(roundabout@generate_route_to_path). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]). -define(FILEPATH, "src/roundabout/generate_route_to_path.gleam"). -export([get_branch_result/3, generate_route_to_path/2, generate_route_to_path_rec/2]). -if(?OTP_RELEASE >= 27). -define(MODULEDOC(Str), -moduledoc(Str)). -define(DOC(Str), -doc(Str)). -else. -define(MODULEDOC(Str), -compile([])). -define(DOC(Str), -compile([])). -endif. -file("src/roundabout/generate_route_to_path.gleam", 119). ?DOC(false). -spec get_branch_result( boolean(), list(roundabout@node:info()), roundabout@node:node_() ) -> glam@doc:document(). get_branch_result(Is_root, Ancestors, Node) -> Has_segments = not gleam@list:is_empty( erlang:element(3, erlang:element(2, Node)) ), Segments = begin _pipe = gleam@list:map( erlang:element(3, erlang:element(2, Node)), fun(Seg) -> case Seg of {seg_lit, Value} -> glam@doc:from_string( <<<<(<<"\""/utf8>>)/binary, (roundabout@constant:value(Value))/binary>>/binary, (<<"\""/utf8>>)/binary>> ); {seg_param, Param} -> Name = roundabout@parameter:name(Param), case roundabout@parameter:kind(Param) of str -> glam@doc:from_string(Name); int -> glam@doc:from_string( <<<<"int.to_string("/utf8, Name/binary>>/binary, ")"/utf8>> ) end end end ), glam@doc:join( _pipe, begin _pipe@1 = roundabout@common:string_join(), _pipe@2 = glam@doc:append( _pipe@1, glam@doc:from_string(<<"\"/\""/utf8>>) ), glam@doc:append(_pipe@2, roundabout@common:string_join()) end ) end, _pipe@3 = {concat, []}, _pipe@6 = (fun(Self) -> case Is_root orelse Has_segments of true -> _pipe@4 = Self, glam@doc:append(_pipe@4, glam@doc:from_string(<<"\"/\""/utf8>>)); false -> _pipe@5 = Self, glam@doc:append( _pipe@5, glam@doc:from_string( <<(<<"\""/utf8>>)/binary, (<<"\""/utf8>>)/binary>> ) ) end end)(_pipe@3), _pipe@9 = (fun(Self@1) -> case Has_segments of true -> _pipe@7 = Self@1, _pipe@8 = glam@doc:append( _pipe@7, roundabout@common:string_join() ), glam@doc:append(_pipe@8, Segments); false -> Self@1 end end)(_pipe@6), (fun(Self@2) -> case gleam@list:is_empty(erlang:element(3, Node)) of true -> Self@2; false -> _pipe@10 = Self@2, _pipe@11 = glam@doc:append( _pipe@10, roundabout@common:string_join() ), glam@doc:append( _pipe@11, glam@doc:from_string( <<(roundabout@common:get_function_name( Ancestors, erlang:element(2, Node) ))/binary, "_route_to_path(sub)"/utf8>> ) ) end end)(_pipe@9). -file("src/roundabout/generate_route_to_path.gleam", 79). -spec generate_route_to_path_case( boolean(), list(roundabout@node:info()), roundabout@node:node_() ) -> glam@doc:document(). generate_route_to_path_case(Is_root, Ancestors, Node) -> Variant_params = begin _pipe = erlang:element(3, erlang:element(2, Node)), _pipe@3 = gleam@list:filter_map(_pipe, fun(Seg) -> case Seg of {seg_lit, _} -> {error, nil}; {seg_param, Param} -> _pipe@1 = Param, _pipe@2 = roundabout@parameter:name(_pipe@1), {ok, _pipe@2} end end), (fun(Items) -> case gleam@list:is_empty(erlang:element(3, Node)) of true -> Items; false -> lists:append(Items, [<<"sub"/utf8>>]) end end)(_pipe@3) end, Variant_params_str = case gleam@list:is_empty(Variant_params) of true -> <<""/utf8>>; false -> <<<<"("/utf8, (gleam@string:join(Variant_params, <<", "/utf8>>))/binary>>/binary, ")"/utf8>> end, Branch_result = get_branch_result(Is_root, Ancestors, Node), _pipe@4 = glam@doc:from_string( <<(roundabout@common:get_type_name(Ancestors, erlang:element(2, Node)))/binary, Variant_params_str/binary>> ), _pipe@5 = glam@doc:append(_pipe@4, roundabout@common:case_arrow()), _pipe@6 = glam@doc:append(_pipe@5, Branch_result), glam@doc:nest(_pipe@6, 2). -file("src/roundabout/generate_route_to_path.gleam", 29). ?DOC(false). -spec generate_route_to_path( list(roundabout@node:info()), roundabout@node:node_() ) -> glam@doc:document(). generate_route_to_path(Ancestors, Node) -> Is_root = gleam@list:is_empty(Ancestors), Next_ancestors = gleam@list:prepend(Ancestors, erlang:element(2, Node)), Route_to_path_cases = begin _pipe = erlang:element(3, Node), _pipe@1 = gleam@list:map( _pipe, fun(_capture) -> generate_route_to_path_case(Is_root, Next_ancestors, _capture) end ), glam@doc:join(_pipe@1, {line, 1}) end, Function_name = begin _pipe@2 = [roundabout@common:get_function_name( Ancestors, erlang:element(2, Node) ), <<"route_to_path"/utf8>>], _pipe@3 = gleam@list:filter( _pipe@2, fun(Name) -> not gleam@string:is_empty(Name) end ), gleam@string:join(_pipe@3, <<"_"/utf8>>) end, Pub_prefix = case gleam@list:is_empty(Ancestors) of true -> <<"pub "/utf8>>; false -> <<""/utf8>> end, glam@doc:concat( [glam@doc:from_string( <<<<<<<<<>/binary, Function_name/binary>>/binary, "(route: "/utf8>>/binary, (roundabout@common:get_type_name( Ancestors, erlang:element(2, Node) ))/binary>>/binary, "Route) -> String {"/utf8>> ), glam@doc:nest_docs( [{line, 1}, glam@doc:from_string(<<"case route {"/utf8>>), glam@doc:nest_docs([{line, 1}, Route_to_path_cases], 2), {line, 1}, glam@doc:from_string(<<"}"/utf8>>)], 2 ), {line, 1}, glam@doc:from_string(<<"}"/utf8>>), glam@doc:lines(2)] ). -file("src/roundabout/generate_route_to_path.gleam", 10). ?DOC(false). -spec generate_route_to_path_rec( list(roundabout@node:info()), roundabout@node:node_() ) -> glam@doc:document(). generate_route_to_path_rec(Ancestors, Node) -> case gleam@list:is_empty(erlang:element(3, Node)) of true -> glam@doc:from_string(<<""/utf8>>); false -> Next_ancestors = gleam@list:prepend( Ancestors, erlang:element(2, Node) ), Sub_types = gleam@list:map( erlang:element(3, Node), fun(Node@1) -> generate_route_to_path_rec(Next_ancestors, Node@1) end ), This = generate_route_to_path(Ancestors, Node), glam@doc:concat(gleam@list:prepend(Sub_types, This)) end.