-module(internal@ast). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]). -export([files_ast/1, files_paths_with_ast/2]). -export_type([file_ast/0, another_files_ast/0]). -type file_ast() :: {file_ast, glance:module_()}. -type another_files_ast() :: {another_files_ast, list(file_ast())}. -spec files_ast(list(internal@fs:file_content())) -> list(file_ast()). files_ast(Files_contents) -> gleam@list:map( Files_contents, fun(Content) -> {file_content, Content@1} = case Content of {file_content, _} -> Content; _assert_fail -> erlang:error(#{gleam_error => let_assert, message => <<"Assertion pattern match failed"/utf8>>, value => _assert_fail, module => <<"internal/ast"/utf8>>, function => <<"files_ast"/utf8>>, line => 16}) end, _assert_subject = glance:module(Content@1), {ok, Ast} = case _assert_subject of {ok, _} -> _assert_subject; _assert_fail@1 -> erlang:error(#{gleam_error => let_assert, message => <<"Assertion pattern match failed"/utf8>>, value => _assert_fail@1, module => <<"internal/ast"/utf8>>, function => <<"files_ast"/utf8>>, line => 17}) end, {file_ast, Ast} end ). -spec files_paths_with_ast( internal@fs:files_dir(), gleam@option:option(internal@fs:files_dir()) ) -> list({internal@fs:file_path(), file_ast(), another_files_ast()}). files_paths_with_ast(Dir, Test_dir) -> File_paths = internal@fs:files_paths(Dir), Flle_contents = internal@fs:files_contents(File_paths), Test_file_contents = case Test_dir of {some, {files_dir, _} = Test_dir@1} -> _pipe = internal@fs:files_paths(Test_dir@1), internal@fs:files_contents(_pipe); none -> [] end, Ast_list = begin _pipe@1 = Flle_contents, _pipe@2 = gleam@list:append(_pipe@1, Test_file_contents), files_ast(_pipe@2) end, Indexes = gleam@list:range(0, gleam@list:length(Ast_list) - 1), gleam@list:filter_map( Indexes, fun(Index) -> case gleam@list:at(File_paths, Index) of {ok, File_path} -> _assert_subject = gleam@list:at(Ast_list, Index), {ok, File_ast} = case _assert_subject of {ok, _} -> _assert_subject; _assert_fail -> erlang:error(#{gleam_error => let_assert, message => <<"Assertion pattern match failed"/utf8>>, value => _assert_fail, module => <<"internal/ast"/utf8>>, function => <<"files_paths_with_ast"/utf8>>, line => 39}) end, {ok, {File_path, File_ast, {another_files_ast, gleam@list:filter_map( Indexes, fun(Idx) -> case Idx =:= Index of true -> {error, nil}; false -> gleam@list:at(Ast_list, Idx) end end )}}}; {error, nil} -> {error, nil} end end ).