Exemple #1
0
        public override Task <IEnumerable <SuggestedActionSet> > GetActionSetsAsync(CancellationToken cancellationToken)
        {
            var list = new List <SuggestedActionSet>();

            var addMissingRulesActionAll = new AddMissingRulesActionAll(_missingRules, _document, _view);

            List <Keyword> missingRulesDotNet = FindMissingRulesSpecific(Category.DotNet);
            List <Keyword> missingRulesCSharp = FindMissingRulesSpecific(Category.CSharp);
            List <Keyword> missingRulesVB     = FindMissingRulesSpecific(Category.VisualBasic);

            AddMissingRulesActionDotNet addMissingRulesActionDotNet = null;
            AddMissingRulesActionCSharp addMissingRulesActionCSharp = null;
            AddMissingRulesActionVB     addMissingRulesActionVB     = null;

            if (missingRulesDotNet.Count() != 0)
            {
                addMissingRulesActionDotNet = new AddMissingRulesActionDotNet(missingRulesDotNet, _document, _view);
            }
            if (missingRulesCSharp.Count() != 0)
            {
                addMissingRulesActionCSharp = new AddMissingRulesActionCSharp(missingRulesCSharp, _document, _view);
            }
            if (missingRulesVB.Count() != 0)
            {
                addMissingRulesActionVB = new AddMissingRulesActionVB(missingRulesVB, _document, _view);
            }

            list.AddRange(CreateActionSet(addMissingRulesActionAll, addMissingRulesActionDotNet, addMissingRulesActionCSharp, addMissingRulesActionVB));
            return(Task.FromResult <IEnumerable <SuggestedActionSet> >(list));
        }
        public override void Execute(CancellationToken cancellationToken)
        {
            SnapshotPoint caretPost = _view.Caret.Position.BufferPosition;

            using (ITextEdit edit = _view.TextBuffer.CreateEdit())
            {
                AddMissingRulesActionAll.AddMissingRules(_document, _missingRules, edit);

                if (edit.HasEffectiveChanges)
                {
                    edit.Apply();
                }
            }

            _view.Caret.MoveTo(new SnapshotPoint(_view.TextBuffer.CurrentSnapshot, caretPost));
        }