コード例 #1
0
ファイル: TacticReplacer.cs プロジェクト: ggrov/dafny
        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);
        }
コード例 #2
0
ファイル: TacticReplacer.cs プロジェクト: ggrov/dafny
        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;
            }
        }
コード例 #3
0
ファイル: TacticReplacer.cs プロジェクト: ggrov/dafny
        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));
        }
コード例 #4
0
ファイル: TacticReplacer.cs プロジェクト: ggrov/dafny
        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));
        }
コード例 #5
0
ファイル: TacticReplacer.cs プロジェクト: ggrov/dafny
        public bool ClearPeekSession(IPeekSession session)
        {
            string file;

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