예제 #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());
        }
예제 #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());
        }
예제 #3
0
        public void Initialize(VBE vbe)
        {
            if (_parser != null)
            {
                throw new InvalidOperationException("ParserState is already initialized.");
            }

            _parser = new RubberduckParser(vbe, _state, _attributeParser);
        }
예제 #4
0
        public void Initialize(VBE vbe)
        {
            if (_parser != null)
            {
                throw new InvalidOperationException("ParserState is already initialized.");
            }
            Func <IVBAPreprocessor> preprocessorFactory = () => new VBAPreprocessor(double.Parse(vbe.Version, CultureInfo.InvariantCulture));

            _attributeParser = new AttributeParser(new ModuleExporter(), preprocessorFactory);
            _parser          = new RubberduckParser(vbe, _state, _attributeParser, preprocessorFactory);
        }
예제 #5
0
        public App(VBE vbe, AddIn addIn)
        {
            _configService = new ConfigurationLoader();
            _inspections   = _configService.GetImplementedCodeInspections();

            var config = _configService.LoadConfiguration();

            EnableCodeInspections(config);
            var parser = new RubberduckParser();

            var inspector = new Inspector(parser, _inspections);

            _menu = new RubberduckMenu(vbe, addIn, _configService, parser, inspector);
            _codeInspectionsToolbar = new CodeInspectionsToolbar(vbe, inspector);
        }
예제 #6
0
        public void Initialize(VBE vbe)
        {
            if (_parser != null)
            {
                throw new InvalidOperationException("ParserState is already initialized.");
            }

            _state = new RubberduckParserState(new Sinks(vbe));
            _state.StateChanged += _state_StateChanged;

            Func <IVBAPreprocessor> preprocessorFactory = () => new VBAPreprocessor(double.Parse(vbe.Version, CultureInfo.InvariantCulture));

            _attributeParser = new AttributeParser(new ModuleExporter(), preprocessorFactory);
            _parser          = new RubberduckParser(vbe, _state, _attributeParser, preprocessorFactory,
                                                    new List <ICustomDeclarationLoader> {
                new DebugDeclarations(_state), new FormEventDeclarations(_state), new AliasDeclarations(_state)
            });
        }
예제 #7
0
        public void TodoPresenter_RefreshUpdatesViewItems()
        {
            var code = @"
Public Sub Bazzer()
    'Todo: Fix the foobarred bazzer.
End Sub";

            var codeModule = RdMockFacotry.CreateCodeModuleMock(code);

            var component = RdMockFacotry.CreateComponentMock("Module1", codeModule.Object, vbext_ComponentType.vbext_ct_StdModule);

            var project = RdMockFacotry.CreateProjectMock("VBAProject", vbext_ProjectProtection.vbext_pp_none);

            var componentList = new List <VBComponent>()
            {
                component.Object
            };
            var components = RdMockFacotry.CreateComponentsMock(componentList, project.Object);

            component.SetupGet(c => c.Collection).Returns(components.Object);

            var projectList = new List <VBProject>()
            {
                project.Object
            };

            var projects = RdMockFacotry.CreateProjectsMock(projectList);

            project.SetupGet(p => p.VBComponents).Returns(components.Object);

            _vbe = RdMockFacotry.CreateVbeMock(_windows, projects.Object);

            _view.SetupProperty(v => v.TodoItems);

            var parser = new RubberduckParser();

            var presenter = new ToDoExplorerDockablePresenter(parser, _markers, _vbe.Object, _addin.Object, _view.Object, _gridViewSorter);

            //act
            presenter.Refresh();

            //assert
            Assert.AreEqual("Todo: Fix the foobarred bazzer.", _view.Object.TodoItems.First().Description);
        }