anchor.diff:  
   -module(refac_rename_fun).
   
  --export([rename_fun/6, rename_fun_eclipse/6]).
  -
  --export([check_atoms/2]).
  -
  -%%-export([rename_fun_1/5, do_rename_fun/5]).
  +-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()]}).
  
positive.code: 	    {ok, {AnnAST, Info}}=refac_util:parse_annotate_file(FileName, true, SearchPaths, TabWidth),
  	    NewName1 = list_to_atom(NewName),
  	    {ok, ModName} = get_module_name(Info),
  	    Inscope_Funs = lists:map(fun ({_M, F, A}) -> {F, A} end, refac_util:inscope_funs(Info)),
  	    case refac_util:pos_to_fun_name(AnnAST, {Line, Col}) of
  		{ok, {Mod, Fun, Arity, _, DefinePos}} ->
  		    if Mod == ModName ->
  			    case NewName1 =/= Fun of
  				true ->
  				    case lists:member({NewName1, Arity}, Inscope_Funs) or
  					lists:member({NewName1, Arity}, refac_util:auto_imported_bifs())
  					of
  					true ->
  					    {error, NewName ++ "/" ++ integer_to_list(Arity) ++ " is already in scope."};
  					_ ->
  					    case is_callback_fun(Info, Fun, Arity) of
  						true ->
  						    {error, "The refactorer does not support renaming of callback function names."};
  						_ ->
  						    ?wrangler_io("The current file under refactoring is:\n~p\n", [FileName]),
  						    {AnnAST1, _C} = rename_fun(AnnAST, {Mod, Fun, Arity}, {DefinePos, NewName1}),
  						    %%check_atoms(AnnAST1, Fun),
  						    case refac_util:is_exported({Fun, Arity}, Info) of
  							true ->
  							    ?wrangler_io("\nChecking client modules in the following search paths: \n~p\n", [SearchPaths]),
  							    ClientFiles = refac_util:get_client_files(FileName, SearchPaths),
  							    try rename_fun_in_client_modules(ClientFiles, {Mod, Fun, Arity}, NewName, SearchPaths, TabWidth) of 
  								Results -> 
  								    case Editor of 
  									emacs ->
  									    refac_util:write_refactored_files_for_preview([{{FileName,FileName},AnnAST1} | Results]),
  									    ChangedClientFiles = lists:map(fun ({{F, _F}, _AST}) -> F end, Results),
  									    ChangedFiles = [FileName |ChangedClientFiles],
  									    ?wrangler_io("The following files are to be changed by this refactoring:\n~p\n",
  											 [ChangedFiles]),								    
  									    {ok, ChangedFiles};
  									eclipse ->
  									    Results1 = [{{FileName, FileName}, AnnAST1} | Results],
  									    Res = lists:map(fun({{FName, NewFName}, AST}) -> {FName, NewFName, 
  										       refac_prettypr:print_ast(refac_util:file_format(FName),AST)} end, Results1),
  									    {ok, Res}
  								    end
  								catch 
  								    throw:Err -> Err
  								end;
  							false ->
  							    case Editor of 
  								emacs ->
  								    refac_util:write_refactored_files_for_preview([{{FileName,FileName},AnnAST1}]),
  								    ?wrangler_io("The following files are to be changed by this refactoring:\n~p\n",
  										 [FileName]),								    
  								    {ok, [FileName]};
  								eclipse ->
  								    Res = [{FileName, FileName, refac_prettypr:print_ast(refac_util:file_format(FileName),AnnAST1)}],
  								    {ok, Res}
  							    end
  						    end
  					    end
  				    end;
  				_ -> case Editor of 
  					 emacs -> {ok, []};
  					 eclipse ->
   					     Res = [{FileName, FileName, refac_prettypr:print_ast(refac_util:file_format(FileName),AnnAST)}],
  					     {ok, Res}
  				     end
  			    end;
  		       true ->
  			    {error, "This function is not defined in this module; please go to the module where it is defined for renaming."}
  		    end;
  		{error, _Reason} -> {error, "You have not selected a function name!"}
  	    end;
        false -> {error, "Invalid new function name!"}
      end.
  
  %% =====================================================================
  %% rename_fun(Tree:syntaxTree(), oldName::{atom(),atom(), integer()},
  %%            {DefinePos,NewName}::{{integer(),integer{},atom()
  %%
  rename_fun(Tree, OldName, {DefinePos, NewName}) ->
      refac_util:stop_tdTP(fun do_rename_fun_1/2, Tree,
  			 {OldName, {DefinePos, NewName}}).
  
  do_rename_fun_1(Tree, {{M, OldName, Arity}, {DefinePos, NewName}}) ->
      case refac_syntax:type(Tree) of
        function ->
  	  case get_fun_def_loc(Tree) of
  
negative.code:       _ -> '_'
      end.
  
  rename_fun_in_client_modules(Files, {Mod, Fun, Arity}, NewName, SearchPaths, TabWidth, Pid) ->
      case Files of
        [] -> [];
        [F | Fs] ->
  	    ?wrangler_io("The current file under refactoring is:\n~p\n", [F]),
  	    {ok, {AnnAST, Info}}= refac_util:parse_annotate_file(F, true, SearchPaths, TabWidth),
  	    {AnnAST1, Changed} = rename_fun_in_client_module_1(F, {AnnAST, Info},{Mod, Fun, Arity}, NewName, SearchPaths, Pid),
  	    check_atoms(F, AnnAST1, Fun, Pid),
  	    if Changed ->
  		    [{{F, F}, AnnAST1} | rename_fun_in_client_modules(Fs, {Mod, Fun, Arity}, NewName, SearchPaths, TabWidth, Pid)];
  	       true ->
  		    rename_fun_in_client_modules(Fs, {Mod, Fun, Arity}, NewName, SearchPaths, TabWidth, Pid)
  	    end
      end.
  
  