Example #1
0
        public void RemoveParamatersRefactoring_RemoveOnlyParam()
        {
            //Input
            const string inputCode =
                @"Private Sub Foo(ByVal arg1 As Integer)
End Sub";
            var selection = new Selection(1, 23, 1, 27); //startLine, startCol, endLine, endCol

            //Expectation
            const string expectedCode =
                @"Private Sub Foo()
End Sub";

            //Arrange
            SetupProject(inputCode);
            var parseResult = new RubberduckParser().Parse(_project.Object);

            var qualifiedSelection = GetQualifiedSelection(selection);

            //Specify Params to remove
            var model = new RemoveParametersModel(parseResult, qualifiedSelection);

            model.Parameters.ForEach(arg => arg.IsRemoved = true);

            //SetupFactory
            var factory = SetupFactory(model);

            //Act
            var refactoring = new RemoveParametersRefactoring(factory.Object);

            refactoring.Refactor(qualifiedSelection);

            //Assert
            Assert.AreEqual(expectedCode, _module.Object.Lines());
        }
Example #2
0
        public void RemoveParamatersRefactoring_RemoveFirstParam()
        {
            //Input
            const string inputCode =
                @"Private Sub Foo(ByVal arg1 As Integer, ByVal arg2 As String)
End Sub";
            var selection = new Selection(1, 23, 1, 27); //startLine, startCol, endLine, endCol

            //Expectation
            const string expectedCode =
                @"Private Sub Foo( ByVal arg2 As String)
End Sub"; //note: The IDE strips out the extra whitespace

            //Arrange
            SetupProject(inputCode);
            var parseResult = new RubberduckParser().Parse(_project.Object);

            var qualifiedSelection = GetQualifiedSelection(selection);

            //Specify Param(s) to remove
            var model = new RemoveParametersModel(parseResult, qualifiedSelection);

            model.Parameters[0].IsRemoved = true;

            //SetupFactory
            var factory = SetupFactory(model);

            //Act
            var refactoring = new RemoveParametersRefactoring(factory.Object);

            refactoring.Refactor(qualifiedSelection);

            //Assert
            Assert.AreEqual(expectedCode, _module.Object.Lines());
        }
        protected override void OnExecute(object parameter)
        {
            var selection = Vbe.GetActiveSelection();

            using (var view = new RemoveParametersDialog(new RemoveParametersViewModel(_state)))
            {
                var factory     = new RemoveParametersPresenterFactory(Vbe, view, _state, _msgbox);
                var refactoring = new RemoveParametersRefactoring(Vbe, factory, _rewritingManager);
                refactoring.Refactor(selection.Value);
            }
        }
Example #4
0
        private void RemoveParameter(QualifiedSelection selection)
        {
            var progress = new ParsingProgressPresenter();
            var result   = progress.Parse(_parser, IDE.ActiveVBProject);

            using (var view = new RemoveParametersDialog())
            {
                var factory     = new RemoveParametersPresenterFactory(_editor, view, result);
                var refactoring = new RemoveParametersRefactoring(factory);
                refactoring.Refactor(selection);
            }
        }
Example #5
0
        protected override void OnExecute(object parameter)
        {
            var activeSelection = SelectionService.ActiveSelection();

            if (!activeSelection.HasValue)
            {
                return;
            }

            var refactoring = new RemoveParametersRefactoring(_state, _factory, RewritingManager, SelectionService);

            refactoring.Refactor(activeSelection.Value);
        }
        public override void Execute(object parameter)
        {
            if (Vbe.ActiveCodePane == null)
            {
                return;
            }

            var selection = Vbe.ActiveCodePane.GetSelection();

            using (var view = new RemoveParametersDialog())
            {
                var factory     = new RemoveParametersPresenterFactory(Editor, view, _state, new MessageBox());
                var refactoring = new RemoveParametersRefactoring(factory, Editor);
                refactoring.Refactor(selection);
            }
        }
        protected override void ExecuteImpl(object parameter)
        {
            if (Vbe.ActiveCodePane == null)
            {
                return;
            }

            var selection = Vbe.ActiveCodePane.GetQualifiedSelection();

            using (var view = new RemoveParametersDialog())
            {
                var factory     = new RemoveParametersPresenterFactory(Vbe, view, _state, new MessageBox());
                var refactoring = new RemoveParametersRefactoring(Vbe, factory);
                refactoring.Refactor(selection.Value);
            }
        }
Example #8
0
        protected override void ExecuteImpl(object parameter)
        {
            var pane = Vbe.ActiveCodePane;

            if (pane.IsWrappingNullReference)
            {
                return;
            }

            var selection = pane.GetQualifiedSelection();

            using (var view = new RemoveParametersDialog(new RemoveParametersViewModel(_state)))
            {
                var factory     = new RemoveParametersPresenterFactory(Vbe, view, _state, _msgbox);
                var refactoring = new RemoveParametersRefactoring(Vbe, factory);
                refactoring.Refactor(selection.Value);
            }
        }