Beispiel #1
0
        public TacticReplacerActor(ITextBuffer tb, int position = -1)
        {
            Contract.Requires(tb != null);
            string currentFileName;

            LoadStatus = RefactoringUtil.LoadAndCheckDocument(tb, out currentFileName) ? TacticReplaceStatus.Success : TacticReplaceStatus.NoDocumentPersistence;
            if (LoadStatus != TacticReplaceStatus.Success)
            {
                return;
            }
            var program = RefactoringUtil.GetReparsedProgram(tb, currentFileName, true);

            _tld        = RefactoringUtil.GetTld(program);
            _tldMembers = _tld?.Members.GetEnumerator();
            LoadStatus  = _tld != null ? TacticReplaceStatus.Success : TacticReplaceStatus.NotResolved;
            if (LoadStatus != TacticReplaceStatus.Success)
            {
                return;
            }
            if (position == -1)
            {
                return;
            }
            SetMember(position);
            SetTacticCall(position);
        }
Beispiel #2
0
        public void AddUpdaterForRot(IPeekSession session, Action <string> recalculate)
        {
            string file;
            var    fileLoaded = RefactoringUtil.LoadAndCheckDocument(session.TextView.TextBuffer, out file);

            if (fileLoaded && _activePeekSession != null && _activePeekSession.ContainsKey(file))
            {
                _activePeekSession[file].Updater = recalculate;
            }
        }
Beispiel #3
0
        public Tuple <string, string> GetExpandedForPeekSession(IPeekSession session)
        {
            string file;
            var    status = RefactoringUtil.LoadAndCheckDocument(session.TextView.TextBuffer, out file);

            if (!status)
            {
                return(null);
            }
            var storedSessionData = _activePeekSession[file];

            return(new Tuple <string, string>(storedSessionData.ExpandedTactic, storedSessionData.ActiveTactic));
        }
Beispiel #4
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));
        }
Beispiel #5
0
        public bool ClearPeekSession(IPeekSession session)
        {
            string file;

            return(RefactoringUtil.LoadAndCheckDocument(session.TextView.TextBuffer, out file) && _activePeekSession.Remove(file));
        }