private IEnumerable <RegexSearchResult> SearchCurrentBlock(string searchPattern)
        {
            var activeSelection = _selectionService.ActiveSelection();

            if (!activeSelection.HasValue)
            {
                return(new List <RegexSearchResult>());
            }

            var block = _selectedDeclarationProvider
                        .SelectedMember(activeSelection.Value)
                        ?.Context
                        .GetSmallestDescendentContainingSelection <VBAParser.BlockContext>(activeSelection.Value.Selection);

            if (block == null)
            {
                return(new List <RegexSearchResult>());
            }

            var blockSelection = block.GetSelection();

            using (var pane = _vbe.ActiveCodePane)
            {
                if (pane == null || pane.IsWrappingNullReference)
                {
                    return(new List <RegexSearchResult>());
                }

                using (var module = pane.CodeModule)
                {
                    //FIXME: This is a catastrophe waiting to happen since the module, which will get disposed, is saved on the result.
                    return(GetResultsFromModule(module, searchPattern, blockSelection));
                }
            }
        }
        private Declaration FindModuleFromSelection()
        {
            var active = _selectionService?.ActiveSelection();

            return(!active.HasValue
                ? null
                : _finderProvider.DeclarationFinder.ModuleDeclaration(active.Value.QualifiedName));
        }
示例#3
0
        private EncapsulateFieldModel InitializeModel()
        {
            var selection = _selectionService.ActiveSelection();

            if (!selection.HasValue)
            {
                return(null);
            }

            return(new EncapsulateFieldModel(_state, selection.Value));
        }
        private ExtractInterfaceModel InitializeModel()
        {
            var activeSelection = _selectionService.ActiveSelection();

            if (!activeSelection.HasValue)
            {
                return(null);
            }

            return(new ExtractInterfaceModel(_declarationFinderProvider, activeSelection.Value));
        }
        private ReorderParametersModel InitializeModel()
        {
            var activeSelection = _selectionService.ActiveSelection();

            if (!activeSelection.HasValue)
            {
                return(null);
            }

            return(new ReorderParametersModel(_state, activeSelection.Value));
        }
        public void Refactor()
        {
            var activeSelection = _selectionService.ActiveSelection();

            if (!activeSelection.HasValue)
            {
                _messageBox.NotifyWarn(RubberduckUI.PromoteVariable_InvalidSelection, RubberduckUI.IntroduceParameter_Caption);
                return;
            }

            Refactor(activeSelection.Value);
        }
        public void Refactor()
        {
            var activeSelection = _selectionService.ActiveSelection();

            if (!activeSelection.HasValue)
            {
                _messageBox.NotifyWarn(RubberduckUI.MoveCloserToUsage_InvalidSelection, RubberduckUI.MoveCloserToUsage_Caption);
                return;
            }

            Refactor(activeSelection.Value);
        }
        public void Refactor()
        {
            var activeSelection = _selectionService.ActiveSelection();

            if (!activeSelection.HasValue)
            {
                _messageBox.NotifyWarn(RubberduckUI.ImplementInterface_InvalidSelectionMessage, RubberduckUI.ImplementInterface_Caption);
                return;
            }

            Refactor(activeSelection.Value);
        }
示例#9
0
        private Declaration FindDeclarationFromSelection()
        {
            var active = _selectionService?.ActiveSelection();

            if (!active.HasValue)
            {
                return(null);
            }

            return(_finderProvider.DeclarationFinder.FindDeclarationsForSelection(active.Value)
                   .SingleOrDefault(declaration => declaration.DeclarationType == DeclarationType.Procedure &&
                                    declaration.Annotations.Any(annotation => annotation is TestMethodAnnotation)));
        }
 public void SaveActiveCodePane()
 {
     _savedActiveModule = _selectionService.ActiveSelection()?.QualifiedName;
 }
示例#11
0
        private RenameModel InitializeModel(Declaration target)
        {
            var targetSelection = target?.QualifiedSelection ?? _selectionService.ActiveSelection();

            return(targetSelection == null ? null : new RenameModel(_declarationFinderProvider.DeclarationFinder, targetSelection.Value));
        }