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)); }
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)); }
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); }
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); }