anchor.diff:  
   -compile(export_all).
   
  -input_par_prompts() ->
  -    ["WS operation name: ", 
  -     "WS operation arity: ", 
  -     "Index of parameter to be renamed: ",
  -     "New parameter name: "]. 
  +input_par_prompts() ->["New parameter name: "].
   
  -select_focus(_Args) ->
  -    {ok, none}.
  +select_focus(_Args=#args{current_file_name=File, 
  +                         cursor_pos=Pos}) ->
  +    Msg ="You have not selected an operation parameter!",
  +    case api_interface:pos_to_fun_def(File, Pos) of 
  +        {ok, FunDef} ->
  +            case  api_interface:pos_to_var_name(FunDef, Pos) of 
  +                {ok, {VarName, _}}->
  +                    {_M, F, A} = api_refac:fun_define_info(FunDef),
  +                    Index = collect_arg_index(FunDef, atom_to_list(F), atom_to_list(VarName)),
  +                    case Index of 
  +                        [] ->
  +                            throw({error, Msg});
  +                        [I] ->
  +                            {ok,{F,A,I}}
  +                    end;
  +                {error, _} ->
  +                    throw({error, Msg})
  +            end;
  +        {error, Msg} ->
  +            throw({error, Msg})
  +    end.
   
  +collect_arg_index(FunDef, OpName, VarName) ->
  +        ?STOP_TD_TU(
  +           [?COLLECT(?T("f@(Args1@@, OldVarName@, Args2@@) when Guards@@ -> Body@@;"),
  +                     length(Args1@@)+1,
  +                     ?PP(f@)==OpName andalso api_refac:type(OldVarName@) == variable  andalso
  +                     ?PP(OldVarName@)==VarName),
  +            ?COLLECT(?T("f@({Args1@@, OldVarName@, Args2@@}) when Guards@@ -> Body@@;"),
  +                     length(Args1@@)+1,
  +                     ?PP(f@)==OpName andalso api_refac:type(OldVarName@) == variable  andalso
  +                     ?PP(OldVarName@)==VarName)
  +           ],FunDef).
  +        
  + 
   composite_refac(_Args=#args{
                     current_file_name = File, 
  -                  user_inputs=[OpName, Arity0, Index0, NewParName]
  +                  focus_sel = {OpName0, Arity, Index},
  +                  user_inputs=[NewVarName]
                    }) ->
  -    Index=list_to_integer(Index0),
  -    Arity=list_to_integer(Arity0),
  -    Op = list_to_atom(OpName),
  +    OpName = atom_to_list(OpName0),
       Refacs = [ ?while(
                     begin
  -                      PreCands=collect_cands_in_precondition(File, OpName,Index, NewParName),
  +                      PreCands=collect_cands_in_precondition(File, OpName, Index,NewVarName),
                         {PreCands/=[], PreCands}
                     end,
  -                  fun([{{Start, End}, OldVarName}|_]) ->
  +                  fun([{Loc, OldVarName1}|_]) ->
                             ?refac_(rename_var,
  -                                  [File, {precondition, 2}, {range, {File, [{Start, End}]}, OldVarName}, 
  -                                   mk_new_par_name(OldVarName, NewParName), [File]])
  +                                  [File, {precondition, 2}, {range, {File, [Loc]}, OldVarName1}, 
  +                                   mk_new_par_name(OldVarName1, NewVarName), [File]])
                     end
                    ),
                  ?while(
  -                  begin
  -                      PostCands=collect_cands_in_postcondition(File, OpName,Index, NewParName),
  -                      {PostCands/=[], PostCands}
  -                  end,
  -                  fun([{Loc, OldVarName}|_])->
  +                   begin
  +                       PreCands=collect_cands_in_postcondition(File, OpName, Index, NewVarName),
  +                       {PreCands/=[], PreCands}
  +                   end,
  +                   fun([{Loc, OldVarName1}|_]) ->
  +                           ?refac_(rename_var,
  +                                   [File, {postcondition, 3}, {range, {File, [Loc]}, OldVarName1}, 
  +                                    mk_new_par_name(OldVarName1, NewVarName), [File]])
  +                   end
  +               ),
  +               ?while(
  +                   begin
  +                       NextCands=collect_cands_in_nextstate(File, OpName, Index, NewVarName),
  +                       {NextCands/=[], NextCands}
  +                   end,
  +                  fun([{{Start, End}, OldVarName1}|_]) ->
                             ?refac_(rename_var,
  -                                  [File, {postcondition, 3},  {range, {File, [Loc]}, OldVarName}, 
  -                                   mk_new_par_name(OldVarName, NewParName), [File]])
  +                                  [File, {next_state, 3}, {range, {File, [{Start, End}]}, OldVarName1}, 
  +                                   mk_new_par_name(OldVarName1, NewVarName), [File]])
                     end
                    ),
                  ?while(
  -                  begin
  -                      NextCands=collect_cands_in_nextstate(File, OpName,Index, NewParName),
  -                      {NextCands/=[], NextCands}
  -                  end,
  -                  fun([{Loc, OldVarName}|_])->
  +                   begin
  +                       NextCands=collect_cands_in_op(File, OpName, Index, NewVarName),
  +                       {NextCands/=[], NextCands}
  +                   end,
  +                  fun([{{Start, End}, OldVarName1}|_]) ->
                             ?refac_(rename_var,
  -                                  [File, {next_state, 3},  {range, {File, [Loc]}, OldVarName}, 
  -                                   mk_new_par_name(OldVarName, NewParName), [File]])
  -                  end
  -                 ),
  -               ?while(
  -                  begin
  -                      OpCands=collect_cands_in_op(File, OpName,Index, NewParName),
  -                      {OpCands/=[], OpCands}
  -                   end,
  -                   fun([{Loc, OldVarName}|_])->
  -                           ?refac_(rename_var,
  -                                   [File, {Op, Arity},  {range, {File, [Loc]}, OldVarName}, 
  -                                     mk_new_par_name(OldVarName, NewParName), [File]])
  +                                  [File, {OpName, Arity}, {range, {File, [{Start, End}]}, OldVarName1}, 
  +                                   mk_new_par_name(OldVarName1, NewVarName), [File]])
                      end
  -                  )               
  +                  )
                ],                
  -        ?non_atomic(Refacs).
  +    ?non_atomic(Refacs).
   
   
   mk_new_par_name(_OldParName=[95|_], NewParName) ->
  
positive.code: %%@hidden
  %%@private
  -module(refac_rename_op_arg).
  
negative.code:     NewParName.
  
  
  collect_cands_in_precondition(File, OpName, Index, NewVarName) ->
      ?STOP_TD_TU(
         [?COLLECT(?T("precondition(S@, {call, ?MODULE, OpName@, [Args@@]}) when Guards@@ -> Body@@;"),
                    {api_refac:start_end_loc(lists:nth(Index, Args@@)), ?PP(lists:nth(Index, Args@@))},
                    ?PP(OpName@)==OpName andalso api_refac:type(lists:nth(Index,Args@@))==variable andalso
                   not lists:member(?PP(lists:nth(Index,Args@@)), [NewVarName, "_"++NewVarName])),
          ?COLLECT(?T("precondition(S@, {call, ?MODULE, OpName@, [{Args@@}]}) when Guards@@ -> Body@@;"),
                    {api_refac:start_end_loc(lists:nth(Index, Args@@)), ?PP(lists:nth(Index, Args@@))},
                    ?PP(OpName@)==OpName andalso api_refac:type(lists:nth(Index,Args@@))==variable andalso
                    not lists:member(?PP(lists:nth(Index,Args@@)), [NewVarName, "_"++NewVarName]))
         ],[File]).
  
  
  collect_cands_in_postcondition(File, OpName, Index, NewVarName) ->
      ?STOP_TD_TU(
         [?COLLECT(?T("postcondition(S@, {call, ?MODULE, OpName@, [Args@@]}, Res@) when Guards@@ -> Body@@;"),
                    {api_refac:start_end_loc(lists:nth(Index, Args@@)), ?PP(lists:nth(Index, Args@@))},
                    ?PP(OpName@)==OpName andalso api_refac:type(lists:nth(Index,Args@@))==variable andalso
                   not lists:member(?PP(lists:nth(Index,Args@@)), [NewVarName, "_"++NewVarName])),
          ?COLLECT(?T("postcondition(S@, {call, ?MODULE, OpName@, [{Args@@}]}, Res@) when Guards@@ -> Body@@;"),
                    {api_refac:start_end_loc(lists:nth(Index, Args@@)), ?PP(lists:nth(Index, Args@@))},
                    ?PP(OpName@)==OpName andalso api_refac:type(lists:nth(Index,Args@@))==variable andalso
                    not lists:member(?PP(lists:nth(Index,Args@@)), [NewVarName, "_"++NewVarName]))
         ],[File]).
  
  
  collect_cands_in_nextstate(File, OpName, Index, NewVarName) ->
      ?STOP_TD_TU(
         [?COLLECT(?T("next_state(S@, R@, {call, ?MODULE, OpName@, [Args@@]}) when Guards@@ -> Body@@;"),
                    {api_refac:start_end_loc(lists:nth(Index, Args@@)), ?PP(lists:nth(Index, Args@@))},
                    ?PP(OpName@)==OpName andalso api_refac:type(lists:nth(Index,Args@@))==variable andalso
                   not lists:member(?PP(lists:nth(Index,Args@@)), [NewVarName, "_"++NewVarName])),
          ?COLLECT(?T("next_state(S@, R@, {call, ?MODULE, OpName@, [{Args@@}]}) when Guards@@ -> Body@@;"),
                    {api_refac:start_end_loc(lists:nth(Index, Args@@)), ?PP(lists:nth(Index, Args@@))},
                    ?PP(OpName@)==OpName andalso api_refac:type(lists:nth(Index,Args@@))==variable andalso
                    not lists:member(?PP(lists:nth(Index,Args@@)), [NewVarName, "_"++NewVarName]))
         ],[File]).
  
  
  collect_cands_in_op(File, OpName, Index, NewVarName) ->
       ?STOP_TD_TU(
          [?COLLECT(?T("f@(Args@@) when Guards@@ -> Body@@;"),
                    {api_refac:start_end_loc(lists:nth(Index, Args@@)), ?PP(lists:nth(Index, Args@@))},
                    ?PP(f@)==OpName andalso api_refac:type(lists:nth(Index,Args@@))==variable andalso
                    not lists:member(?PP(lists:nth(Index,Args@@)), [NewVarName, "_"++NewVarName])),
           ?COLLECT(?T("f@({Args@@}) when Guards@@ -> Body@@;"),
                    {api_refac:start_end_loc(lists:nth(Index, Args@@)), ?PP(lists:nth(Index, Args@@))},
                    ?PP(f@)==OpName andalso api_refac:type(lists:nth(Index,Args@@))==variable andalso
                    not lists:member(?PP(lists:nth(Index,Args@@)), [NewVarName, "_"++NewVarName]))
          ],[File]).
          
  