anchor.diff:        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
  +	  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, 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, _} ->
  +					      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, false};
  +					  _ -> {Tree, false}
  +				      end;
  +				  _ -> {Tree, false}
  +			      end
  +		  end
   	  end;
  -      arity_qualifier ->
  +	arity_qualifier ->
   	  Fun = refac_syntax:arity_qualifier_body(Tree),
   	  Fun_Name = refac_syntax:atom_value(Fun),
   	  Arg = refac_syntax:arity_qualifier_argument(Tree),
  
positive.code: 				end,
  				R)),
      UndecidableAtoms = R1 -- R2,
      case UndecidableAtoms of
        [] -> ok;
        _ ->
  	  ?wrangler_io("WARNING: the refactorer could not decide "
  		    "whether to rename the name at the following "
  		    "positions in this file, please check "
  		    "manually! {Line, Col}:\n~p\n",
  		    [UndecidableAtoms])
      end.
  
  collect_atoms(Tree, AtomName) ->
      F = fun (T, S) ->
  
negative.code: 	end,
      refac_syntax_lib:fold(F, [], Tree).
  
  
  transform_apply_style_calls(FileName, Node, {ModName, FunName, Arity}, NewFunName, SearchPaths) ->
      Operator = refac_syntax:application_operator(Node),
      Arguments = refac_syntax:application_arguments(Node),
      [N1, N2, Mod, Fun, Args] = case length(Arguments) of 
  				   5 -> Arguments;
  				   4 -> [none | Arguments];
  				   3 -> [none , none| Arguments]
  			       end,					
      Mod1 = try_eval(FileName, Mod, SearchPaths),
      Fun1 = try_eval(FileName, Fun, SearchPaths),
      case Fun1 of
  	{value, FunName} ->
  	    case Mod1 of
  		{value, ModName} ->
  		    case ((refac_syntax:type(Args)==list) andalso (refac_syntax:list_length(Args)==Arity)) orelse
  			((refac_syntax:type(Args)==nil) andalso Arity==0) of 
  			true ->
  			    Fun2 = refac_syntax:atom(NewFunName),
  			    App = case length(Arguments) of
  				      5 -> refac_syntax:application(Operator, [N1,N2, Mod, Fun2, Args]);
  				      4 -> refac_syntax:application(Operator, [N2, Mod, Fun2, Args]);
  				      3 -> refac_syntax:application(Operator, [Mod, Fun2, Args])
  				  end,
  			    {refac_syntax:copy_pos(Node, refac_syntax:copy_attrs(Node, App)), true};
  			false -> {Node, false}
  		    end;
  		_ ->
  		    {Node, false}
  	    end;
  	{value, _} -> {Node, false};
  	{error, _Reason} -> {Node, false}
      end.
  
  %% =====================================================================
  %% @spec application_info(Tree::syntaxTree())->term()
  
  %% Three ways that function name can be used in test data:
  %% {modulename, functionname}
  %% {modulename, functionname, arity}
  %% {modulename, functionname, arglist}
  %% {generator, modulename, functionname}
  %% {call, modulename, functionname, arglist}
  do_rename_fun_in_tuples(Node, {FileName, SearchPaths, ModName, OldName, NewName, Arity, Pid}) ->
      case refac_syntax:type(Node) of 
  	tuple ->
  	    case refac_syntax:tuple_elements(Node) of 
  		[E1, E2] ->
  		    case refac_syntax:type(E2) of 
  			atom -> case refac_syntax:atom_value(E2) of 
  				    OldName ->
  					case try_eval(FileName, E1, SearchPaths) of 
  					    {value, ModName} ->
  						Pid ! {add_renamed, {FileName, refac_syntax:get_pos(E2)}},
  						{refac_syntax:tuple([E1, refac_syntax:copy_attrs(E2, refac_syntax:atom(NewName))]),
  						 true};
  					    _ -> {Node, false}
  					end;
  				    _ -> {Node, false}
  				end;
  			_ -> {Node, false}
  		    end;
  		[E1, E2, E3] -> 
  		    case refac_syntax:type(E3) of 
  			atom -> case refac_syntax:atom_value(E3) of 
  				    OldName ->
  					case try_eval(FileName, E2, SearchPaths) of
  					    {value, ModName} ->
  						Pid ! {add_renamed, {FileName, refac_syntax:get_pos(E3)}},
  						{refac_syntax:tuple([E1, E2, 
  								     refac_syntax:copy_attrs(E3, refac_syntax:atom(NewName))]),
  						 true};
  					    _  -> {Node, false}
  					end;
  				    _ -> {Node, false}
  				end;
  			integer -> 
  			    case refac_syntax:integer_value(E3) of 
  				       Arity -> case refac_syntax:type(E2) of 
  						    atom -> case refac_syntax:atom_value(E2) of 
  								OldName -> 
  								    case try_eval(FileName, E1, SearchPaths) of
  									{value, ModName} ->
  									    Pid ! {add_renamed, {FileName, refac_syntax:get_pos(E2)}},
  									    {refac_syntax:tuple([E1, refac_syntax:copy_attrs(E2, 
  										refac_syntax:atom(NewName)), E3]),true};
  									_ -> {Node, false}
  								    end;
  								_ -> {Node, false}
  							    end;
  						    _->{Node, false}
  						end;
  				       _ -> {Node, false}
  				   end;
  			_ -> {Node, false}
  		    end;
  		[E1, E2, E3, E4] ->
  		    case refac_syntax:type(E3) of 
  			atom -> case refac_syntax:atom_value(E3) of 
  				    OldName ->
  					case try_eval(FileName, E2, SearchPaths) of
  					    {value, ModName} ->
  						case ((refac_syntax:type(E4)==list) andalso (refac_syntax:list_length(E4)==Arity)) orelse
  						    ((refac_syntax:type(E4)==nil) andalso Arity==0) of
  						    true ->
  							Pid ! {add_renamed, {FileName, refac_syntax:get_pos(E3)}},
  							{refac_syntax:tuple([E1, E2, 
  									     refac_syntax:copy_attrs(E3, refac_syntax:atom(NewName)), E4]),
  							 true};
  						    _ ->
  							{Node, false}
  						end;
  					    _ -> {Node, false}
  					end;
  				    _ -> {Node, false}
  				end;
  			_ -> {Node, false}
  		    end;
  		_ -> {Node, false}
  	    end;
  	_  -> {Node, false}
      end.
  
  try_eval(FileName, Node, SearchPaths) ->
      try erl_eval:exprs([refac_syntax:revert(Node)],[]) of
  	{value, Val, _} -> {value, Val}
      catch _:_ ->
  	    case has_macros(Node) andalso (refac_util:get_free_vars(Node)==[]) of 
  		true ->
  		    Dir = filename:dirname(FileName),
  		    DefaultIncl1 = [".","..", "../hrl", "../incl", "../inc", "../include"],
  		    DefaultIncl2 = [filename:join(Dir, X) || X <-DefaultIncl1],
  		    NewSearchPaths= SearchPaths++DefaultIncl2,
  		    {Ms, UMs} = case refac_epp:parse_file(FileName, NewSearchPaths, [])  of 
  				    {ok, _, {Defs, Uses}} -> 
  					{dict:from_list(Defs), dict:from_list(Uses)};		  	 
  				    _ -> []
  				end, 
  		    NodeToks = get_toks(FileName, Node),
  		    try refac_epp:expand_macros(NodeToks, {Ms, UMs}) of
  			NewToks when is_list(NewToks)->
  			    {ok, Exprs} = refac_parse:parse_exprs(NewToks++[{dot,{999,0}}]),
  			    try erl_eval:exprs(Exprs, []) of 
  				{value, Val, _} -> {value, Val}
  			    catch
  				_:_ -> {error, no_value}
  			    end
  		    catch
  			_:__ -> {error, no_value}
  		    end;
  		false ->
  		    {error, no_value}
  	    end
      end.
      
  
  has_macros(Node) ->
      F = fun(N, _Others) ->
  		case refac_syntax:type(N) of
  		    macro -> {N, true};
  		    _ -> {[], false}
  		end
  	end,			    
      {_, Res}= refac_util:once_tdTU(F, Node, []),
      Res.
  
  get_toks(FileName, Node) ->
      Toks = refac_util:tokenize(FileName),
      {StartPos, EndPos} = refac_util:get_range(Node),
      Toks1 = lists:dropwhile(fun(T) ->
  				    token_loc(T) < StartPos end, Toks),
      Toks2 = lists:takewhile(fun(T) ->
  				    token_loc(T) =< EndPos end, Toks1),
      Toks2.
  
  token_loc(T) ->
      case T of
  	{_, L, _V} -> L;
  	{_, L1} -> L1
      end.
  
  test_framework_aware_name_checking(UsedFrameWorks, OldFunName, Arity, NewFunName) ->
      eunit_name_checking(UsedFrameWorks, OldFunName,Arity, NewFunName),
      eqc_name_checking(UsedFrameWorks, OldFunName, Arity, NewFunName),
      testserver_name_checking(UsedFrameWorks, OldFunName, Arity, NewFunName),
      commontest_name_checking(UsedFrameWorks, OldFunName, Arity, NewFunName).
  
  
  eunit_name_checking(UsedFrameWorks, OldFunName, Arity, NewFunName) ->
       case lists:keysearch(eunit, 1, UsedFrameWorks) of 
  	{value,_} when Arity==0 ->
  	     eunit_name_checking_1(atom_to_list(OldFunName), (atom_to_list(NewFunName)));
  	_ -> ok
      end.
     
  eunit_name_checking_1(OldFunName, NewFunName) ->
      case lists:suffix(?DEFAULT_EUNIT_TEST_SUFFIX, OldFunName) of 
  	true ->
  	    case lists:suffix(?DEFAULT_EUNIT_TEST_SUFFIX, NewFunName) of 
  		true ->
  		    ok;
  	       _ -> throw({warning,"Renaming will make this function no longer an EUnit test function, continue?"})
  	    end;
  	_ -> case lists:suffix(?DEFAULT_EUNIT_GENERATOR_SUFFIX,OldFunName) of 
  		 true ->
  		     case lists:suffix(?DEFAULT_EUNIT_GENERATOR_SUFFIX, NewFunName) of 
  			 true -> ok;
  			 _ -> throw({warning,"Renaming will make this function no longer an EUnit test generator function,continue?"})
  		     end;
  		 _ ->case lists:suffix(?DEFAULT_EUNIT_TEST_SUFFIX, NewFunName) of 
  			 true -> throw({warning, "Renaming will make this function an EUnit test function, continue?"});		     
  			 _ -> case lists:suffix(?DEFAULT_EUNIT_GENERATOR_SUFFIX,NewFunName) of 
  				  true -> throw({warning, "Renaming will make this function an EUnit test geneator function, continue?"});
  				  _ -> ok
  			      end
  		     end
  	     end
      end.
  
  eqc_name_checking(UsedFrameWorks, OldFunName, Arity, NewFunName) ->
      case lists:keysearch(eqc_statem, 1, UsedFrameWorks) of 
  	{value,_} -> eqc_statem_name_checking(OldFunName, Arity, NewFunName);
  	false -> ok
      end,
      case lists:keysearch(eqc, 1, UsedFrameWorks) of 
  	{value,_} ->  eqc_name_checking(atom_to_list(OldFunName), Arity, atom_to_list(NewFunName));
  	false -> ok
      end.
     
  eqc_name_checking(OldFunName, _Arity, NewFunName) ->
      case lists:prefix("prop_", OldFunName) of 
  	true -> case lists:prefix("prop_", NewFunName) of 
  		    true -> ok;
  		    false -> throw({warning, "Renaming will make this function no longer a quickcheck property, continue?"})
  		end;
  	false -> case lists:prefix("prop_", NewFunName) of 
  		     true ->
  			 throw({warning, "Renaming will make this function a quickcheck property, continue?"});
  		     false -> ok
  		 end
      end.
  	    
  
  
  eqc_statem_name_checking(OldFunName, Arity, NewFunName) ->
      case lists:member({OldFunName, Arity}, eqc_statem_callback_funs()) of 
  	true ->
  	    throw({warning, "The function selected is a callback function, continue?"});
  	false -> case lists:member({NewFunName, Arity}, eqc_statem_callback_funs()) of 
  		     true ->
  			 throw({warning, "The new function would be a quickcheck callback function, continue?"});
  		     false -> ok
  		 end
      end.
  		 
  testserver_name_checking(UsedFrameWorks, OldFunName, Arity, NewFunName) ->
      case lists:keysearch(testserver, 1, UsedFrameWorks) of 
  	{value,_} ->testserver_name_checking(atom_to_list(OldFunName), Arity, atom_to_list(NewFunName));
  	false -> ok
      end.
     
  testserver_name_checking(OldFunName, Arity, NewFunName) ->
      case lists:member({OldFunName, Arity}, testserver_callback_funs()) of 
  	true ->
  	    throw({warning, "The function selected is mandatory in a Test Server test suite, continue?"});
  	false -> case lists:member({NewFunName, Arity}, testserver_callback_funs()) of 
  		     true ->
  			 throw({warning, "The new function would be Test Server special function, continue?"});
  		     false -> ok
  		 end
      end.		 
  									    
  commontest_name_checking(UsedFrameWorks, OldFunName, Arity, NewFunName) ->
      case lists:keysearch(commontest, 1, UsedFrameWorks) of 
  	{value,_} ->commontest_name_checking(atom_to_list(OldFunName), Arity, atom_to_list(NewFunName));
  	false -> ok
      end.
  commontest_name_checking(OldFunName, Arity, NewFunName) ->
      case lists:member({OldFunName, Arity}, commontest_callback_funs()) of 
  	true ->
  	    throw({warning, "The function selected is a Common Test callback function, continue?"});
  	false -> case lists:member({NewFunName, Arity}, commontest_callback_funs()) of 
  		     true ->
  			 throw({warning, "The new function would be a Common Test callback function, continue?"});
  		     false -> ok
  		 end
      end.
  	    
  
  eqc_statem_callback_funs()->
      [{initial_state, 0}, {precondition, 2}, {command,1}, {postcondition, 3}, {next_state,3}].
  commontest_callback_funs() ->
      [{all,0}, {groups, 0}, {suite, 0},{init_per_suite, 1}, {end_per_suite, 1},{init_per_group,2},
       {end_per_group, 2}, {init_per_testcase,2},{end_per_testcase, 2}, {testcase, 0},{testcase, 1}].
  testserver_callback_funs() ->
      [{all, 0}, {init_per_suite,1}, {end_per_suite,1},{init_per_testcase,2}, {fin_per_testcase,2}].
  
  apply_style_funs() ->
      [{{erlang, apply, 3}, [modulenmae, functionname, arglist], term},
       {{erlang, spawn, 3}, [modulename, functionname, arglist], term},
       {{erlang, spawn, 4}, [node, modulename, functionname, arglist], term},
       {{erlang, spawn_link, 3}, [modulename, functionname, arglist], term},
       {{erlang, spawn_link, 4}, [term, modulename, functioname, arglist], term},
       {{erlang, spawn_monitor, 3}, [term, modulename,functionname, arglist], term},
       {{test_server, timecall, 3}, [modulename, functionname, arglist], term},
       {{test_server, do_times, 4}, [integer, modulename, functionname, arglist], term},
       {{test_server, call_crash, 3}, [modulename, functionname, arglist], term},
       {{test_server, call_crash, 4}, [term, modulename, functionname, arglist], term},
       {{test_server, call_crash, 5}, [term, term, modulename, functionname, arglist], term}].
  
  
  start_atom_process() ->
      spawn_link(fun()-> atom_loop({[],[]}) end).
  
  stop_atom_process(Pid) ->
      Pid ! stop.
  
  atom_loop({NotRenamed, Renamed}) ->
      receive
  	{add_not_renamed, Data} ->
  	    atom_loop({[Data|NotRenamed], Renamed});
  	{add_renamed, {FileName, Pos}} ->
  	    case Renamed of
  		[] -> atom_loop({NotRenamed, [{FileName, [Pos]}]});
  		[{FileName, Ps}|Others] ->
  		    atom_loop({NotRenamed, [{FileName, [Pos|Ps]}|Others]});
  		_ -> atom_loop({NotRenamed, [{FileName,[Pos]}|Renamed]})
  	    end;		    
  	{From, get} ->
  	    From ! {self(), {lists:reverse(NotRenamed), lists:reverse(Renamed)}},
  	    atom_loop({NotRenamed, Renamed});
  	stop ->
  	    ok
      end.
  
  output_atom_warning_msg(Pid, Name) ->
      Pid ! {self(), get},
      receive
  	{Pid, {NotRenamed, Renamed}} ->
  	    output_atom_warnings({NotRenamed, Renamed}, Name);
  	_ -> throw({error, "Refactoring failed because of a bug in Wrangler."})
      end.
      
      
  
      
  output_atom_warnings({[],[]}, _) ->
      ok;
  output_atom_warnings({NotRenamed, Renamed}, FunName) ->
      output_atom_not_renamed_warnings(NotRenamed,FunName),
      output_atom_renamed_warnings(Renamed, FunName).
  
  output_atom_not_renamed_warnings([], _FunName)-> 
      ok;
  output_atom_not_renamed_warnings(NotRenamed, FunName) ->
      ?wrangler_io("\n=================================================================================\n",[]),
      ?wrangler_io("WARNING: Wrangler could not infer whether the uses of '~p' at the following positions "
  		 "refer to the function renamed, and they are not renamed. Please check manually!\n", [FunName]),
      output_atom_info(NotRenamed).
  
  output_atom_renamed_warnings([], _FunName) ->
      ok;
  output_atom_renamed_warnings(Renamed, FunName) ->
      ?wrangler_io("\n=================================================================================\n",[]),
      ?wrangler_io("WARNING: Wrangler has renamed the uses of '~p' at the following positions without enough "
  		 "syntactic/semantic information. Please check manually!\n", [FunName]),
      output_atom_info(Renamed).
  
  output_atom_info(FileAndPositions) ->
      Msg = lists:flatmap(fun({FileName, Positions}) ->
  				Str = io_lib:format("File:\n ~p\n", [FileName]),
  				Str ++ io_lib:format("Position(s){Line, Col}:~p\n",[Positions])
  			end, FileAndPositions),
      ?wrangler_io(Msg, []).
      
      
      
  
      
      
      
  		       
  
       
  
  
      
       
       
  