anchor.diff:  	true -> 
   	    true;
   	false ->
  -	    {_CallerCallee, Sccs, _E} = get_call_graph(Files),
  +	    {_CallerCallee, Sccs, _E} = refac_callgraph_server:get_callgraph(Files),
   	    Sccs1 =[[Fun||{Fun, _FunDef}<-Scc]||Scc<-Sccs],
   	    lists:any(fun(E)-> (length(E)>1) andalso (lists:member({ModName, FunName, Arity}, E)) end,
   		      Sccs1)   
       end.
   	
      
  -collect_process_names(DirList) ->
  +%% The only way to register a process is to use register/2.
  +%% This function checks all the applications of 'register/2'.
  +collect_registered_names_and_pids(DirList) ->
       Files = refac_util:expand_files(DirList, ".erl"),
       F = fun(File, FileAcc) ->
  -		 case get_ast(File) of 
  -		     {ok, {AnnAST, Info}} ->
  -			 {value, {module, ModName}} = lists:keysearch(module, 1, Info),
  -			 F1 = fun(Node, ModAcc) ->
  -				      case refac_syntax:type(Node) of 
  -					  function ->
  -					      FunDef = Node, 
  -					      F2= fun (Node1, FunAcc) ->    
  -							  case refac_syntax:type(Node1) of 
  -							      application ->
  -								  case is_register_app(Node1) of 
  -								      true -> 
  -									  [RegName, _Pid] = refac_syntax:application_arguments(Node1),
  -									    Res = evaluate_expr(Files, ModName, AnnAST, FunDef, RegName),
  -									    Res++FunAcc;
  -									_ -> FunAcc
  -								    end; 
  -								_ ->  FunAcc
  -							    end
  -						    end,
  -					      refac_syntax_lib:fold(F2, [], FunDef)++ModAcc;
  -					  _-> ModAcc 
  -				      end
  -			      end,
  -			 refac_syntax_lib:fold(F1, [], AnnAST) ++ FileAcc;
  -		     {error, Reason} -> erlang:error({error, Reason})
  -		 end
  -	 end,			 
  +		{ok, {AnnAST, Info}} = refac_util:parse_annotate_file(File, true, DirList),
  +		{value, {module, ModName}} = lists:keysearch(module, 1, Info),
  +		F1 = fun(Node, ModAcc) ->
  +			     case refac_syntax:type(Node) of 
  +				 function ->
  +				     FunName = refac_syntax:data(refac_syntax:function_name(Node)),
  +				     Arity = refac_syntax:function_arity(Node),
  +				     F2= fun (Node1, FunAcc) ->    
  +						 case refac_syntax:type(Node1) of 
  +						     application ->
  +							 case is_register_app(Node1) of 
  +							     true -> 
  +								 [RegName, Pid] = refac_syntax:application_arguments(Node1),
  +								 RegNameValues = evaluate_expr(Files, ModName, AnnAST, Node, RegName),
  +								 RegNameValues1 = lists:map(fun(R) -> {pname, R} end, RegNameValues),
  +								 [{pid, {{ModName, FunName, Arity}, Pid}}|RegNameValues1++FunAcc];
  +							     _ -> FunAcc
  +							 end; 
  +						     _ ->  FunAcc
  +						 end
  +					 end,
  +				     refac_syntax_lib:fold(F2, [], Node)++ModAcc;
  +				 _-> ModAcc 
  +			     end
  +		     end,
  +		refac_syntax_lib:fold(F1, [], AnnAST) ++ FileAcc
  +	   end,			 
       Acc =lists:foldl(F, [], Files),
  -    {Names, UnKnowns} = lists:partition(fun({Tag,_V})-> Tag==value end, Acc),
  -    {lists:usort(lists:map(fun({value, P}) -> P end, Names)), lists:usort(UnKnowns)}.
  +    PNameAcc = lists:flatmap(fun({P,A}) -> if  P ==pname -> [A]; 
  +					       true -> []
  +					   end 
  +			     end, Acc), 
  +    PidAcc = lists:flatmap(fun({P,A}) -> if P == pid -> [A];
  +					true -> [] 
  +				     end 
  +		       end, Acc), 
  +    {Names, UnKnowns} = lists:partition(fun({Tag,_V})-> Tag==value end, PNameAcc),
  +    {PidAcc, {lists:usort(lists:map(fun({value, P}) -> P end, Names)), lists:usort(UnKnowns)}}.
       
   
   is_register_app(T) ->
  
positive.code: %%
  %% =====================================================================
  %%
  %% @doc This refactoring register a process id, Pid say, with a name, RegName say, and replace
  %% the uses of Pid ! Msg with  RegName ! Msg if possible.
  %% @end
  -module(refac_register_pid).
  
  -export([register_pid/5, register_pid_eclipse/5, register_pid_1/5, register_pid_2/5]).
  
  -export([get_call_graph/1]).
  
  -include("../hrl/wrangler.hrl").
  
  %% Rationale for this refactoring: If we want to send a message to a process, then we need to know its PID. This is often inconvenient since the 
  %% PID has to be sent to all the processes in the system that want to comminicate with this process. Registering a process with a name allows any 
  %% process in the system to communicate with this process without knowing its PID.
  %%
  %% To perform this refactoring, the user needs to select a match expression whose right-hand side is a spawn expression, and whose left-hand side 
  %% is a Pid variable.
  %%
  
  %% Side conditions for this refactorings:
  %% 1. The process name provided by the user should be lexically valid. (done).
  %% 2. The name provided by the user should not have been used as a process name. (need to handle dynamically create process names) (done).
  
  %% 2. The same process cannot be registered more than once. (check the registration of the generated Pid, and self()). (done).
  
  %% 3. At any time during the running of the system, only one process can be associated with a particular process name.  Since statically we 
  %% cannot decide when a process starts/dies, we use a rather stronger condition, that is the function containing the registration is only 
  
negative.code:    
  
  
  do_register(FName, AnnAST, MatchExpr, Pid, RegName, SearchPaths) ->
      Ann = refac_syntax:get_ann(Pid),
     {value, PidInfo} = lists:keysearch(pid, 1, Ann),
     {AnnAST1, Modified} = add_register_expr(AnnAST, MatchExpr, RegName),
     case Modified of 
         true ->  Res = refactor_send_exprs(FName, AnnAST1, PidInfo, RegName, SearchPaths),
  	       {ok, Res};	    
         _ -> {error, "Wrangler failed to add the registration expression."}
     end.
   
  
  
  refactor_send_exprs(FName, AnnAST, PidInfo, RegName, SearchPaths) ->
      {AnnAST1,_} = refac_util:stop_tdTP(fun do_refactor_send_exprs/2, AnnAST, {PidInfo, RegName}),
      %%This can be refined to check the client and parent modules of the current module.
      Files = refac_util:expand_files(SearchPaths, ".erl") -- [FName],
      Results = lists:flatmap(fun(File) ->
  				    io:format("The current file under refactoring is:\n~p\n",[File]),
  				    {ok, {AnnAST2, _Info}} = refac_util:parse_annotate_file(File, true, SearchPaths),
  				    {AnnAST3, Changed} = refac_util:stop_tdTP(fun do_refactor_send_exprs/2, AnnAST2, {PidInfo, RegName}),
  				    if Changed ->
  					    [{{File, File}, AnnAST3}];
  				       true -> []
  				    end
  			    end, Files),
      [{{FName, FName}, AnnAST1}|Results].
  
  do_refactor_send_exprs(Node, {PidInfo, RegName}) ->
       case refac_syntax:type(Node) of 
  	infix_expr -> Dest = refac_syntax:infix_expr_left(Node),
  		      Op = refac_syntax:infix_expr_operator(Node),
  		      Msg = refac_syntax:infix_expr_right(Node),
  