예제 #1
0
        public bool UpdateRot(string file, ITextSnapshot snapshot)
        {
            if (String.IsNullOrEmpty(file) || _activePeekSession == null || !_activePeekSession.ContainsKey(file))
            {
                return(false);
            }
            var    session = _activePeekSession[file];
            string expanded;
            var    position = session.TriggerPoint.GetPosition(snapshot);
            var    tra      = new TacticReplacerActor(snapshot.TextBuffer, position);
            var    name     = tra.GetActiveTacticName();

            if (name != session.ActiveTactic)
            {
                session.Updater?.Invoke(null);
            }
            if (tra.LoadStatus != TacticReplaceStatus.Success)
            {
                return(NotifyOfReplacement(tra.LoadStatus));
            }
            var status = tra.ExpandSingleTacticCall(position, out expanded);

            if (status != TacticReplaceStatus.Success)
            {
                return(NotifyOfReplacement(status));
            }
            session.ExpandedTactic = expanded;
            session.Updater?.Invoke(expanded);
            return(true);
        }
예제 #2
0
        public bool ShowRot(IWpfTextView atv)
        {
            Contract.Assume(atv != null);

            string expanded;
            var    caret        = atv.Caret.Position.BufferPosition.Position;
            var    triggerPoint = atv.TextBuffer.CurrentSnapshot.CreateTrackingPoint(caret, PointTrackingMode.Positive);
            var    tra          = new TacticReplacerActor(atv.TextBuffer, caret);

            if (tra.LoadStatus != TacticReplaceStatus.Success)
            {
                return(NotifyOfReplacement(tra.LoadStatus));
            }
            var status = tra.ExpandSingleTacticCall(caret, out expanded);

            if (status != TacticReplaceStatus.Success)
            {
                return(NotifyOfReplacement(status));
            }

            string file;
            var    fileLoaded = RefactoringUtil.LoadAndCheckDocument(atv.TextBuffer, out file);

            if (!fileLoaded)
            {
                return(NotifyOfReplacement(TacticReplaceStatus.NoDocumentPersistence));
            }

            var session = _pb.CreatePeekSession(new PeekSessionCreationOptions(atv, RotPeekRelationship.SName, triggerPoint, 0, false, null, false));

            _activePeekSession.Remove(file);
            _activePeekSession.Add(file, new ActivePeekSessionData {
                TriggerPoint   = triggerPoint,
                ExpandedTactic = expanded,
                ActiveTactic   = tra.GetActiveTacticName()
            });
            session.Start();
            return(NotifyOfReplacement(TacticReplaceStatus.Success));
        }
예제 #3
0
    public bool ShowRot(IWpfTextView atv)
    {
      Contract.Assume(atv != null);

      string expanded;
      var caret = atv.Caret.Position.BufferPosition.Position;
      var triggerPoint = atv.TextBuffer.CurrentSnapshot.CreateTrackingPoint(caret, PointTrackingMode.Positive);
      var tra = new TacticReplacerActor(atv.TextBuffer, caret);
      if (tra.LoadStatus != TacticReplaceStatus.Success) return NotifyOfReplacement(tra.LoadStatus);
      var status = tra.ExpandSingleTacticCall(caret, out expanded);
      if (status != TacticReplaceStatus.Success)
        return NotifyOfReplacement(status);
      
      string file;
      var fileLoaded = RefactoringUtil.LoadAndCheckDocument(atv.TextBuffer, out file);
      if (!fileLoaded) return NotifyOfReplacement(TacticReplaceStatus.NoDocumentPersistence);
      
      var session = _pb.CreatePeekSession(new PeekSessionCreationOptions(atv, RotPeekRelationship.SName, triggerPoint, 0, false, null, false));
      _activePeekSession.Remove(file);
      _activePeekSession.Add(file, new ActivePeekSessionData {
        TriggerPoint = triggerPoint,
        ExpandedTactic = expanded,
        ActiveTactic = tra.GetActiveTacticName()
      });
      session.Start();
      return NotifyOfReplacement(TacticReplaceStatus.Success);
    }
예제 #4
0
 public bool UpdateRot(string file, ITextSnapshot snapshot)
 {
   if (String.IsNullOrEmpty(file) || _activePeekSession==null || !_activePeekSession.ContainsKey(file)) return false;
   var session = _activePeekSession[file];
   string expanded;
   var position = session.TriggerPoint.GetPosition(snapshot);
   var tra = new TacticReplacerActor(snapshot.TextBuffer, position);
   var name = tra.GetActiveTacticName();
   if(name!=session.ActiveTactic) session.Updater?.Invoke(null);
   if (tra.LoadStatus != TacticReplaceStatus.Success) return NotifyOfReplacement(tra.LoadStatus);
   var status = tra.ExpandSingleTacticCall(position, out expanded);
   if (status != TacticReplaceStatus.Success)
     return NotifyOfReplacement(status);
   session.ExpandedTactic = expanded;
   session.Updater?.Invoke(expanded);
   return true;
 }