Skip to content

Commit

Permalink
new function added.
Browse files Browse the repository at this point in the history
  • Loading branch information
huiqing committed Mar 21, 2014
1 parent f421082 commit fd87f0e
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/api_interface.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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").

Expand Down Expand Up @@ -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) ->
Expand Down

0 comments on commit fd87f0e

Please sign in to comment.