diff --git a/src/api_interface.erl b/src/api_interface.erl index 69dbf29a..d9a30396 100644 --- a/src/api_interface.erl +++ b/src/api_interface.erl @@ -34,8 +34,10 @@ -module(api_interface). -export([pos_to_node/3, range_to_node/3, - pos_to_fun_name/2,pos_to_fun_def/2,pos_to_var_name/2,pos_to_var/2,pos_to_expr/3, - pos_to_expr_list/2,pos_to_expr_list/3,pos_to_expr_or_pat_list/3,expr_to_fun/2]). + pos_to_fun_name/2,pos_to_fun_def/2,pos_to_var_name/2, + pos_to_var/2,pos_to_expr/3, pos_to_expr1/3, + pos_to_expr_list/2,pos_to_expr_list/3, + pos_to_expr_or_pat_list/3,expr_to_fun/2]). -include("../include/wrangler_internal.hrl"). @@ -333,6 +335,16 @@ pos_to_expr(Tree, Start, End) -> _ -> {ok, hd(Es)} end. + +pos_to_expr1(FileOrTree, Start, End) when is_list(FileOrTree) -> + case filelib:is_regular(FileOrTree) of + true -> + {ok, {AnnAST, _}} = wrangler_ast_server:parse_annotate_file(FileOrTree, true), + pos_to_expr(AnnAST, Start, End); + false -> + throw({error, "Badarg to function interface_api:pos_to_expr1/3"}) + end. + pos_to_expr_1(Tree, Start, End) -> {S, E} = wrangler_misc:start_end_loc(Tree), if (S >= Start) and (E =< End) ->