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); }
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); }
public RenameCommand( RenameRefactoring refactoring, RenameFailedNotifier renameFailedNotifier, IParserStatusProvider parserStatusProvider, IVbeEvents vbeEvents) : base(vbeEvents) { _refactoring = refactoring; _failureNotifier = renameFailedNotifier; _parserStatusProvider = parserStatusProvider; AddToCanExecuteEvaluation(SpecialEvaluateCanExecute); }
protected RefactoringQuickFixBase(IRefactoring refactoring, params Type[] inspections) : base(inspections) { Refactoring = refactoring; }
protected RefactorDeclarationCommandBase(IRefactoring refactoring, IRefactoringFailureNotifier failureNotifier, IParserStatusProvider parserStatusProvider) : base(refactoring, failureNotifier, parserStatusProvider) { }
public void Set(FileManager fm, IRefactoring r) { FileManager = fm; Refactoring = r; }