예제 #1
0
        public void Register(IRefactoring refactoring)
        {
            Contract.Requires(refactoring != null);

            var context = this;

            try {
                CancellationTokenExtensions.SetCancellationToken(context._originalContext.CancellationToken);

                var newRoot  = refactoring.ComputeRoot(context.Root);
                var document = context.Document.WithSyntaxRoot(newRoot);

                if (ProducedEquivalent(context.Root, newRoot))
                {
                    document = context.Document;
                }

                var codeAction = CodeAction.Create(refactoring.Description, async c => document);
                _originalContext.RegisterRefactoring(codeAction);
            }
            catch (OperationCanceledException) {
                throw;
            }
            catch (Exception) {
                if (Settings.Instance.CanThrow)
                {
                    throw;
                }
                // TODO: add logging
            }
        }
        protected RefactorCommandBase(IRefactoring refactoring, IRefactoringFailureNotifier failureNotifier, IParserStatusProvider parserStatusProvider)
        {
            Refactoring          = refactoring;
            ParserStatusProvider = parserStatusProvider;
            FailureNotifier      = failureNotifier;

            AddToCanExecuteEvaluation(SpecialEvaluateCanExecute);
        }
예제 #3
0
        public void RegisterAsync(IRefactoring refactoring)
        {
            Contract.Requires(refactoring != null);

            Register(GetCodeAction(
                         title: refactoring.Description,
                         getRoot: (root, c) => Task.Run(() => refactoring.ComputeRoot(root), c),
                         context: this));
        }
        protected RefactorCodePaneCommandBase(
            IRefactoring refactoring,
            IRefactoringFailureNotifier failureNotifier,
            ISelectionProvider selectionProvider,
            IParserStatusProvider parserStatusProvider)
            : base(refactoring, failureNotifier, parserStatusProvider)
        {
            SelectionProvider = selectionProvider;

            AddToCanExecuteEvaluation(SpecializedEvaluateCanExecute);
        }
예제 #5
0
        public RenameCommand(
            RenameRefactoring refactoring,
            RenameFailedNotifier renameFailedNotifier,
            IParserStatusProvider parserStatusProvider,
            IVbeEvents vbeEvents)
            : base(vbeEvents)
        {
            _refactoring          = refactoring;
            _failureNotifier      = renameFailedNotifier;
            _parserStatusProvider = parserStatusProvider;

            AddToCanExecuteEvaluation(SpecialEvaluateCanExecute);
        }
예제 #6
0
 protected RefactoringQuickFixBase(IRefactoring refactoring, params Type[] inspections)
     : base(inspections)
 {
     Refactoring = refactoring;
 }
 protected RefactorDeclarationCommandBase(IRefactoring refactoring, IRefactoringFailureNotifier failureNotifier, IParserStatusProvider parserStatusProvider)
     : base(refactoring, failureNotifier, parserStatusProvider)
 {
 }
예제 #8
0
 public void Set(FileManager fm, IRefactoring r)
 {
     FileManager = fm;
     Refactoring = r;
 }