anchor.diff:  	_ -> false
       end.
   
  -rename_fun_in_client_module_1({Tree, Info}, {M, OldName, Arity}, NewName) ->
  +rename_fun_in_client_module_1(FileName, {Tree, Info}, {M, OldName, Arity}, NewName, SearchPaths, Pid) ->
       case lists:keysearch(module, 1, Info) of
         {value, {module, ClientModName}} ->
  -	  Inscope_Funs = lists:map(fun ({_M, F, A}) -> {F, A} end,
  -				   refac_util:inscope_funs(Info)),
  -	  case lists:member({list_to_atom(NewName), Arity}, Inscope_Funs) and
  -		 lists:member({OldName, Arity}, Inscope_Funs)
  -	      of
  -	    true ->
  -		  throw({error, "The new function name causes confliction in module '" ++ atom_to_list(ClientModName)++"'"});
  -	    false ->
  -		refac_util:stop_tdTP(fun do_rename_fun_in_client_module_1/2, Tree,
  -				     {{M, OldName, Arity}, NewName})
  -	  end;
  -      _ ->
  -	  refac_util:stop_tdTP(fun do_rename_fun_in_client_module_1/2, Tree,
  -			       {{M, OldName, Arity}, NewName})
  -    end.
  -
  -do_rename_fun_in_client_module_1(Tree, {{M, OldName, Arity}, NewName}) ->
  +	    Inscope_Funs = lists:map(fun ({_M, F, A}) -> {F, A} end, refac_util:inscope_funs(Info)),
  +	    case lists:member({list_to_atom(NewName), Arity}, Inscope_Funs)
  +		and lists:member({OldName, Arity}, Inscope_Funs) of
  +		true ->
  +		    throw({error, "The new function name causes confliction in module '" ++ atom_to_list(ClientModName)++"'"});
  +		_ -> ok
  +	    end;
  +	_ -> ok
  +    end,
  +    refac_util:stop_tdTP(fun do_rename_fun_in_client_module_1/2, Tree, {FileName,{M, OldName, Arity}, NewName, SearchPaths, Pid}).
  +  
  +
  +do_rename_fun_in_client_module_1(Tree, {FileName,{M, OldName, Arity}, NewName, SearchPaths, Pid}) ->
       case refac_syntax:type(Tree) of
  -      application ->
  -	  Operator = refac_syntax:application_operator(Tree),
  -	  Arguments = refac_syntax:application_arguments(Tree),
  -	  case application_info(Tree) of
  -	    {{_, apply}, 2} -> {Tree, true};
  -	    {{_, apply}, 3} -> transform_apply_call(Tree, {M, OldName, Arity}, NewName);
  -	    {{_, spawn}, 3} -> transform_spawn_call(Tree, {M, OldName, Arity}, NewName);
  -	    {{_, spawn}, 4} -> transform_spawn_call(Tree, {M, OldName, Arity}, NewName);
  -	    {{_, spawn_link}, 3} -> transform_spawn_call(Tree, {M, OldName, Arity}, NewName);
  -	    {{_, spawn_link}, 4} -> transform_spawn_call(Tree, {M, OldName, Arity}, NewName);
  -	    _ ->
  -		case refac_syntax:type(Operator) of
  -		  atom ->
  -		      case get_fun_def_info(Operator) of
  -			{M, OldName, Arity, _} ->
  -			    Operator1 = refac_syntax:copy_attrs(Operator, refac_syntax:atom(NewName)),
  -			    Tree1 = refac_syntax:copy_attrs(Tree, refac_syntax:application(Operator1, Arguments)),
  -			    {Tree1, true};
  -			_ -> {Tree, false}
  -		      end;
  -		  module_qualifier ->
  -		      Mod = refac_syntax:module_qualifier_argument(Operator),
  -		      Fun = refac_syntax:module_qualifier_body(Operator),
  -		      case get_fun_def_info(Operator) of
  -			{M, OldName, Arity, _} ->
  -			    Fun1 = refac_syntax:copy_attrs(Fun, refac_syntax:atom(NewName)),
  -			    %% Need to change the fun_def annotation as well?
  -			    Operator1 = refac_syntax:copy_attrs(Tree, refac_syntax:module_qualifier(Mod, Fun1)),
  -			    Tree1 = refac_syntax:copy_attrs(Tree, refac_syntax:application(Operator1, Arguments)),
  -			    {Tree1, true};
  -			_ -> {Tree, false}
  -		      end;
  -		  _ -> {Tree, false}
  -		end
  -	  end;
  -      arity_qualifier ->   %% is there a module name?
  -	  Fun = refac_syntax:arity_qualifier_body(Tree),
  -	  Fun_Name = refac_syntax:atom_value(Fun),
  -	  Arg = refac_syntax:arity_qualifier_argument(Tree),
  -	  Arg1 = refac_syntax:integer_value(Arg),
  -	  DefMod = get_fun_def_mod(Fun),
  -	  if (Fun_Name == OldName) and (Arg1 == Arity) and (DefMod == M) ->
  -		 {refac_syntax:copy_attrs(Tree, refac_syntax:arity_qualifier(refac_syntax:atom(NewName), Arg)),
  -		  true};
  -	     true -> {Tree, false}
  -	  end;
  -      _ -> {Tree, false}
  +	application ->
  +	    Operator = refac_syntax:application_operator(Tree),
  +	    Arguments = refac_syntax:application_arguments(Tree),
  +	    case get_fun_def_info(Operator) of 
  +		{Mod1, Fun1, Ari1, _} ->
  +		    case lists:keysearch({Mod1, Fun1, Ari1}, 1, apply_style_funs()) of 
  +			{value, _} ->
  +			    transform_apply_style_calls(FileName, Tree, {M, OldName, Arity}, NewName, SearchPaths);
  +			false ->case refac_syntax:type(Operator) of
  +				    atom ->
  +					case get_fun_def_info(Operator) of
  +					    {M, OldName, Arity, _} ->
  +						Operator1 = refac_syntax:copy_attrs(Operator, refac_syntax:atom(NewName)),
  +						Tree1 = refac_syntax:copy_attrs(Tree, refac_syntax:application(Operator1, Arguments)),
  +						{Tree1, true};
  +					    _ -> {Tree, false}
  +					end;
  +				    module_qualifier ->
  +					Mod = refac_syntax:module_qualifier_argument(Operator),
  +					Fun = refac_syntax:module_qualifier_body(Operator),
  +					case get_fun_def_info(Operator) of
  +					    {M, OldName, Arity, _} ->
  +						Fun2 = refac_syntax:copy_attrs(Fun, refac_syntax:atom(NewName)),
  +						%% Need to change the fun_def annotation as well?
  +						Operator1 = refac_syntax:copy_attrs(Tree, refac_syntax:module_qualifier(Mod, Fun2)),
  +						Tree1 = refac_syntax:copy_attrs(Tree, refac_syntax:application(Operator1, Arguments)),
  +						{Tree1, true};
  +					    _ -> {Tree, false}
  +					end;
  +				    _ -> {Tree, false}
  +				end
  +		    end;
  +		_ -> {Tree, false}
  +	    end;
  +	arity_qualifier ->   %% is there a module name?
  +	    Fun = refac_syntax:arity_qualifier_body(Tree),
  +	    Fun_Name = refac_syntax:atom_value(Fun),
  +	    Arg = refac_syntax:arity_qualifier_argument(Tree),
  +	    Arg1 = refac_syntax:integer_value(Arg),
  +	    DefMod = get_fun_def_mod(Fun),
  +	    if (Fun_Name == OldName) and (Arg1 == Arity) and (DefMod == M) ->
  +		    {refac_syntax:copy_attrs(Tree, refac_syntax:arity_qualifier(refac_syntax:atom(NewName), Arg)),
  +		     true};
  +	       true -> {Tree, false}
  +	    end;
  +	tuple -> do_rename_fun_in_tuples(Tree, {FileName, SearchPaths, M, OldName, NewName, Arity, Pid});
  +	_ -> {Tree, false}
       end.
   
   get_module_name(ModInfo) ->
  
positive.code:       application ->
  	  Operator = refac_syntax:application_operator(Tree),
  	  Arguments = refac_syntax:application_arguments(Tree),
  	  case application_info(Tree) of
  	    {{_, apply}, 2} -> transform_apply_call(Tree, {M, OldName, Arity}, NewName);
  	    {{_, apply}, 3} -> transform_apply_call(Tree, {M, OldName, Arity}, NewName);
  	    {{_, spawn}, 3} -> transform_spawn_call(Tree, {M, OldName, Arity}, NewName);
  	    {{_, spawn}, 4} -> transform_spawn_call(Tree, {M, OldName, Arity}, NewName);
  	    {{_, spawn_link}, 3} -> transform_spawn_call(Tree, {M, OldName, Arity}, NewName);
  	    {{_, spawn_link}, 4} -> transform_spawn_call(Tree, {M, OldName, Arity}, NewName);
  	    _ ->
  		case refac_syntax:type(Operator) of
  		  atom ->
  		      case get_fun_def_info(Operator) of
  			{M, OldName, Arity, _} ->
  			    Operator1 = refac_syntax:copy_attrs(Operator, refac_syntax:atom(NewName)),
  			    Tree1 = refac_syntax:copy_attrs(Tree, refac_syntax:application(Operator1, Arguments)),
  			    {Tree1, false};
  			_ -> {Tree, false}
  		      end;
  		  module_qualifier ->
  		      Mod = refac_syntax:module_qualifier_argument(Operator),
  		      Fun = refac_syntax:module_qualifier_body(Operator),
  		      case get_fun_def_info(Operator) of
  			{M, OldName, Arity, _} ->
  			    Fun1 = refac_syntax:copy_attrs(Fun, refac_syntax:atom(NewName)),
  			    %% Need to change the fun_def annotation as well?
  			    Operator1 = refac_syntax:copy_attrs(Tree, refac_syntax:module_qualifier(Mod, Fun1)),
  			    Tree1 = refac_syntax:copy_attrs(Tree, refac_syntax:application(Operator1, Arguments)),
  			    {Tree1, false};
  			_ -> {Tree, false}
  		      end;
  		  _ -> {Tree, false}
  		end
  	  end;
        arity_qualifier ->
  	  Fun = refac_syntax:arity_qualifier_body(Tree),
  	  Fun_Name = refac_syntax:atom_value(Fun),
  	  Arg = refac_syntax:arity_qualifier_argument(Tree),
  
negative.code: 
  -module(refac_rename_fun).
  
  -export([rename_fun/6, rename_fun_1/6,  rename_fun_eclipse/6]).
  
  -export([check_atoms/4]).
  
  -include("../include/wrangler.hrl").
  %% =====================================================================
  %% @spec rename_fun(FileName::filename(), Line::integer(), Col::integer(), NewName::string(), SearchPaths::[string()])
  %% -> term()
  %%
  
  -define(DEBUG, true).
  
  -ifdef(DEBUG).
  -define(debug(__String, __Args), ?wrangler_io(__String, __Args)).
  -else.
  -define(debug(__String, __Args), ok).
  -endif.
  
  -spec(rename_fun/6::(string(), integer(), integer(), string(), [dir()], integer()) ->
  	     {error, string()} | {ok, [filename()]}).
  