Ejemplo n.º 1
0
        public TacticReplaceStatus SetMember(int position)
        {
            var status = RefactoringUtil.GetMemberFromPosition(_tld, position, out _member);

            _tacticCalls = RefactoringUtil.GetTacticCallsInMember(_member as Method);
            return(status);
        }
Ejemplo n.º 2
0
        private void ProcessSomeMembers()
        {
            Begin();
            var p = RefactoringUtil.GetNewProgram(_tb);

            if (p == null)
            {
                NotifyStatusbar(DeadAnnotationStatus.NoProgram);
                Finish();
                return;
            }
            UpdateFilename(p.FullName);
            var notProcessedMembers = new List <MemberDecl>();
            var tld = RefactoringUtil.GetTld(p);

            _changesSinceLastSuccessfulRun.ForEach(i => {
                MemberDecl md;
                RefactoringUtil.GetMemberFromPosition(tld, i, out md);
                if (md != null && !notProcessedMembers.Contains(md))
                {
                    notProcessedMembers.Add(md);
                }
            });
            if (tld == null || notProcessedMembers.Count == 0)
            {
                NotifyStatusbar(DeadAnnotationStatus.NoChanges);
                Finish();
                return;
            }
            _thread = new Thread(ProcessSomeMembersThreaded);
            _thread.Start(new ThreadParams {
                P = p, M = notProcessedMembers, S = Snapshot, Stop = _currentStopper
            });
        }
Ejemplo n.º 3
0
        public IEnumerable <SuggestedActionSet> GetSuggestedActions(ISuggestedActionCategorySet requestedActionCategories, SnapshotSpan range, CancellationToken cancellationToken)
        {
            var actionList      = new List <ISuggestedAction>();
            var currentSnapshot = range.Snapshot;

            var first = _agg.GetTags(range).FirstOrDefault();

            if (first != null)
            {
                actionList.Add(new RemoveDeadAnnotationSuggestedAction(currentSnapshot, first.Tag));
            }

            Program p;

            RefactoringUtil.GetExistingProgram(currentSnapshot.TextBuffer, out p);
            if (p == null)
            {
                return(Enumerable.Empty <SuggestedActionSet>());
            }
            var        tld = RefactoringUtil.GetTld(p);
            MemberDecl md;

            RefactoringUtil.GetMemberFromPosition(tld, range.Start, out md);
            if (md != null)
            {
                var methodSpan = RefactoringUtil.GetRangeOfMember(currentSnapshot, md);
                var tagSpans   = _agg.GetTags(methodSpan);
                var tags       = (from ts in tagSpans
                                  select new RemoveDeadAnnotationSuggestedAction(currentSnapshot, ts.Tag)).ToList();
                if (tags.Count > 0)
                {
                    actionList.Add(new RemoveMultipleDeadAnnotationsSuggestedAction(currentSnapshot.TextBuffer, tags, DeadAnnotationLocation.Block));
                }
            }

            var snapshotWideSpan = new SnapshotSpan(currentSnapshot, 0, currentSnapshot.Length);
            var allTags          = _agg.GetTags(snapshotWideSpan);
            var list             = allTags.Select(ts => new RemoveDeadAnnotationSuggestedAction(currentSnapshot, ts.Tag)).ToList();

            if (list.Count > 0)
            {
                actionList.Add(new RemoveMultipleDeadAnnotationsSuggestedAction(currentSnapshot.TextBuffer, list, DeadAnnotationLocation.File));
            }

            return(actionList.Count > 0 ?
                   new [] { new SuggestedActionSet(actionList.ToArray()) }
        : Enumerable.Empty <SuggestedActionSet>());
        }