Esempio n. 1
0
 public IntroduceParameterRefactoring(RubberduckParserState parseResult, IActiveCodePaneEditor editor, IMessageBox messageBox)
 {
     _parseResult  = parseResult;
     _declarations = parseResult.AllDeclarations.ToList();
     _editor       = editor;
     _messageBox   = messageBox;
 }
Esempio n. 2
0
        public RubberduckMenu(VBE vbe, AddIn addIn, IGeneralConfigService configService, IRubberduckParser parser, IActiveCodePaneEditor editor, IInspector inspector)
            : base(vbe, addIn)
        {
            _addIn = addIn;
            _parser = parser;
            _configService = configService;

            var testExplorer = new TestExplorerWindow();
            var testEngine = new TestEngine();
            var testGridViewSort = new GridViewSort<TestExplorerItem>(RubberduckUI.Result, false);
            var testPresenter = new TestExplorerDockablePresenter(vbe, addIn, testExplorer, testEngine, testGridViewSort);
            _testMenu = new TestMenu(vbe, addIn, testExplorer, testPresenter);

            var codeExplorer = new CodeExplorerWindow();
            var codePresenter = new CodeExplorerDockablePresenter(parser, vbe, addIn, codeExplorer);
            codePresenter.RunAllTests += CodePresenterRunAllAllTests;
            codePresenter.RunInspections += codePresenter_RunInspections;
            codePresenter.Rename += codePresenter_Rename;
            codePresenter.FindAllReferences += codePresenter_FindAllReferences;
            codePresenter.FindAllImplementations += codePresenter_FindAllImplementations;
            _codeExplorerMenu = new CodeExplorerMenu(vbe, addIn, codeExplorer, codePresenter);

            var todoSettings = configService.LoadConfiguration().UserSettings.ToDoListSettings;
            var todoExplorer = new ToDoExplorerWindow();
            var todoGridViewSort = new GridViewSort<ToDoItem>(RubberduckUI.Priority, false);
            var todoPresenter = new ToDoExplorerDockablePresenter(parser, todoSettings.ToDoMarkers, vbe, addIn, todoExplorer, todoGridViewSort);
            _todoItemsMenu = new ToDoItemsMenu(vbe, addIn, todoExplorer, todoPresenter);

            var inspectionExplorer = new CodeInspectionsWindow();
            var inspectionGridViewSort = new GridViewSort<CodeInspectionResultGridViewItem>(RubberduckUI.Component, false);
            var inspectionPresenter = new CodeInspectionsDockablePresenter(inspector, vbe, addIn, inspectionExplorer, inspectionGridViewSort);
            _codeInspectionsMenu = new CodeInspectionsMenu(vbe, addIn, inspectionExplorer, inspectionPresenter);

            _refactorMenu = new RefactorMenu(IDE, AddIn, parser, editor);
        }
Esempio n. 3
0
 public RemoveParametersPresenterFactory(IActiveCodePaneEditor editor, IRemoveParametersView view,
                                         VBProjectParseResult parseResult)
 {
     _editor      = editor;
     _view        = view;
     _parseResult = parseResult;
 }
 public RenameRefactoring(IRefactoringPresenterFactory<IRenamePresenter> factory, IActiveCodePaneEditor editor, IMessageBox messageBox, RubberduckParserState state)
 {
     _factory = factory;
     _editor = editor;
     _messageBox = messageBox;
     _state = state;
 }
 public RenameRefactoring(IRefactoringPresenterFactory <IRenamePresenter> factory, IActiveCodePaneEditor editor, IMessageBox messageBox, RubberduckParserState state)
 {
     _factory    = factory;
     _editor     = editor;
     _messageBox = messageBox;
     _state      = state;
 }
Esempio n. 6
0
        public RefactorMenu(VBE vbe, AddIn addin, IRubberduckParser parser, IActiveCodePaneEditor editor)
            : base(vbe, addin)
        {
            _parser = parser;
            _editor = editor;

            _iconCache = new SearchResultIconCache();
        }
 public IntroduceFieldRefactoring(RubberduckParserState parserState, IActiveCodePaneEditor editor, IMessageBox messageBox)
 {
     _declarations =
         parserState.AllDeclarations.Where(i => !i.IsBuiltIn && i.DeclarationType == DeclarationType.Variable)
             .ToList();
     _editor = editor;
     _messageBox = messageBox;
 }
Esempio n. 8
0
 public IntroduceFieldRefactoring(RubberduckParserState parserState, IActiveCodePaneEditor editor, IMessageBox messageBox)
 {
     _declarations =
         parserState.AllDeclarations.Where(i => !i.IsBuiltIn && i.DeclarationType == DeclarationType.Variable)
         .ToList();
     _editor     = editor;
     _messageBox = messageBox;
 }
Esempio n. 9
0
 public RemoveParametersPresenterFactory(IActiveCodePaneEditor editor, IRemoveParametersView view,
                                         RubberduckParserState parseResult, IMessageBox messageBox)
 {
     _editor      = editor;
     _view        = view;
     _parseResult = parseResult;
     _messageBox  = messageBox;
 }
 public ExtractInterfaceRefactoring(RubberduckParserState state, IMessageBox messageBox, IRefactoringPresenterFactory <ExtractInterfacePresenter> factory,
                                    IActiveCodePaneEditor editor)
 {
     _state      = state;
     _messageBox = messageBox;
     _factory    = factory;
     _editor     = editor;
 }
Esempio n. 11
0
        public RefactorMenu(VBE vbe, AddIn addin, IRubberduckParser parser, IActiveCodePaneEditor editor)
            : base(vbe, addin)
        {
            _parser = parser;
            _editor = editor;

            _iconCache = new SearchResultIconCache();
        }
        public ExtractMethodModel(IActiveCodePaneEditor editor, IEnumerable <Declaration> declarations, QualifiedSelection selection)
        {
            var items = declarations.ToList();

            _sourceMember = items.FindSelectedDeclaration(selection, DeclarationExtensions.ProcedureTypes, d => ((ParserRuleContext)d.Context.Parent).GetSelection());
            if (_sourceMember == null)
            {
                throw new InvalidOperationException("Invalid selection.");
            }

            _extractedMethod = new ExtractedMethod();

            _selection    = selection;
            _selectedCode = editor.GetLines(selection.Selection);

            var inScopeDeclarations = items.Where(item => item.ParentScope == _sourceMember.Scope).ToList();

            var inSelection = inScopeDeclarations.SelectMany(item => item.References)
                              .Where(item => selection.Selection.Contains(item.Selection))
                              .ToList();

            var usedInSelection = new HashSet <Declaration>(inScopeDeclarations.Where(item =>
                                                                                      selection.Selection.Contains(item.Selection) ||
                                                                                      item.References.Any(reference => inSelection.Contains(reference))));

            var usedBeforeSelection = new HashSet <Declaration>(inScopeDeclarations.Where(item =>
                                                                                          item.Selection.StartLine < selection.Selection.StartLine ||
                                                                                          item.References.Any(reference => reference.Selection.StartLine < selection.Selection.StartLine)));

            var usedAfterSelection = new HashSet <Declaration>(inScopeDeclarations.Where(item =>
                                                                                         item.Selection.StartLine > selection.Selection.StartLine ||
                                                                                         item.References.Any(reference => reference.Selection.StartLine > selection.Selection.EndLine)));

            // identifiers used inside selection and before selection (or if it's a parameter) are candidates for parameters:
            var input = inScopeDeclarations.Where(item =>
                                                  usedInSelection.Contains(item) && (usedBeforeSelection.Contains(item) || item.DeclarationType == DeclarationType.Parameter)).ToList();

            // identifiers used inside selection and after selection are candidates for return values:
            var output = inScopeDeclarations.Where(item =>
                                                   usedInSelection.Contains(item) && usedAfterSelection.Contains(item))
                         .ToList();

            // identifiers used only inside and/or after selection are candidates for locals:
            _locals = inScopeDeclarations.Where(item => item.DeclarationType != DeclarationType.Parameter && (
                                                    item.References.All(reference => inSelection.Contains(reference)) ||
                                                    (usedAfterSelection.Contains(item) && (!usedBeforeSelection.Contains(item)))))
                      .ToList();

            // locals that are only used in selection are candidates for being moved into the new method:
            _declarationsToMove = _locals.Where(item => !usedAfterSelection.Contains(item)).ToList();

            _output = output.Select(declaration =>
                                    new ExtractedParameter(declaration.AsTypeName, ExtractedParameter.PassedBy.ByRef, declaration.IdentifierName));

            _input = input.Where(declaration => !output.Contains(declaration))
                     .Select(declaration =>
                             new ExtractedParameter(declaration.AsTypeName, ExtractedParameter.PassedBy.ByVal, declaration.IdentifierName));
        }
Esempio n. 13
0
        public ExtractMethodModel(IActiveCodePaneEditor editor, IEnumerable<Declaration> declarations, QualifiedSelection selection)
        {
            var items = declarations.ToList();

            _sourceMember = items.FindSelectedDeclaration(selection, DeclarationExtensions.ProcedureTypes, d => ((ParserRuleContext)d.Context.Parent).GetSelection());
            if (_sourceMember == null)
            {
                throw new InvalidOperationException("Invalid selection.");
            }

            _extractedMethod = new ExtractedMethod();

            _selection = selection;
            _selectedCode = editor.GetLines(selection.Selection);

            var inScopeDeclarations = items.Where(item => item.ParentScope == _sourceMember.Scope).ToList();

            var inSelection = inScopeDeclarations.SelectMany(item => item.References)
                .Where(item => selection.Selection.Contains(item.Selection))
                .ToList();

            var usedInSelection = new HashSet<Declaration>(inScopeDeclarations.Where(item =>
                selection.Selection.Contains(item.Selection) ||
                item.References.Any(reference => inSelection.Contains(reference))));

            var usedBeforeSelection = new HashSet<Declaration>(inScopeDeclarations.Where(item =>
                item.Selection.StartLine < selection.Selection.StartLine ||
                item.References.Any(reference => reference.Selection.StartLine < selection.Selection.StartLine)));

            var usedAfterSelection = new HashSet<Declaration>(inScopeDeclarations.Where(item =>
                item.Selection.StartLine > selection.Selection.StartLine ||
                item.References.Any(reference => reference.Selection.StartLine > selection.Selection.EndLine)));

            // identifiers used inside selection and before selection (or if it's a parameter) are candidates for parameters:
            var input = inScopeDeclarations.Where(item =>
                usedInSelection.Contains(item) && (usedBeforeSelection.Contains(item) || item.DeclarationType == DeclarationType.Parameter)).ToList();

            // identifiers used inside selection and after selection are candidates for return values:
            var output = inScopeDeclarations.Where(item =>
                usedInSelection.Contains(item) && usedAfterSelection.Contains(item))
                .ToList();

            // identifiers used only inside and/or after selection are candidates for locals:
            _locals = inScopeDeclarations.Where(item => item.DeclarationType != DeclarationType.Parameter && (
                item.References.All(reference => inSelection.Contains(reference))
                || (usedAfterSelection.Contains(item) && (!usedBeforeSelection.Contains(item)))))
                .ToList();

            // locals that are only used in selection are candidates for being moved into the new method:
            _declarationsToMove = _locals.Where(item => !usedAfterSelection.Contains(item)).ToList();

            _output = output.Select(declaration =>
                new ExtractedParameter(declaration.AsTypeName, ExtractedParameter.PassedBy.ByRef, declaration.IdentifierName));

            _input = input.Where(declaration => !output.Contains(declaration))
                .Select(declaration =>
                    new ExtractedParameter(declaration.AsTypeName, ExtractedParameter.PassedBy.ByVal, declaration.IdentifierName));
        }
 public RefactorImplementInterfaceCommand(VBE vbe, RubberduckParserState state, IActiveCodePaneEditor editor)
     : base(vbe, editor)
 {
     _state = state;
 }
 public RefactorEncapsulateFieldCommand(VBE vbe, RubberduckParserState state, IActiveCodePaneEditor editor)
     : base(vbe, editor)
 {
     _state = state;
 }
 public RefactorRemoveParametersCommand(VBE vbe, RubberduckParserState state, IActiveCodePaneEditor editor) 
     : base (vbe, editor)
 {
     _state = state;
 }
 public RefactorIntroduceFieldCommand(VBE vbe, RubberduckParserState state, IActiveCodePaneEditor editor, ICodePaneWrapperFactory wrapperWrapperFactory)
     : base(vbe, editor)
 {
     _state = state;
     _wrapperWrapperFactory = wrapperWrapperFactory;
 }
 public ReorderParametersRefactoring(IRefactoringPresenterFactory <IReorderParametersPresenter> factory, IActiveCodePaneEditor editor, IMessageBox messageBox)
 {
     _factory    = factory;
     _editor     = editor;
     _messageBox = messageBox;
 }
Esempio n. 19
0
        public RubberduckMenu(VBE vbe, AddIn addIn, IGeneralConfigService configService, IRubberduckParser parser, IActiveCodePaneEditor editor, IInspector inspector)
            : base(vbe, addIn)
        {
            _addIn         = addIn;
            _parser        = parser;
            _configService = configService;

            var testExplorer     = new TestExplorerWindow();
            var testEngine       = new TestEngine();
            var testGridViewSort = new GridViewSort <TestExplorerItem>(RubberduckUI.Result, false);
            var testPresenter    = new TestExplorerDockablePresenter(vbe, addIn, testExplorer, testEngine, testGridViewSort);

            _testMenu = new TestMenu(vbe, addIn, testExplorer, testPresenter);

            var codeExplorer  = new CodeExplorerWindow();
            var codePresenter = new CodeExplorerDockablePresenter(parser, vbe, addIn, codeExplorer);

            codePresenter.RunAllTests            += CodePresenterRunAllAllTests;
            codePresenter.RunInspections         += codePresenter_RunInspections;
            codePresenter.Rename                 += codePresenter_Rename;
            codePresenter.FindAllReferences      += codePresenter_FindAllReferences;
            codePresenter.FindAllImplementations += codePresenter_FindAllImplementations;
            _codeExplorerMenu = new CodeExplorerMenu(vbe, addIn, codeExplorer, codePresenter);

            var todoSettings     = configService.LoadConfiguration().UserSettings.ToDoListSettings;
            var todoExplorer     = new ToDoExplorerWindow();
            var todoGridViewSort = new GridViewSort <ToDoItem>(RubberduckUI.Priority, false);
            var todoPresenter    = new ToDoExplorerDockablePresenter(parser, todoSettings.ToDoMarkers, vbe, addIn, todoExplorer, todoGridViewSort);

            _todoItemsMenu = new ToDoItemsMenu(vbe, addIn, todoExplorer, todoPresenter);

            var inspectionExplorer     = new CodeInspectionsWindow();
            var inspectionGridViewSort = new GridViewSort <CodeInspectionResultGridViewItem>(RubberduckUI.Component, false);
            var inspectionPresenter    = new CodeInspectionsDockablePresenter(inspector, vbe, addIn, inspectionExplorer, inspectionGridViewSort);

            _codeInspectionsMenu = new CodeInspectionsMenu(vbe, addIn, inspectionExplorer, inspectionPresenter);

            _refactorMenu = new RefactorMenu(IDE, AddIn, parser, editor);
        }
 public RefactorMoveCloserToUsageCommand(VBE vbe, RubberduckParserState state, IActiveCodePaneEditor editor, ICodePaneWrapperFactory wrapperWrapperFactory)
     : base(vbe, editor)
 {
     _state = state;
     _wrapperWrapperFactory = wrapperWrapperFactory;
 }
 public RefactorRemoveParametersCommand(VBE vbe, RubberduckParserState state, IActiveCodePaneEditor editor)
     : base(vbe, editor)
 {
     _state = state;
 }
 protected RefactorCommandBase(VBE vbe, IActiveCodePaneEditor editor)
 {
     Vbe = vbe;
     Editor = editor;
 }
 public RemoveParametersRefactoring(IRefactoringPresenterFactory<IRemoveParametersPresenter> factory, IActiveCodePaneEditor editor)
 {
     _factory = factory;
     _editor = editor;
 }
 public MoveCloserToUsageRefactoring(RubberduckParserState parseResult, IActiveCodePaneEditor editor, IMessageBox messageBox)
 {
     _declarations = parseResult.AllDeclarations.ToList();
     _editor = editor;
     _messageBox = messageBox;
 }
 public RefactorMoveCloserToUsageCommand(VBE vbe, RubberduckParserState state, IActiveCodePaneEditor editor, ICodePaneWrapperFactory wrapperWrapperFactory)
     : base(vbe, editor)
 {
     _state = state;
     _wrapperWrapperFactory = wrapperWrapperFactory;
 }
 public RefactorReorderParametersCommand(VBE vbe, RubberduckParserState state, IActiveCodePaneEditor editor, ICodePaneWrapperFactory wrapperWrapperFactory) 
     : base (vbe, editor)
 {
     _state = state;
     _wrapperWrapperFactory = wrapperWrapperFactory;
 }
 public ImplementInterfaceRefactoring(RubberduckParserState state, IActiveCodePaneEditor editor, IMessageBox messageBox)
 {
     _declarations = state.AllDeclarations.ToList();
     _editor = editor;
     _messageBox = messageBox;
 }
Esempio n. 28
0
 public RefactorImplementInterfaceCommand(VBE vbe, RubberduckParserState state, IActiveCodePaneEditor editor)
     : base(vbe, editor)
 {
     _state = state;
 }
Esempio n. 29
0
 protected RefactorCommandBase(VBE vbe, IActiveCodePaneEditor editor)
 {
     Vbe    = vbe;
     Editor = editor;
 }
 public RefactorEncapsulateFieldCommand(VBE vbe, RubberduckParserState state, IActiveCodePaneEditor editor)
     : base(vbe, editor)
 {
     _state = state;
 }
 public EncapsulateFieldRefactoring(IRefactoringPresenterFactory<IEncapsulateFieldPresenter> factory, IActiveCodePaneEditor editor)
 {
     _factory = factory;
     _editor = editor;
 }
 public RefactorReorderParametersCommand(VBE vbe, RubberduckParserState state, IActiveCodePaneEditor editor, ICodePaneWrapperFactory wrapperWrapperFactory)
     : base(vbe, editor)
 {
     _state = state;
     _wrapperWrapperFactory = wrapperWrapperFactory;
 }
 public FormDesignerRefactorRenameCommand(VBE vbe, RubberduckParserState state, IActiveCodePaneEditor editor, ICodePaneWrapperFactory wrapperWrapperFactory) 
     : base (vbe, editor)
 {
     _state = state;
     _wrapperWrapperFactory = wrapperWrapperFactory;
 }
 public ExtractMethodPresenterFactory(IActiveCodePaneEditor editor, IEnumerable <Declaration> declarations, IIndenter indenter)
 {
     _editor       = editor;
     _declarations = declarations;
     _indenter     = indenter;
 }
 public FormDesignerRefactorRenameCommand(VBE vbe, RubberduckParserState state, IActiveCodePaneEditor editor, ICodePaneWrapperFactory wrapperWrapperFactory)
     : base(vbe, editor)
 {
     _state = state;
     _wrapperWrapperFactory = wrapperWrapperFactory;
 }
 public EncapsulateFieldPresenterFactory(RubberduckParserState parseResult, IActiveCodePaneEditor editor, IEncapsulateFieldView view)
 {
     _editor      = editor;
     _view        = view;
     _parseResult = parseResult;
 }
Esempio n. 37
0
 public EncapsulateFieldRefactoring(IRefactoringPresenterFactory <IEncapsulateFieldPresenter> factory, IActiveCodePaneEditor editor)
 {
     _factory = factory;
     _editor  = editor;
 }
 public ExtractInterfacePresenterFactory(RubberduckParserState state, IActiveCodePaneEditor editor, IExtractInterfaceView view)
 {
     _editor = editor;
     _view   = view;
     _state  = state;
 }
Esempio n. 39
0
 public RefactorExtractInterfaceCommand(VBE vbe, RubberduckParserState state, IActiveCodePaneEditor editor, IMessageBox messageBox)
     : base(vbe, editor)
 {
     _state      = state;
     _messageBox = messageBox;
 }
 public RefactorIntroduceFieldCommand (VBE vbe, RubberduckParserState state, IActiveCodePaneEditor editor, ICodePaneWrapperFactory wrapperWrapperFactory)
     : base(vbe, editor)
 {
     _state = state;
     _wrapperWrapperFactory = wrapperWrapperFactory;
 }
Esempio n. 41
0
 public RefactorExtractMethodCommand(VBE vbe, RubberduckParserState state, IActiveCodePaneEditor editor, IIndenter indenter)
     : base(vbe, editor)
 {
     _state    = state;
     _indenter = indenter;
 }
Esempio n. 42
0
 public ImplementInterfaceRefactoring(RubberduckParserState state, IActiveCodePaneEditor editor, IMessageBox messageBox)
 {
     _declarations = state.AllDeclarations.ToList();
     _editor       = editor;
     _messageBox   = messageBox;
 }
 public RemoveParametersRefactoring(IRefactoringPresenterFactory <IRemoveParametersPresenter> factory, IActiveCodePaneEditor editor)
 {
     _factory = factory;
     _editor  = editor;
 }
 public MoveCloserToUsageRefactoring(RubberduckParserState parseResult, IActiveCodePaneEditor editor, IMessageBox messageBox)
 {
     _declarations = parseResult.AllDeclarations.ToList();
     _editor       = editor;
     _messageBox   = messageBox;
 }
 public ExtractMethodRefactoring(IRefactoringPresenterFactory<IExtractMethodPresenter> factory, IActiveCodePaneEditor editor)
 {
     _factory = factory;
     _editor = editor;
 }
 public RefactorExtractMethodCommand(VBE vbe, RubberduckParserState state, IActiveCodePaneEditor editor, IIndenter indenter)
     : base (vbe, editor)
 {
     _state = state;
     _indenter = indenter;
 }
Esempio n. 47
0
 public ExtractMethodPresenterFactory(IActiveCodePaneEditor editor, Declarations declarations)
 {
     _editor       = editor;
     _declarations = declarations;
 }
Esempio n. 48
0
 public ExtractMethodRefactoring(IRefactoringPresenterFactory <IExtractMethodPresenter> factory, IActiveCodePaneEditor editor)
 {
     _factory = factory;
     _editor  = editor;
 }
 public ReorderParametersRefactoring(IRefactoringPresenterFactory<IReorderParametersPresenter> factory, IActiveCodePaneEditor editor, IMessageBox messageBox)
 {
     _factory = factory;
     _editor = editor;
     _messageBox = messageBox;
 }