public void GotoDefinition_CPlusPlus() { Create(); var ct = GetOrCreateContentType(VsVim.Constants.CPlusPlusContentType, "code"); var textView = CreateTextView(ct, "hello world"); var wordUtil = WordUtilFactory.GetWordUtil(textView.TextBuffer); _textManager.SetupGet(x => x.ActiveTextViewOptional).Returns(textView); _dte.Setup(x => x.ExecuteCommand(VsVimHost.CommandNameGoToDefinition, "hello")); Assert.True(_host.GoToDefinition()); }
private void Create(bool insertMode, params string[] lines) { _factory = new MockRepository(MockBehavior.Strict); _factory.DefaultValue = DefaultValue.Mock; _textView = CreateTextView(lines); _textBuffer = _textView.TextBuffer; _vim = _factory.Create <IVim>(MockBehavior.Loose); _editorOptions = _factory.Create <IEditorOptions>(MockBehavior.Loose); _textChangeTracker = _factory.Create <ITextChangeTracker>(MockBehavior.Loose); _textChangeTracker.SetupGet(x => x.CurrentChange).Returns(FSharpOption <TextChange> .None); _undoRedoOperations = _factory.Create <IUndoRedoOperations>(); _wordCompletionSessionFactoryService = _factory.Create <IWordCompletionSessionFactoryService>(); var localSettings = new LocalSettings(Vim.GlobalSettings); _vimBuffer = MockObjectFactory.CreateVimBuffer( _textView, localSettings: localSettings, vim: _vim.Object, factory: _factory); _vimBuffer.SetupGet(x => x.ModeKind).Returns(ModeKind.Insert); _operations = _factory.Create <ICommonOperations>(); _operations.SetupGet(x => x.EditorOperations).Returns(EditorOperationsFactoryService.GetEditorOperations(_textView)); _broker = _factory.Create <IDisplayWindowBroker>(); _broker.SetupGet(x => x.IsCompletionActive).Returns(false); _broker.SetupGet(x => x.IsQuickInfoActive).Returns(false); _broker.SetupGet(x => x.IsSignatureHelpActive).Returns(false); _insertUtil = _factory.Create <IInsertUtil>(); // Setup the mouse. By default we say it has no buttons down as that's the normal state _mouseDevice = _factory.Create <IMouseDevice>(); _mouseDevice.SetupGet(x => x.IsLeftButtonPressed).Returns(false); // Setup the keyboard. By default we don't say that any button is pressed. Insert mode is usually // only concerned with arrow keys and we will set those up as appropriate for the typing tests _keyboardDevice = _factory.Create <IKeyboardDevice>(); _keyboardDevice.Setup(x => x.IsKeyDown(It.IsAny <VimKey>())).Returns(false); _modeRaw = new global::Vim.Modes.Insert.InsertMode( _vimBuffer.Object, _operations.Object, _broker.Object, _editorOptions.Object, _undoRedoOperations.Object, _textChangeTracker.Object, _insertUtil.Object, !insertMode, _keyboardDevice.Object, _mouseDevice.Object, WordUtilFactory.GetWordUtil(_textView.TextBuffer), _wordCompletionSessionFactoryService.Object); _mode = _modeRaw; _mode.CommandRan += (sender, e) => { _lastCommandRan = e.CommandRunData; }; }
public void Create(params string[] lines) { _textBuffer = CreateTextBuffer(lines); _wordNavigator = WordUtilFactory.GetWordUtil(_textBuffer).CreateTextStructureNavigator(WordKind.NormalWord); _globalSettings = Vim.GlobalSettings; _globalSettings.Magic = true; _globalSettings.IgnoreCase = true; _globalSettings.SmartCase = false; _textSearch = TextSearchService; _searchRaw = new SearchService(_textSearch, _globalSettings); _search = _searchRaw; }
/// <summary> /// Create a new instance of VimBufferData. Centralized here to make it easier to /// absorb API changes in the Unit Tests /// </summary> protected IVimBufferData CreateVimBufferData( IVimTextBuffer vimTextBuffer, ITextView textView, IStatusUtil statusUtil = null, IJumpList jumpList = null, IUndoRedoOperations undoRedoOperations = null, IVimWindowSettings windowSettings = null, IWordUtil wordUtil = null) { jumpList = jumpList ?? new JumpList(textView, _bufferTrackingService); statusUtil = statusUtil ?? new StatusUtil(); undoRedoOperations = undoRedoOperations ?? CreateUndoRedoOperations(statusUtil); windowSettings = windowSettings ?? new WindowSettings(vimTextBuffer.GlobalSettings); wordUtil = wordUtil ?? WordUtilFactory.GetWordUtil(vimTextBuffer.TextBuffer); return(new VimBufferData( vimTextBuffer, textView, windowSettings, jumpList, statusUtil, undoRedoOperations, wordUtil)); }
protected ITextStructureNavigator CreateTextStructureNavigator(ITextBuffer textBuffer, WordKind kind) { return(WordUtilFactory.GetWordUtil(textBuffer).CreateTextStructureNavigator(kind)); }