anchor.diff:  
   rename_fun_1_eclipse(FileName, Line, Col, NewName, SearchPaths, TabWidth) ->
       rename_fun_1(FileName, Line, Col, NewName, SearchPaths, TabWidth, eclipse).
  -    
  +
   rename_fun_1(FileName, Line, Col, NewName, SearchPaths, TabWidth, Editor) ->
       Cmd = "CMD: " ++ atom_to_list(?MODULE) ++ ":rename_fun(" ++ "\"" ++
  -	FileName ++ "\", " ++ integer_to_list(Line) ++
  -	", " ++ integer_to_list(Col) ++ ", " ++ "\"" ++ NewName ++ "\","
  -	++ "[" ++ refac_util:format_search_paths(SearchPaths) ++ "]," ++ integer_to_list(TabWidth) ++ ").",    
  -    {ok, {AnnAST, Info}} = refac_util:parse_annotate_file(FileName, true, SearchPaths, TabWidth),
  +	    FileName ++ "\", " ++ integer_to_list(Line) ++
  +	      ", " ++ integer_to_list(Col) ++ ", " ++ "\"" ++ NewName ++ "\","
  +		++ "[" ++ refac_util:format_search_paths(SearchPaths) ++ "]," ++ integer_to_list(TabWidth) ++ ").",
  +    {ok, {AnnAST0, Info}} = refac_util:parse_annotate_file(FileName, true, SearchPaths, TabWidth),
  +    AnnAST = refac_type_annotation:type_ann_ast(FileName, AnnAST0, SearchPaths, TabWidth),
       NewName1 = list_to_atom(NewName),
       {ok, {Mod, Fun, Arity, _, DefinePos}} = refac_util:pos_to_fun_name(AnnAST, {Line, Col}),
       ?wrangler_io("The current file under refactoring is:\n~p\n", [FileName]),
       Pid = start_atom_process(),
  -    {AnnAST1, _C} = do_rename_fun(FileName, SearchPaths, AnnAST, {Mod, Fun, Arity}, 
  -				  {DefinePos, NewName1}, Pid, TabWidth),
  +    {AnnAST1, _C} = do_rename_fun(AnnAST, {Mod, Fun, Arity}, {DefinePos, NewName1}),
       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, Pid)
  -		of
  -		Results ->
  -		    output_atom_warning_msg(Pid, not_renamed_warn_msg(Fun), renamed_warn_msg(Fun)),
  -		    stop_atom_process(Pid),
  -		    write_files(Editor, [{{FileName, FileName}, AnnAST1}| Results], Cmd)
  -	    catch
  -		throw:Err -> Err
  -	    end;
  +      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, Pid)
  +	  of
  +	    Results ->
  +		  HasWarningMsg =has_warning_msg(Pid),
  +		  output_atom_warning_msg(Pid, not_renamed_warn_msg(Fun), renamed_warn_msg(Fun)),
  +		  stop_atom_process(Pid),
  +		  write_files(Editor, [{{FileName, FileName}, AnnAST1}| Results], Cmd,HasWarningMsg)
  +	  catch
  +	      throw:Err -> Err
  +	  end;
   	false ->
  +	    HasWarningMsg =has_warning_msg(Pid),
   	    output_atom_warning_msg(Pid, not_renamed_warn_msg(Fun), renamed_warn_msg(Fun)),
   	    stop_atom_process(Pid),
  -	    write_files(emacs, [{{FileName, FileName}, AnnAST1}], Cmd)
  +	    write_files(emacs, [{{FileName, FileName}, AnnAST1}], Cmd,HasWarningMsg)
       end.
   
   -spec(write_files/3::(Editor::atom(), Results::[{{filename(), filename()}, syntaxTree()}], string()) ->
   	     {ok, [filename()]} | {ok, [{filename(), filename(), string()}]}).
  -write_files(Editor, Results, Cmd) ->    
  -    case Editor of 
  -	emacs ->
  +
  +write_files(Editor, Results, Cmd) ->
  +    case Editor of
  +      emacs ->
  +	  refac_util:write_refactored_files_for_preview(Results, Cmd),
  +	  ChangedFiles = [F || {{F, _F}, _AST} <- Results],
  +	  ?wrangler_io("The following files are to be changed by this refactoring:\n~p\n",
  +		       [ChangedFiles]),
  +	  {ok, ChangedFiles};
  +      eclipse ->
  +	  Res = [{FName, NewFName, refac_prettypr:print_ast(refac_util:file_format(FName), AST)}
  +		 || {{FName, NewFName}, AST} <- Results],
  +	  {ok, Res}
  +    end.
  +
  +write_files(Editor, Results, Cmd, HasWarningMsg) ->
  +    case Editor of
  +      emacs ->
   	    refac_util:write_refactored_files_for_preview(Results, Cmd),
  -	    ChangedFiles = [F ||{{F, _F}, _AST}<-Results],
  +	    ChangedFiles = [F || {{F, _F}, _AST} <- Results],
   	    ?wrangler_io("The following files are to be changed by this refactoring:\n~p\n",
   			 [ChangedFiles]),
  -	    {ok, ChangedFiles};
  +	    {ok, ChangedFiles, HasWarningMsg};
   	eclipse ->
  -	    Res= [{FName, NewFName, refac_prettypr:print_ast(refac_util:file_format(FName),AST)}
  -		  ||{{FName, NewFName}, AST}<-Results],	  
  +	    Res = [{FName, NewFName, refac_prettypr:print_ast(refac_util:file_format(FName), AST)}
  +		   || {{FName, NewFName}, AST} <- Results],
   	    {ok, Res}
       end.
  -
  -pre_cond_check(FileName, Info, NewFunName, OldFunDefMod,OldFunName, Arity) ->
  +pre_cond_check(FileName, Info, NewFunName, OldFunDefMod, OldFunName, Arity) ->
       {ok, ModName} = get_module_name(Info),
  -    Inscope_Funs = [{F, A}||{_M, F, A}<-refac_util:inscope_funs(Info)],
  -    if OldFunDefMod==ModName ->
  -	    case lists:member({NewFunName, Arity}, Inscope_Funs) orelse
  -		erlang:is_builtin(erlang, NewFunName, Arity) orelse
  -		erl_internal:bif(erlang, NewFunName, Arity) of
  -		true ->
  -		    {error, atom_to_list(NewFunName) ++ "/" ++ 
  -		     integer_to_list(Arity) ++" is already in scope, "
  -		     "or is an auto-imported builtin function."};
  -		_ -> 
  -		    case is_callback_fun(Info,OldFunName, Arity) of
  -			true ->
  -			    {warning, "The function to be renamed is a callback function, continue?"}; 
  -			_ -> TestFrameWorkUsed = refac_util:test_framework_used(FileName),
  -			     case TestFrameWorkUsed of
  -				 [] -> ok;
  -				 _ ->
  -				     catch test_framework_aware_name_checking(
  -					     TestFrameWorkUsed, OldFunName, Arity, NewFunName)			      		     
  -			     end
  -		    end
  -	    end;
  -       true  ->
  -	    {error, "This function is not defined in this module; "
  -	     "a function can only be renamed from the module where it is defined."}
  -    end.
  -
  -
  -do_rename_fun(FileName, SearchPaths, Tree, {ModName, OldName, Arity}, 
  -	      {DefinePos, NewName}, Pid, TabWidth) ->
  -    refac_util:full_tdTP(fun do_rename_fun_1/2, Tree, 
  -			 {FileName, {ModName, OldName, Arity}, 
  -			  {DefinePos, NewName},SearchPaths, Pid, TabWidth}).
  -  
  -do_rename_fun_1(Tree, {FileName, {M, OldName, Arity},
  -		       {DefinePos, NewName}, SearchPaths, Pid, TabWidth}) ->
  +    Inscope_Funs = [{F, A} || {_M, F, A} <- refac_util:inscope_funs(Info)],
  +    if OldFunDefMod == ModName ->
  +	   case lists:member({NewFunName, Arity}, Inscope_Funs) orelse
  +		  erlang:is_builtin(erlang, NewFunName, Arity) orelse
  +		    erl_internal:bif(erlang, NewFunName, Arity)
  +	       of
  +	     true ->
  +		 {error, atom_to_list(NewFunName) ++ "/" ++
  +			   integer_to_list(Arity) ++ " is already in scope, "
  +						     "or is an auto-imported builtin function."};
  +	     _ ->
  +		 case is_callback_fun(Info, OldFunName, Arity) of
  +		   true ->
  +		       {warning, "The function to be renamed is a callback function, continue?"};
  +		   _ -> TestFrameWorkUsed = refac_util:test_framework_used(FileName),
  +			case TestFrameWorkUsed of
  +			  [] -> ok;
  +			  _ ->
  +			      catch test_framework_aware_name_checking(
  +				      TestFrameWorkUsed, OldFunName, Arity, NewFunName)
  +			end
  +		 end
  +	   end;
  +       true ->
  +	   {error, "This function is not defined in this module; "
  +		   "a function can only be renamed from the module where it is defined."}
  +    end.
  +
  +do_rename_fun(Tree, {ModName, OldName, Arity}, {DefinePos, NewName}) ->
  +    refac_util:full_tdTP(fun do_rename_fun_1/2, Tree,
  +			 {{ModName, OldName, Arity}, {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
  -	    DefinePos ->
  -		N = refac_syntax:function_name(Tree),
  -		Cs = refac_syntax:function_clauses(Tree),
  -		N1 = refac_syntax:copy_attrs(N, refac_syntax:atom(NewName)),
  -		{rewrite(Tree, refac_syntax:function(N1, Cs)), true};
  -	    _ -> {Tree, false}
  -	  end;
  -      application ->
  -	  do_rename_in_fun_app(Tree, FileName, M, OldName, Arity, NewName, SearchPaths, TabWidth);
  -      arity_qualifier ->
  -	  do_rename_fun_in_arity_qualifier(Tree, M, OldName, Arity, NewName);
  -      tuple ->
  -	  do_rename_fun_in_tuples(Tree, {FileName, SearchPaths, M, OldName, NewName, Arity, Pid, TabWidth});
  -      _ -> {Tree, false}
  -    end.
  -
  -
  -do_rename_in_fun_app(Tree, FileName, M, OldName, Arity, NewName, SearchPaths, TabWidth) ->
  +	    case get_fun_def_loc(Tree) of
  +		DefinePos ->
  +		    N = refac_syntax:function_name(Tree),
  +		    Cs = refac_syntax:function_clauses(Tree),
  +		    N1 = refac_syntax:copy_attrs(N, refac_syntax:atom(NewName)),
  +		    {rewrite(Tree, refac_syntax:function(N1, Cs)), true};
  +		_ -> {Tree, false}
  +	    end;
  +	application ->
  +	  do_rename_in_fun_app(Tree, M, OldName, Arity, NewName);
  +	arity_qualifier ->
  +	    do_rename_fun_in_arity_qualifier(Tree, M, OldName, Arity, NewName);
  +	atom ->
  +	    As = refac_syntax:get_ann(Tree),
  +	    case lists:keysearch(type, 1, As) of
  +		{value, {type, {f_atom, [M, OldName, Arity]}}} ->
  +		    {refac_syntax:copy_attrs(Tree, refac_syntax:atom(NewName)), true};
  +		_ -> {Tree, false}
  +	    end;
  +	_ -> {Tree, false}
  +    end.
  +
  +do_rename_in_fun_app(Tree, M, OldName, Arity, NewName) ->
       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, TabWidth);
  -	    false ->
  -		case refac_syntax:type(Operator) of
  -		  atom ->
  -		      case get_fun_def_info(Operator) of
  -			{M, OldName, Arity, _} ->
  -			    Operator1 = rewrite(Operator, refac_syntax:atom(NewName)),
  -			    Tree1 = rewrite(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 = rewrite(Fun, refac_syntax:atom(NewName)),
  -			    %% Need to change the fun_def annotation as well?
  -			    Operator1 = rewrite(Operator, refac_syntax:module_qualifier(Mod, Fun2)),
  -			    Tree1 = rewrite(Tree, refac_syntax:application(Operator1, Arguments)),
  -			    {Tree1, true};
  -			_ -> {Tree, false}
  -		      end;
  -		  tuple ->
  -		      case refac_syntax:tuple_elements(Operator) of
  -			[Mod, Fun] ->
  -			    case get_fun_def_info(Operator) of
  -			      {M, OldName, Arity, _} ->
  -				  Fun2 = rewrite(Fun, refac_syntax:atom(NewName)),
  -				  %% Need to change the fun_def annotation as well?
  -				  Operator1 = rewrite(Operator, refac_syntax:tuple([Mod, Fun2])),
  -				  Tree1 = rewrite(Tree, refac_syntax:application(Operator1, Arguments)),
  -				  {Tree1, true};
  -			      _ -> {Tree, false}
  -			    end;
  -			_ -> {Tree, false}
  -		      end;
  +    case refac_syntax:type(Operator) of
  +      atom ->
  +	  case get_fun_def_info(Operator) of
  +	    {M, OldName, Arity, _} ->
  +		Operator1 = rewrite(Operator, refac_syntax:atom(NewName)),
  +		Tree1 = rewrite(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 = rewrite(Fun, refac_syntax:atom(NewName)),
  +		%% Need to change the fun_def annotation as well?
  +		Operator1 = rewrite(Operator, refac_syntax:module_qualifier(Mod, Fun2)),
  +		Tree1 = rewrite(Tree, refac_syntax:application(Operator1, Arguments)),
  +		{Tree1, true};
  +	    _ -> {Tree, false}
  +	  end;
  +      tuple ->
  +	  case refac_syntax:tuple_elements(Operator) of
  +	    [Mod, Fun] ->
  +		case get_fun_def_info(Operator) of
  +		  {M, OldName, Arity, _} ->
  +		      Fun2 = rewrite(Fun, refac_syntax:atom(NewName)),
  +		      %% Need to change the fun_def annotation as well?
  +		      Operator1 = rewrite(Operator, refac_syntax:tuple([Mod, Fun2])),
  +		      Tree1 = rewrite(Tree, refac_syntax:application(Operator1, Arguments)),
  +		      {Tree1, true};
   		  _ -> {Tree, false}
  -		end
  +		end;
  +	    _ -> {Tree, false}
   	  end;
         _ -> {Tree, false}
       end.
  
positive.code: 		end
  	end,
      R = lists:usort(lists:flatten(lists:map(F, refac_syntax:form_list_elements(Tree)))),
      R1 = [X ||{atom, X, _} <- R, X =/={0,0}],  %% X=/={0,0} only a temporay fix; should check where {0,0} is introduced.
      R2 = [X ||{_, X, _} <- lists:filter(fun (X) ->
  					     case X of
  						 {atom, _X, _} -> false;
  						 _ -> true
  					     end
  					end,
  					R)],
      UndecidableAtoms = R1 -- R2,
      case UndecidableAtoms of 
  	[] -> ok;
  	_ -> Pid ! {add_not_renamed, {FileName, UndecidableAtoms}}
      end.
   
  
  collect_atoms(Tree, AtomNames) ->
      F = fun (T, S) ->
  
negative.code: %% </p>
  %% @end
  %% =====================================================================
  %% Notes about being testing-framework-aware:
  %% EUNIT: Issue a warning message when renaming a non-test function to a test function and vice versa;
  %% EQC: Issue a warning when renaming callback functions, also handld the use of 'call' quardruples.
  %% CommonTest, Issue a warning message when renaing a non-test function to a test function and vice versa.
  
  -module(refac_rename_fun).
  
  -export([rename_fun/6, rename_fun_1/6,  rename_fun_eclipse/6, rename_fun_1_eclipse/6]).
  -export([check_atoms/4, collect_atoms/2,try_eval/4, start_atom_process/0, 
  	 stop_atom_process/1,output_atom_warning_msg/3, write_files/3,
  	 apply_style_funs/0, eqc_statem_callback_funs/0, is_callback_fun/3,
  	 commontest_callback_funs/0,testserver_callback_funs/0, has_warning_msg/1]).
  
  
  -include("../include/wrangler.hrl").
  