Beispiel #1
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(NotifyOfReplacement(replaceStatus));
        }
Beispiel #2
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(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(NotifyOfReplacement(status));
        }
Beispiel #3
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 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 NotifyOfReplacement(status);
 }
Beispiel #4
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 NotifyOfReplacement(replaceStatus);
    }