protected override void RefactorImpl(RemoveParametersModel model)
        {
            if (model.TargetDeclaration == null)
            {
                throw new TargetDeclarationIsNullException();
            }

            _refactoringAction.Refactor(model);
        }
Beispiel #2
0
        public override void Refactor(QualifiedSelection target)
        {
            var targetInterface = _declarationFinderProvider.DeclarationFinder.FindInterface(target);

            if (targetInterface == null)
            {
                throw new NoImplementsStatementSelectedException(target);
            }

            var targetModule = _declarationFinderProvider.DeclarationFinder
                               .ModuleDeclaration(target.QualifiedName);

            if (!ImplementingModuleTypes.Contains(targetModule.DeclarationType))
            {
                throw new InvalidDeclarationTypeException(targetModule);
            }

            var targetClass = targetModule as ClassModuleDeclaration;

            if (targetClass == null)
            {
                //This really should never happen. If it happens the declaration type enum value
                //and the type of the declaration are inconsistent.
                throw new InvalidTargetDeclarationException(targetModule);
            }

            var model = Model(targetInterface, targetClass);

            _refactoringAction.Refactor(model);
        }
Beispiel #3
0
        protected override void OnExecute(object parameter)
        {
            if (!(parameter is System.ValueTuple <IAnnotation, ICodeExplorerNode> data))
            {
                return;
            }

            var(annotation, node) = data;
            var target = node?.Declaration;

            try
            {
                var model = ModelFromParameter(annotation, target);
                if (!annotation.AllowedArguments.HasValue ||
                    annotation.AllowedArguments.Value > 0 ||
                    annotation is IAttributeAnnotation)
                {
                    model = _userInteraction.UserModifiedModel(model);
                }

                _annotateAction.Refactor(model);
            }
            catch (RefactoringAbortedException)
            {}
            catch (RefactoringException exception)
            {
                _failureNotifier.Notify(exception);
            }
        }
Beispiel #4
0
        private void PromoteVariable(Declaration target)
        {
            if (!PromptIfMethodImplementsInterface(target))
            {
                return;
            }

            var model = Model(target);

            _refactoringAction.Refactor(model);
        }
        public void Refactor(RenameModel model)
        {
            if (model?.Target == null ||
                model.Target.IdentifierName.Equals(model.NewName, StringComparison.InvariantCultureIgnoreCase))
            {
                return;
            }

            if (IsComponentOrProjectTarget(model))
            {
                _renameComponentOrProjectRefactoringAction.Refactor(model);
            }
            else
            {
                _renameCodeDefinedIdentifierRefactoringAction.Refactor(model);
            }
        }
Beispiel #6
0
        protected override void OnExecute(object parameter)
        {
            if (!CanExecute(parameter))
            {
                return;
            }

            try
            {
                var model = ModelFromParameter(parameter);
                ValidateModel(model);
                _refactoringAction.Refactor(model);
            }
            catch (RefactoringAbortedException)
            { }
            catch (RefactoringException exception)
            {
                _failureNotifier.Notify(exception);
            }
        }
 private static void ExecuteRefactoringAction <TModel>(
     TModel model,
     object parameter,
     Action <TModel> initialModelValidation,
     Func <TModel, object, TModel> modelModification,
     IRefactoringAction <TModel> refactoringAction,
     IRefactoringFailureNotifier failureNotifier)
     where TModel : class, IRefactoringModel
 {
     try
     {
         initialModelValidation(model);
         var modifiedModel = modelModification(model, parameter);
         refactoringAction.Refactor(modifiedModel);
     }
     catch (RefactoringAbortedException)
     {}
     catch (RefactoringException exception)
     {
         failureNotifier.Notify(exception);
     }
 }
Beispiel #8
0
        private void PromoteVariable(Declaration target)
        {
            var model = Model(target);

            _refactoringAction.Refactor(model);
        }
Beispiel #9
0
 protected override void RefactorImpl(ExtractInterfaceModel model)
 {
     _refactoringAction.Refactor(model);
 }
        private void MoveCloserToUsage(Declaration target)
        {
            var model = Model(target);

            _refactoringAction.Refactor(model);
        }
 protected override void RefactorImpl(MoveMultipleFoldersModel model)
 {
     ValidateModel(model);
     _moveFoldersAction.Refactor(model);
 }
 protected override void RefactorImpl(AnnotateDeclarationModel model)
 {
     _annotateDeclarationAction.Refactor(model);
 }
Beispiel #13
0
 protected override void RefactorImpl(RenameModel model)
 {
     _refactoringAction.Refactor(model);
 }
Beispiel #14
0
 protected override void RefactorImpl(ReorderParametersModel model)
 {
     _refactoringAction.Refactor(model);
 }