Beispiel #1
0
 public bool ReplaceOneCall(IWpfTextView atv)
 {
   Contract.Assume(atv != null);
   var caret = atv.Caret.Position.BufferPosition.Position;
   var tra = new TacticReplacerActor(atv.TextBuffer, caret);
   if (tra.LoadStatus != TacticReplaceStatus.Success)  return Util.NotifyOfReplacement(tra.LoadStatus);
   var tedit = atv.TextBuffer.CreateEdit();
   var status = TacticReplaceStatus.TranslatorFail;
   try {
     status = tra.ReplaceSingleTacticCall(tedit);
     if (status == TacticReplaceStatus.Success) { tedit.Apply(); } else { tedit.Dispose(); }
   } catch {  tedit.Dispose(); }
   return Util.NotifyOfReplacement(status);
 }
Beispiel #2
0
    public bool ShowRot(IWpfTextView atv)
    {
      Contract.Assume(atv != null);

      string testString;
      var caret = atv.Caret.Position.BufferPosition.Position;
      var tra = new TacticReplacerActor(atv.TextBuffer, caret);
      if (tra.LoadStatus != TacticReplaceStatus.Success) return Util.NotifyOfReplacement(tra.LoadStatus);
      var status = tra.ExpandSingleTacticCall(caret, out testString);
      if (status != TacticReplaceStatus.Success)
        return Util.NotifyOfReplacement(status);
      
      _pb.TriggerPeekSession(new PeekSessionCreationOptions(atv, RotPeekRelationship.SName, null, 0, false, null, false));
      return Util.NotifyOfReplacement(TacticReplaceStatus.Success);
    }
Beispiel #3
0
 public static string GetExpandedForRot(int position, ITextBuffer tb)
 {
   Contract.Assume(tb != null);
   string fullMethod;
   var tra = new TacticReplacerActor(tb, position);
   return tra.ExpandSingleTacticCall(position, out fullMethod)==TacticReplaceStatus.Success ? fullMethod : null;
   //var splitMethod = fullMethod.Split('\n');
   //return splitMethod.Where((t, i) => i >= 2 && i <= splitMethod.Length - 3).Aggregate("", (current, t) => current + t + "\n");
 }
Beispiel #4
0
    public static string GetExpandedForPreview(int position, ITextBuffer buffer, ref SnapshotSpan methodName)
    {
      Contract.Assume(buffer != null);
      var tra = new TacticReplacerActor(buffer, position);
      if (!tra.MemberReady) return null;

      methodName = new SnapshotSpan(buffer.CurrentSnapshot, tra.MemberNameStart, tra.MemberName.Length);
      string expanded;
      tra.ExpandTactic(out expanded);
      return expanded;
    }
Beispiel #5
0
    public bool ReplaceAll(ITextBuffer tb)
    {
      Contract.Assume(tb != null);

      var tra = new TacticReplacerActor(tb);
      var isMoreMembers = tra.NextMemberInTld();
      var replaceStatus = TacticReplaceStatus.Success;
      var tedit = tb.CreateEdit();
      try
      {
        while (isMoreMembers && (replaceStatus == TacticReplaceStatus.Success || replaceStatus == TacticReplaceStatus.NoTactic))
        {
          var isMoreTactics = tra.NextTacticCallInMember();
          while (isMoreTactics && (replaceStatus == TacticReplaceStatus.Success || replaceStatus == TacticReplaceStatus.NoTactic))
          {
            replaceStatus = tra.ReplaceSingleTacticCall(tedit);
            isMoreTactics = tra.NextTacticCallInMember();
          }
          isMoreMembers = tra.NextMemberInTld();
        }

        if(replaceStatus==TacticReplaceStatus.Success || replaceStatus == TacticReplaceStatus.NoTactic)
          { tedit.Apply();} else { tedit.Dispose();}
      } catch { tedit.Dispose(); }
      return Util.NotifyOfReplacement(replaceStatus);
    }