-module(internal@ast_const). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]). -export([public_const/1, is_pub_const_used/3]). -spec public_const(internal@ast:file_ast()) -> list(internal@ast:public_member()). public_const(File_ast) -> {file_ast, Ast} = File_ast, {module, _, _, _, Constants, _} = Ast, gleam@list:flat_map( Constants, fun(Constant) -> {definition, _, {constant, Const_name, Is_public, _, _}} = Constant, case Is_public of public -> [{public_const, Const_name}]; _ -> [] end end ). -spec check_const_usage( list(any()), internal@ast:public_member(), internal@ast:module_name() ) -> {ok, nil} | {error, nil}. check_const_usage(Statements, Pub_const_name, Module_name) -> {public_const, Pub_const_name@1} = case Pub_const_name of {public_const, _} -> Pub_const_name; _assert_fail -> erlang:error(#{gleam_error => let_assert, message => <<"Assertion pattern match failed"/utf8>>, value => _assert_fail, module => <<"internal/ast_const"/utf8>>, function => <<"check_const_usage"/utf8>>, line => 27}) end, {module_name, Module_name@1} = Module_name, gleam@list:find_map( Statements, fun(Statement) -> case begin _pipe = Statement, _pipe@1 = gleam@string:inspect(_pipe), gleam_stdlib:contains_string( _pipe@1, <<<<<<<<"FieldAccess(Variable(\""/utf8, Module_name@1/binary>>/binary, "\"), \""/utf8>>/binary, Pub_const_name@1/binary>>/binary, "\")"/utf8>> ) end of true -> {ok, nil}; false -> {error, nil} end end ). -spec is_pub_const_used( internal@ast:another_files_ast(), internal@ast:public_member(), internal@fs:module_full_name() ) -> {ok, nil} | {error, nil}. is_pub_const_used(Files_ast, Pub_const_name, Module_full_name) -> internal@ast:is_pub_member_used( Files_ast, Pub_const_name, Module_full_name, fun check_const_usage/3 ).