示例#1
0
 internal VsKeyProcessor(IVsAdapter adapter, IVimBufferCoordinator bufferCoordinator, IKeyUtil keyUtil)
     : base(bufferCoordinator.VimBuffer, keyUtil)
 {
     _adapter = adapter;
     _bufferCoordinator = bufferCoordinator;
     _searchInProgressInfo = new Lazy<PropertyInfo>(FindSearchInProgressPropertyInfo);
 }
示例#2
0
        public VsCommandTargetTest()
        {
            _textView = CreateTextView("");
            _buffer = Vim.CreateVimBuffer(_textView);
            _bufferCoordinator = new VimBufferCoordinator(_buffer);
            _vim = _buffer.Vim;
            _factory = new MockRepository(MockBehavior.Strict);

            // By default Resharper isn't loaded
            _resharperUtil = _factory.Create<IResharperUtil>();
            _resharperUtil.SetupGet(x => x.IsInstalled).Returns(false);

            _nextTarget = _factory.Create<IOleCommandTarget>(MockBehavior.Strict);
            _vsAdapter = _factory.Create<IVsAdapter>();
            _vsAdapter.SetupGet(x => x.KeyboardDevice).Returns(InputManager.Current.PrimaryKeyboardDevice);
            _vsAdapter.Setup(x => x.InAutomationFunction).Returns(false);
            _vsAdapter.Setup(x => x.InDebugMode).Returns(false);
            _vsAdapter.Setup(x => x.IsIncrementalSearchActive(It.IsAny<ITextView>())).Returns(false);

            _broker = _factory.Create<IDisplayWindowBroker>(MockBehavior.Loose);

            var oldCommandFilter = _nextTarget.Object;
            var vsTextView = _factory.Create<IVsTextView>(MockBehavior.Loose);
            vsTextView.Setup(x => x.AddCommandFilter(It.IsAny<IOleCommandTarget>(), out oldCommandFilter)).Returns(0);
            var result = VsCommandTarget.Create(
                _bufferCoordinator,
                vsTextView.Object,
                _vsAdapter.Object,
                _broker.Object,
                _resharperUtil.Object,
                KeyUtil);
            Assert.True(result.IsSuccess);
            _targetRaw = result.Value;
            _target = _targetRaw;
        }
示例#3
0
        /// <summary>
        /// Create a Visual Studio simulation with the specified set of lines
        /// </summary>
        private void CreateCore(bool simulateResharper, bool usePeekRole, params string[] lines)
        {
            if (usePeekRole)
            {
                _textBuffer = CreateTextBuffer(lines);
                _textView = TextEditorFactoryService.CreateTextView(
                    _textBuffer,
                    TextEditorFactoryService.CreateTextViewRoleSet(PredefinedTextViewRoles.Document, PredefinedTextViewRoles.Editable, Constants.TextViewRoleEmbeddedPeekTextView));
            }
            else
            {
                _textView = CreateTextView(lines);
                _textBuffer = _textView.TextBuffer;
            }
            _vimBuffer = Vim.CreateVimBuffer(_textView);
            _bufferCoordinator = new VimBufferCoordinator(_vimBuffer);
            _vsSimulation = new VsSimulation(
                _bufferCoordinator,
                simulateResharper: simulateResharper,
                simulateStandardKeyMappings: false,
                editorOperationsFactoryService: EditorOperationsFactoryService,
                keyUtil: KeyUtil);

            VimHost.TryCustomProcessFunc = (textView, insertCommand) =>
                {
                    if (textView == _textView)
                    {
                        return _vsSimulation.VsCommandTarget.TryCustomProcess(insertCommand);
                    }

                    return false;
                };
        }
示例#4
0
 internal VsKeyProcessor(IVsAdapter adapter, IVimBufferCoordinator bufferCoordinator, IKeyUtil keyUtil, IReportDesignerUtil reportDesignerUtil, IWpfTextView wpfTextView)
     : base(bufferCoordinator.VimBuffer, keyUtil, wpfTextView)
 {
     _adapter = adapter;
     _reportDesignerUtil = reportDesignerUtil;
     _bufferCoordinator = bufferCoordinator;
     _searchInProgressInfo = new Lazy<PropertyInfo>(FindSearchInProgressPropertyInfo);
 }
示例#5
0
        ICommandTarget ICommandTargetFactory.CreateCommandTarget(IOleCommandTarget nextCommandTarget, IVimBufferCoordinator vimBufferCoordinator)
        {
            if (!_reSharperUtil.IsInstalled)
            {
                return null;
            }

            return ReSharperKeyUtil.GetOrCreate(vimBufferCoordinator);
        }
示例#6
0
 internal VsCommandTarget(
     IVimBufferCoordinator vimBufferCoordinator,
     ITextManager textManager,
     IVsAdapter vsAdapter,
     IDisplayWindowBroker broker,
     IKeyUtil keyUtil,
     IOleCommandTarget nextTarget,
     ReadOnlyCollection<ICommandTarget> commandTargets)
     : this(vimBufferCoordinator, textManager, vsAdapter, broker, keyUtil)
 {
     CompleteInit(nextTarget, commandTargets);
 }
示例#7
0
 private VsCommandTarget(
     IVimBufferCoordinator bufferCoordinator,
     IVsAdapter vsAdapter,
     IDisplayWindowBroker broker,
     IExternalEditorManager externalEditorManager)
 {
     _buffer = bufferCoordinator.VimBuffer;
     _bufferCoordinator = bufferCoordinator;
     _textBuffer = _buffer.TextBuffer;
     _vsAdapter = vsAdapter;
     _broker = broker;
     _externalEditManager = externalEditorManager;
 }
示例#8
0
 internal StandardCommandTarget(
     IVimBufferCoordinator vimBufferCoordinator,
     ITextManager textManager,
     IDisplayWindowBroker broker,
     IOleCommandTarget nextOleCommandTarget)
 {
     _vimBuffer = vimBufferCoordinator.VimBuffer;
     _vimBufferCoordinator = vimBufferCoordinator;
     _textBuffer = _vimBuffer.TextBuffer;
     _textView = _vimBuffer.TextView;
     _textManager = textManager;
     _broker = broker;
     _nextOleCommandTarget = nextOleCommandTarget;
 }
示例#9
0
 private VsCommandTarget(
     IVimBufferCoordinator bufferCoordinator,
     IVsAdapter vsAdapter,
     IDisplayWindowBroker broker,
     IResharperUtil resharperUtil)
 {
     _vimBuffer = bufferCoordinator.VimBuffer;
     _vim = _vimBuffer.Vim;
     _bufferCoordinator = bufferCoordinator;
     _textBuffer = _vimBuffer.TextBuffer;
     _vsAdapter = vsAdapter;
     _broker = broker;
     _resharperUtil = resharperUtil;
 }
示例#10
0
 private VsCommandTarget(
     IVimBufferCoordinator vimBufferCoordinator,
     ITextManager textManager,
     IVsAdapter vsAdapter,
     IDisplayWindowBroker broker,
     IKeyUtil keyUtil)
 {
     _vimBuffer = vimBufferCoordinator.VimBuffer;
     _vim = _vimBuffer.Vim;
     _vimBufferCoordinator = vimBufferCoordinator;
     _textBuffer = _vimBuffer.TextBuffer;
     _vsAdapter = vsAdapter;
     _broker = broker;
     _keyUtil = keyUtil;
 }
示例#11
0
 protected override void Setup(string languageId)
 {
     base.Setup(languageId);
     _factory = new MockRepository(MockBehavior.Strict);
     _textBuffer = _factory.Create<ITextBuffer>();
     _vsAdapter = _factory.Create<IVsAdapter>();
     _vsAdapter.Setup(x => x.IsIncrementalSearchActive(It.IsAny<ITextView>())).Returns(false);
     _buffer = MockObjectFactory.CreateVimBuffer(_textBuffer.Object);
     _buffer.Setup(x => x.CanProcess(It.IsAny<KeyInput>())).Returns(true);
     _buffer.Setup(x => x.Process(It.IsAny<KeyInput>())).Returns(ProcessResult.NewHandled(ModeSwitch.NoSwitch));
     _buffer.SetupGet(x => x.ModeKind).Returns(ModeKind.Normal);
     _bufferCoordinator = new VimBufferCoordinator(_buffer.Object);
     _vsProcessor = new VsKeyProcessor(_vsAdapter.Object, _bufferCoordinator);
     _processor = _vsProcessor;
     _device = new MockKeyboardDevice();
 }
示例#12
0
 private VsCommandTarget(
     IVimBufferCoordinator bufferCoordinator,
     ITextManager textManager,
     IVsAdapter vsAdapter,
     IDisplayWindowBroker broker,
     IReSharperUtil resharperUtil,
     IKeyUtil keyUtil)
 {
     _vimBuffer = bufferCoordinator.VimBuffer;
     _vim = _vimBuffer.Vim;
     _bufferCoordinator = bufferCoordinator;
     _textBuffer = _vimBuffer.TextBuffer;
     _textView = _vimBuffer.TextView;
     _textManager = textManager;
     _vsAdapter = vsAdapter;
     _broker = broker;
     _resharperUtil = resharperUtil;
     _keyUtil = keyUtil;
 }
示例#13
0
        protected override VimKeyProcessor CreateKeyProcessor()
        {
            _factory = new MockRepository(MockBehavior.Strict);
            _wpfTextView = CreateTextView();
            _mockAdapter = new MockAdapter();
            _editorAdaptersFactoryService = _factory.Create<IVsEditorAdaptersFactoryService>();
            _editorAdaptersFactoryService.Setup(x => x.GetViewAdapter(_wpfTextView)).Returns(_mockAdapter);

            _vsAdapter = _factory.Create<IVsAdapter>();
            _vsAdapter.Setup(x => x.IsIncrementalSearchActive(It.IsAny<ITextView>())).Returns(false);
            _vsAdapter.SetupGet(x => x.EditorAdapter).Returns(_editorAdaptersFactoryService.Object);
            _vsAdapter.Setup(x => x.IsReadOnly(_wpfTextView)).Returns(false);
            _mockVimBuffer = MockObjectFactory.CreateVimBuffer(_wpfTextView);
            _mockVimBuffer.Setup(x => x.CanProcess(It.IsAny<KeyInput>())).Returns(true);
            _mockVimBuffer.Setup(x => x.Process(It.IsAny<KeyInput>())).Returns(ProcessResult.NewHandled(ModeSwitch.NoSwitch));
            _mockVimBuffer.SetupGet(x => x.ModeKind).Returns(ModeKind.Normal);
            _bufferCoordinator = new VimBufferCoordinator(_mockVimBuffer.Object);
            _device = new MockKeyboardDevice();
            return new VsKeyProcessor(_vsAdapter.Object, _bufferCoordinator, KeyUtil);
        }
示例#14
0
        protected VsCommandTargetTest()
        {
            _textView          = CreateTextView("");
            _textBuffer        = _textView.TextBuffer;
            _vimBuffer         = Vim.CreateVimBuffer(_textView);
            _bufferCoordinator = new VimBufferCoordinator(_vimBuffer);
            _vim     = _vimBuffer.Vim;
            _factory = new MockRepository(MockBehavior.Strict);

            // By default Resharper isn't loaded
            _resharperUtil = _factory.Create <IReSharperUtil>();
            _resharperUtil.SetupGet(x => x.IsInstalled).Returns(false);

            _nextTarget = _factory.Create <IOleCommandTarget>(MockBehavior.Strict);
            _vsAdapter  = _factory.Create <IVsAdapter>();
            _vsAdapter.SetupGet(x => x.KeyboardDevice).Returns(InputManager.Current.PrimaryKeyboardDevice);
            _vsAdapter.Setup(x => x.InAutomationFunction).Returns(false);
            _vsAdapter.Setup(x => x.InDebugMode).Returns(false);
            _vsAdapter.Setup(x => x.IsIncrementalSearchActive(It.IsAny <ITextView>())).Returns(false);

            _broker      = _factory.Create <IDisplayWindowBroker>(MockBehavior.Loose);
            _textManager = _factory.Create <ITextManager>();

            var oldCommandFilter = _nextTarget.Object;
            var vsTextView       = _factory.Create <IVsTextView>(MockBehavior.Loose);

            vsTextView.Setup(x => x.AddCommandFilter(It.IsAny <IOleCommandTarget>(), out oldCommandFilter)).Returns(0);
            var result = VsCommandTarget.Create(
                _bufferCoordinator,
                vsTextView.Object,
                _textManager.Object,
                _vsAdapter.Object,
                _broker.Object,
                _resharperUtil.Object,
                KeyUtil);

            Assert.True(result.IsSuccess);
            _targetRaw = result.Value;
            _target    = _targetRaw;
        }
示例#15
0
        protected VsCommandTargetTest(bool isReSharperInstalled)
        {
            _textView          = CreateTextView("");
            _textBuffer        = _textView.TextBuffer;
            _vimBuffer         = Vim.CreateVimBuffer(_textView);
            _bufferCoordinator = new VimBufferCoordinator(_vimBuffer);
            _vim     = _vimBuffer.Vim;
            _factory = new MockRepository(MockBehavior.Strict);

            _nextTarget = _factory.Create <IOleCommandTarget>(MockBehavior.Strict);
            _vsAdapter  = _factory.Create <IVsAdapter>();
            _vsAdapter.SetupGet(x => x.KeyboardDevice).Returns(InputManager.Current.PrimaryKeyboardDevice);
            _vsAdapter.Setup(x => x.InAutomationFunction).Returns(false);
            _vsAdapter.Setup(x => x.InDebugMode).Returns(false);
            _vsAdapter.Setup(x => x.IsIncrementalSearchActive(It.IsAny <ITextView>())).Returns(false);

            _broker      = _factory.Create <IDisplayWindowBroker>(MockBehavior.Loose);
            _textManager = _factory.Create <ITextManager>();

            var commandTargets = new List <ICommandTarget>();

            if (isReSharperInstalled)
            {
                commandTargets.Add(ReSharperKeyUtil.GetOrCreate(_bufferCoordinator));
            }
            commandTargets.Add(new StandardCommandTarget(_bufferCoordinator, _textManager.Object, _broker.Object, _nextTarget.Object));

            var oldCommandFilter = _nextTarget.Object;

            _targetRaw = new VsCommandTarget(
                _bufferCoordinator,
                _textManager.Object,
                _vsAdapter.Object,
                _broker.Object,
                KeyUtil,
                _nextTarget.Object,
                commandTargets.ToReadOnlyCollectionShallow());
            _target = _targetRaw;
        }
示例#16
0
        protected VsCommandTargetTest(bool isReSharperInstalled)
        {
            _textView = CreateTextView("");
            _textBuffer = _textView.TextBuffer;
            _vimBuffer = Vim.CreateVimBuffer(_textView);
            _bufferCoordinator = new VimBufferCoordinator(_vimBuffer);
            _vim = _vimBuffer.Vim;
            _factory = new MockRepository(MockBehavior.Strict);

            _nextTarget = _factory.Create<IOleCommandTarget>(MockBehavior.Strict);
            _vsAdapter = _factory.Create<IVsAdapter>();
            _vsAdapter.SetupGet(x => x.KeyboardDevice).Returns(InputManager.Current.PrimaryKeyboardDevice);
            _vsAdapter.Setup(x => x.InAutomationFunction).Returns(false);
            _vsAdapter.Setup(x => x.InDebugMode).Returns(false);
            _vsAdapter.Setup(x => x.IsIncrementalSearchActive(It.IsAny<ITextView>())).Returns(false);

            _broker = _factory.Create<IDisplayWindowBroker>(MockBehavior.Loose);
            _textManager = _factory.Create<ITextManager>();
            _vimApplicationSettings = _factory.Create<IVimApplicationSettings>();

            var commandTargets = new List<ICommandTarget>();
            if (isReSharperInstalled)
            {
                commandTargets.Add(ReSharperKeyUtil.GetOrCreate(_bufferCoordinator));
            }
            commandTargets.Add(new StandardCommandTarget(_bufferCoordinator, _textManager.Object, _broker.Object, _nextTarget.Object));

            var oldCommandFilter = _nextTarget.Object;
            _targetRaw = new VsCommandTarget(
                _bufferCoordinator,
                _textManager.Object,
                _vsAdapter.Object,
                _broker.Object,
                KeyUtil,
                _vimApplicationSettings.Object,
                _nextTarget.Object,
                commandTargets.ToReadOnlyCollectionShallow());
            _target = _targetRaw;
        }
示例#17
0
        protected override VimKeyProcessor CreateKeyProcessor()
        {
            _factory     = new MockRepository(MockBehavior.Strict);
            _wpfTextView = CreateTextView();
            _mockAdapter = new MockAdapter();
            _editorAdaptersFactoryService = _factory.Create <IVsEditorAdaptersFactoryService>();
            _editorAdaptersFactoryService.Setup(x => x.GetViewAdapter(_wpfTextView)).Returns(_mockAdapter);

            _vsAdapter = _factory.Create <IVsAdapter>();
            _vsAdapter.Setup(x => x.IsIncrementalSearchActive(It.IsAny <ITextView>())).Returns(false);
            _vsAdapter.SetupGet(x => x.EditorAdapter).Returns(_editorAdaptersFactoryService.Object);
            _vsAdapter.Setup(x => x.IsReadOnly(_wpfTextView)).Returns(false);
            _reportDesignerUtil = _factory.Create <IReportDesignerUtil>();
            _reportDesignerUtil.Setup(x => x.IsExpressionView(_wpfTextView)).Returns(false);
            _mockVimBuffer = MockObjectFactory.CreateVimBuffer(_wpfTextView);
            _mockVimBuffer.Setup(x => x.CanProcess(It.IsAny <KeyInput>())).Returns(true);
            _mockVimBuffer.Setup(x => x.Process(It.IsAny <KeyInput>())).Returns(ProcessResult.NewHandled(ModeSwitch.NoSwitch));
            _mockVimBuffer.SetupGet(x => x.ModeKind).Returns(ModeKind.Normal);
            _bufferCoordinator = new VimBufferCoordinator(_mockVimBuffer.Object);
            _device            = new MockKeyboardDevice();
            return(new VsVimKeyProcessor(_vsAdapter.Object, _bufferCoordinator, KeyUtil, _reportDesignerUtil.Object));
        }
示例#18
0
 /// <summary>
 /// Create a Visual Studio simulation with the specified set of lines
 /// </summary>
 private void CreateCore(bool simulateResharper, bool usePeekRole, params string[] lines)
 {
     if (usePeekRole)
     {
         _textBuffer = CreateTextBuffer(lines);
         _textView = TextEditorFactoryService.CreateTextView(
             _textBuffer,
             TextEditorFactoryService.CreateTextViewRoleSet(PredefinedTextViewRoles.Document, PredefinedTextViewRoles.Editable, Constants.TextViewRoleEmbeddedPeekTextView));
     }
     else
     {
         _textView = CreateTextView(lines);
         _textBuffer = _textView.TextBuffer;
     }
     _vimBuffer = Vim.CreateVimBuffer(_textView);
     _bufferCoordinator = new VimBufferCoordinator(_vimBuffer);
     _vsSimulation = new VsSimulation(
         _bufferCoordinator,
         simulateResharper: simulateResharper,
         simulateStandardKeyMappings: false,
         editorOperationsFactoryService: EditorOperationsFactoryService,
         keyUtil: KeyUtil);
 }
示例#19
0
 /// <summary>
 /// Create a Visual Studio simulation with the specified set of lines
 /// </summary>
 private void CreateCore(bool simulateResharper, bool usePeekRole, params string[] lines)
 {
     if (usePeekRole)
     {
         _textBuffer = CreateTextBuffer(lines);
         _textView   = TextEditorFactoryService.CreateTextView(
             _textBuffer,
             TextEditorFactoryService.CreateTextViewRoleSet(PredefinedTextViewRoles.Document, PredefinedTextViewRoles.Editable, Constants.TextViewRoleEmbeddedPeekTextView));
     }
     else
     {
         _textView   = CreateTextView(lines);
         _textBuffer = _textView.TextBuffer;
     }
     _vimBuffer         = Vim.CreateVimBuffer(_textView);
     _bufferCoordinator = new VimBufferCoordinator(_vimBuffer);
     _vsSimulation      = new VsSimulation(
         _bufferCoordinator,
         simulateResharper: simulateResharper,
         simulateStandardKeyMappings: false,
         editorOperationsFactoryService: EditorOperationsFactoryService,
         keyUtil: KeyUtil);
 }
示例#20
0
        internal VsSimulation(IVimBufferCoordinator bufferCoordinator, bool simulateResharper, bool simulateStandardKeyMappings, IEditorOperationsFactoryService editorOperationsFactoryService, IKeyUtil keyUtil)
        {
            _keyUtil     = keyUtil;
            _wpfTextView = (IWpfTextView)bufferCoordinator.VimBuffer.TextView;
            _factory     = new MockRepository(MockBehavior.Strict);
            _vsKeyboardInputSimulation   = new VsKeyboardInputSimulation(this, _wpfTextView);
            _simulateStandardKeyMappings = simulateStandardKeyMappings;

            // Create the IVsAdapter and pick reasonable defaults here.  Consumers can modify
            // this via an exposed property
            _vsAdapter = _factory.Create <IVsAdapter>();
            _vsAdapter.SetupGet(x => x.InAutomationFunction).Returns(false);
            _vsAdapter.SetupGet(x => x.KeyboardDevice).Returns(_vsKeyboardInputSimulation.KeyBoardDevice);
            _vsAdapter.Setup(x => x.IsReadOnly(It.IsAny <ITextBuffer>())).Returns(false);
            _vsAdapter.Setup(x => x.IsReadOnly(It.IsAny <ITextView>())).Returns(false);
            _vsAdapter.Setup(x => x.IsIncrementalSearchActive(_wpfTextView)).Returns(false);

            _reportDesignerUtil = _factory.Create <IReportDesignerUtil>();
            _reportDesignerUtil.Setup(x => x.IsExpressionView(_wpfTextView)).Returns(false);

            _displayWindowBroker = _factory.Create <IDisplayWindowBroker>();
            _displayWindowBroker.SetupGet(x => x.IsCompletionActive).Returns(false);
            _displayWindowBroker.SetupGet(x => x.IsQuickInfoActive).Returns(false);
            _displayWindowBroker.SetupGet(x => x.IsSignatureHelpActive).Returns(false);

            _vimApplicationSettings = _factory.Create <IVimApplicationSettings>();
            _vimApplicationSettings.SetupGet(x => x.UseEditorDefaults).Returns(true);
            _vimApplicationSettings.SetupGet(x => x.UseEditorIndent).Returns(true);
            _vimApplicationSettings.SetupGet(x => x.UseEditorTabAndBackspace).Returns(true);

            _commonOperations = _factory.Create <ICommonOperations>();

            _vsSimulationCommandTarget = new SimulationCommandTarget(
                bufferCoordinator.VimBuffer.TextView,
                editorOperationsFactoryService.GetEditorOperations(bufferCoordinator.VimBuffer.TextView));

            var textManager    = _factory.Create <ITextManager>();
            var commandTargets = new List <ICommandTarget>();

            if (simulateResharper)
            {
                commandTargets.Add(ReSharperKeyUtil.GetOrCreate(bufferCoordinator));
            }
            commandTargets.Add(new StandardCommandTarget(
                                   bufferCoordinator,
                                   textManager.Object,
                                   _commonOperations.Object,
                                   _displayWindowBroker.Object,
                                   _vsSimulationCommandTarget));

            // Create the VsCommandTarget.  It's next is the final and default Visual Studio
            // command target
            _vsCommandTarget = new VsCommandTarget(
                bufferCoordinator,
                textManager.Object,
                _vsAdapter.Object,
                _displayWindowBroker.Object,
                _keyUtil,
                _vimApplicationSettings.Object,
                _vsSimulationCommandTarget,
                commandTargets.ToReadOnlyCollectionShallow());

            // Time to setup the start command target.  If we are simulating R# then put them ahead of VsVim
            // on the IOleCommandTarget chain.  VsVim doesn't try to fight R# and prefers instead to be
            // behind them
            if (simulateResharper)
            {
                _reSharperCommandTarget = new ReSharperCommandTargetSimulation(_wpfTextView, _vsCommandTarget);
                _commandTarget          = _reSharperCommandTarget;
            }
            else
            {
                _commandTarget = _vsCommandTarget;
            }

            // Visual Studio hides the default IOleCommandTarget inside of the IWpfTextView property
            // bag.  The default KeyProcessor implementation looks here for IOleCommandTarget to
            // process text input.
            //
            // This should always point to the head of the IOleCommandTarget chain.  In the implementation
            // it actually points to the IVsTextView implementation which then immediately routes to the
            // IOleCommandTarget head
            _wpfTextView.Properties[typeof(IOleCommandTarget)] = _commandTarget;

            // Create the input controller.  Make sure that the VsVim one is ahead in the list
            // from the default Visual Studio one.  We can guarantee this is true due to MEF
            // ordering of the components
            if (simulateResharper)
            {
                _vsKeyboardInputSimulation.KeyProcessors.Add(ReSharperKeyUtil.GetOrCreate(bufferCoordinator));
            }
            _vsKeyboardInputSimulation.KeyProcessors.Add(new VsVimKeyProcessor(_vsAdapter.Object, bufferCoordinator, _keyUtil, _reportDesignerUtil.Object));
            _vsKeyboardInputSimulation.KeyProcessors.Add((KeyProcessor)bufferCoordinator);
            _vsKeyboardInputSimulation.KeyProcessors.Add(new SimulationKeyProcessor(bufferCoordinator.VimBuffer.TextView));
        }
示例#21
0
 ICommandTarget ICommandTargetFactory.CreateCommandTarget(IOleCommandTarget nextCommandTarget, IVimBufferCoordinator vimBufferCoordinator)
 {
     var displayWindowBroker = _displayWindowBrokerFactory.GetDisplayWindowBroker(vimBufferCoordinator.VimBuffer.TextView);
     return new StandardCommandTarget(vimBufferCoordinator, _textManager, displayWindowBroker, nextCommandTarget);
 }
示例#22
0
        ICommandTarget ICommandTargetFactory.CreateCommandTarget(IOleCommandTarget nextCommandTarget, IVimBufferCoordinator vimBufferCoordinator)
        {
            var vimBuffer           = vimBufferCoordinator.VimBuffer;
            var displayWindowBroker = _displayWindowBrokerFactory.GetDisplayWindowBroker(vimBuffer.TextView);
            var commonOperations    = _commonOperationsFactory.GetCommonOperations(vimBuffer.VimBufferData);

            return(new StandardCommandTarget(vimBufferCoordinator, _textManager, commonOperations, displayWindowBroker, nextCommandTarget));
        }
示例#23
0
        internal VsSimulation(IVimBufferCoordinator bufferCoordinator, bool simulateResharper, bool simulateStandardKeyMappings, IEditorOperationsFactoryService editorOperationsFactoryService)
        {
            _wpfTextView = (IWpfTextView)bufferCoordinator.VimBuffer.TextView;
            _factory = new MockRepository(MockBehavior.Strict);
            _defaultKeyboardDevice = new DefaultKeyboardDevice(InputManager.Current);
            _testableSynchronizationContext = new TestableSynchronizationContext();

            // Create the IVsAdapter and pick reasonable defaults here.  Consumers can modify
            // this via an exposed property
            _vsAdapter = _factory.Create<IVsAdapter>();
            _vsAdapter.SetupGet(x => x.InAutomationFunction).Returns(false);
            _vsAdapter.SetupGet(x => x.KeyboardDevice).Returns(_defaultKeyboardDevice);
            _vsAdapter.Setup(x => x.IsReadOnly(It.IsAny<ITextBuffer>())).Returns(false);
            _vsAdapter.Setup(x => x.IsIncrementalSearchActive(_wpfTextView)).Returns(false);

            _resharperUtil = _factory.Create<IResharperUtil>();
            _resharperUtil.SetupGet(x => x.IsInstalled).Returns(simulateResharper);

            _displayWindowBroker = _factory.Create<IDisplayWindowBroker>();
            _displayWindowBroker.SetupGet(x => x.IsCompletionActive).Returns(false);
            _displayWindowBroker.SetupGet(x => x.IsQuickInfoActive).Returns(false);
            _displayWindowBroker.SetupGet(x => x.IsSignatureHelpActive).Returns(false);
            _displayWindowBroker.SetupGet(x => x.IsSmartTagSessionActive).Returns(false);

            _defaultCommandTarget = new DefaultCommandTarget(
                bufferCoordinator.VimBuffer.TextView,
                editorOperationsFactoryService.GetEditorOperations(bufferCoordinator.VimBuffer.TextView));

            // Visual Studio hides the default IOleCommandTarget inside of the IWpfTextView property
            // bag.  The default KeyProcessor implementation looks here for IOleCommandTarget to
            // process text input
            _wpfTextView.Properties[typeof(IOleCommandTarget)] = _defaultCommandTarget;

            // Create the VsCommandTarget.  It's next is the final and default Visual Studio
            // command target
            var vsTextView = _factory.Create<IVsTextView>();
            IOleCommandTarget nextCommandTarget = _defaultCommandTarget;
            vsTextView.Setup(x => x.AddCommandFilter(It.IsAny<IOleCommandTarget>(), out nextCommandTarget)).Returns(VSConstants.S_OK);
            var vsCommandTarget = VsCommandTarget.Create(
                bufferCoordinator,
                vsTextView.Object,
                _vsAdapter.Object,
                _displayWindowBroker.Object,
                _resharperUtil.Object).Value;

            // Time to setup the start command target.  If we are simulating R# then put them ahead of VsVim
            // on the IOleCommandTarget chain.  VsVim doesn't try to fight R# and prefers instead to be
            // behind them
            if (simulateResharper)
            {
                var resharperCommandTarget = new ResharperCommandTarget(_wpfTextView, vsCommandTarget);
                _commandTarget = resharperCommandTarget;
            }
            else
            {
                _commandTarget = vsCommandTarget;
            }

            // Create the input controller.  Make sure that the VsVim one is ahead in the list
            // from the default Visual Studio one.  We can guarantee this is true due to MEF
            // ordering of the components
            var keyProcessors = new List<Microsoft.VisualStudio.Text.Editor.KeyProcessor>();
            keyProcessors.Add(new VsKeyProcessor(_vsAdapter.Object, bufferCoordinator));
            keyProcessors.Add(new SimulationKeyProcessor(bufferCoordinator.VimBuffer.TextView));
            _defaultInputController = new DefaultInputController(bufferCoordinator.VimBuffer.TextView, keyProcessors);
        }
示例#24
0
 /// <summary>
 /// Create a Visual Studio simulation with the specified set of lines
 /// </summary>
 private void Create(bool simulateResharper, params string[] lines)
 {
     _textView = CreateTextView(lines);
     _vimBuffer = Vim.CreateVimBuffer(_textView);
     _bufferCoordinator = new VimBufferCoordinator(_vimBuffer);
     _simulation = new VsSimulation(_bufferCoordinator, simulateResharper);
 }
示例#25
0
 internal static ReSharperKeyUtil GetOrCreate(IVimBufferCoordinator vimBufferCoordinator)
 {
     return(vimBufferCoordinator.VimBuffer.Properties.GetOrCreateSingletonProperty(PropertyBagKey, () => new ReSharperKeyUtil(vimBufferCoordinator)));
 }
示例#26
0
 /// <summary>
 /// Create a Visual Studio simulation with the specified set of lines
 /// </summary>
 private void Create(bool simulateResharper, params string[] lines)
 {
     _textView = CreateTextView(lines);
     _textBuffer = _textView.TextBuffer;
     _vimBuffer = Vim.CreateVimBuffer(_textView);
     _bufferCoordinator = new VimBufferCoordinator(_vimBuffer);
     _simulation = new VsSimulation(
         _bufferCoordinator,
         simulateResharper: simulateResharper,
         simulateStandardKeyMappings: false,
         editorOperationsFactoryService: EditorOperationsFactoryService);
 }
示例#27
0
        public void SetUp()
        {
            _textView = EditorUtil.CreateTextView("");
            _buffer = EditorUtil.FactoryService.Vim.CreateVimBuffer(_textView);
            _bufferCoordinator = new VimBufferCoordinator(_buffer);
            _vim = _buffer.Vim;
            _factory = new MockRepository(MockBehavior.Strict);

            // By default Resharper isn't loaded
            _externalEditorManager = _factory.Create<IExternalEditorManager>();
            _externalEditorManager.SetupGet(x => x.IsResharperInstalled).Returns(false);

            _nextTarget = _factory.Create<IOleCommandTarget>(MockBehavior.Strict);
            _adapter = _factory.Create<IVsAdapter>();
            _adapter.Setup(x => x.InAutomationFunction).Returns(false);
            _adapter.Setup(x => x.InDebugMode).Returns(false);
            _adapter.Setup(x => x.IsIncrementalSearchActive(It.IsAny<ITextView>())).Returns(false);

            _broker = _factory.Create<IDisplayWindowBroker>(MockBehavior.Loose);

            var oldCommandFilter = _nextTarget.Object;
            var vsTextView = _factory.Create<IVsTextView>(MockBehavior.Loose);
            vsTextView.Setup(x => x.AddCommandFilter(It.IsAny<IOleCommandTarget>(), out oldCommandFilter)).Returns(0);
            var result = VsCommandTarget.Create(
                _bufferCoordinator,
                vsTextView.Object,
                _adapter.Object,
                _broker.Object,
                _externalEditorManager.Object);
            Assert.IsTrue(result.IsSuccess);
            _targetRaw = result.Value;
            _target = _targetRaw;
        }
示例#28
0
 private ReSharperKeyUtil(IVimBufferCoordinator vimBufferCoordinator)
 {
     _vimBufferCoordinator = vimBufferCoordinator;
     _vimBuffer = vimBufferCoordinator.VimBuffer;
 }
示例#29
0
        ICommandTarget ICommandTargetFactory.CreateCommandTarget(IOleCommandTarget nextCommandTarget, IVimBufferCoordinator vimBufferCoordinator)
        {
            var displayWindowBroker = _displayWindowBrokerFactory.GetDisplayWindowBroker(vimBufferCoordinator.VimBuffer.TextView);

            return(new StandardCommandTarget(vimBufferCoordinator, _textManager, displayWindowBroker, nextCommandTarget));
        }
示例#30
0
        ICommandTarget ICommandTargetFactory.CreateCommandTarget(IOleCommandTarget nextCommandTarget, IVimBufferCoordinator vimBufferCoordinator)
        {
            if (!_reSharperUtil.IsInstalled)
            {
                return(null);
            }

            return(ReSharperKeyUtil.GetOrCreate(vimBufferCoordinator));
        }
示例#31
0
 private ReSharperKeyUtil(IVimBufferCoordinator vimBufferCoordinator)
 {
     _vimBufferCoordinator = vimBufferCoordinator;
     _vimBuffer            = vimBufferCoordinator.VimBuffer;
 }
示例#32
0
 internal static Result<VsCommandTarget> Create(
     IVimBufferCoordinator bufferCoordinator,
     IVsTextView vsTextView,
     IVsAdapter adapter,
     IDisplayWindowBroker broker,
     IExternalEditorManager externalEditorManager)
 {
     var filter = new VsCommandTarget(bufferCoordinator, adapter, broker, externalEditorManager);
     var hresult = vsTextView.AddCommandFilter(filter, out filter._nextTarget);
     return Result.CreateSuccessOrError(filter, hresult);
 }
示例#33
0
        internal static Result<VsCommandTarget> Create(
            IVimBufferCoordinator bufferCoordinator,
            IVsTextView vsTextView,
            ITextManager textManager,
            IVsAdapter adapter,
            IDisplayWindowBroker broker,
            IResharperUtil resharperUtil,
            IKeyUtil keyUtil)
        {
            var vsCommandTarget = new VsCommandTarget(bufferCoordinator, textManager, adapter, broker, resharperUtil, keyUtil);
            var hresult = vsTextView.AddCommandFilter(vsCommandTarget, out vsCommandTarget._nextTarget);
            var result = Result.CreateSuccessOrError(vsCommandTarget, hresult);
            if (result.IsSuccess)
            {
                bufferCoordinator.VimBuffer.TextView.Properties[Key] = vsCommandTarget;
            }

            return result;
        }
示例#34
0
 internal VsKeyProcessor(IVsAdapter adapter, IVimBufferCoordinator bufferCoordinator)
     : base(bufferCoordinator.VimBuffer)
 {
     _adapter           = adapter;
     _bufferCoordinator = bufferCoordinator;
 }
示例#35
0
        internal VsSimulation(IVimBufferCoordinator bufferCoordinator, bool simulateResharper)
        {
            _wpfTextView = (IWpfTextView)bufferCoordinator.VimBuffer.TextView;
            _factory     = new MockRepository(MockBehavior.Strict);

            // Create the IVsAdapter and pick reasonable defaults here.  Consumers can modify
            // this via an exposed property
            _vsAdapter = _factory.Create <IVsAdapter>();
            _vsAdapter.SetupGet(x => x.InAutomationFunction).Returns(false);
            _vsAdapter.Setup(x => x.IsReadOnly(It.IsAny <ITextBuffer>())).Returns(false);
            _vsAdapter.Setup(x => x.IsIncrementalSearchActive(_wpfTextView)).Returns(false);

            _externalEditorManager = _factory.Create <IExternalEditorManager>();
            _externalEditorManager.SetupGet(x => x.IsResharperInstalled).Returns(simulateResharper);

            _displayWindowBroker = _factory.Create <IDisplayWindowBroker>();
            _displayWindowBroker.SetupGet(x => x.IsCompletionActive).Returns(false);
            _displayWindowBroker.SetupGet(x => x.IsQuickInfoActive).Returns(false);
            _displayWindowBroker.SetupGet(x => x.IsSignatureHelpActive).Returns(false);
            _displayWindowBroker.SetupGet(x => x.IsSmartTagSessionActive).Returns(false);

            _defaultCommandTarget = new DefaultCommandTarget(
                bufferCoordinator.VimBuffer.TextView,
                EditorUtil.GetEditorOperations(bufferCoordinator.VimBuffer.TextView));

            // Visual Studio hides the default IOleCommandTarget inside of the IWpfTextView property
            // bag.  The default KeyProcessor implementation looks here for IOleCommandTarget to
            // process text input
            _wpfTextView.Properties[typeof(IOleCommandTarget)] = _defaultCommandTarget;

            // Create the VsCommandTarget.  It's next is the final and default Visual Studio
            // command target
            var vsTextView = _factory.Create <IVsTextView>();
            IOleCommandTarget nextCommandTarget = _defaultCommandTarget;

            vsTextView.Setup(x => x.AddCommandFilter(It.IsAny <IOleCommandTarget>(), out nextCommandTarget)).Returns(VSConstants.S_OK);
            var vsCommandTarget = VsCommandTarget.Create(
                bufferCoordinator,
                vsTextView.Object,
                _vsAdapter.Object,
                _displayWindowBroker.Object,
                _externalEditorManager.Object).Value;

            // Time to setup the start command target.  If we are simulating R# then put them ahead of VsVim
            // on the IOleCommandTarget chain.  VsVim doesn't try to fight R# and prefers instead to be
            // behind them
            if (simulateResharper)
            {
                var resharperCommandTarget = new ResharperCommandTarget(_wpfTextView, vsCommandTarget);
                _commandTarget = resharperCommandTarget;
            }
            else
            {
                _commandTarget = vsCommandTarget;
            }

            // Create the input controller.  Make sure that the VsVim one is ahead in the list
            // from the default Visual Studio one.  We can guarantee this is true due to MEF
            // ordering of the components
            var keyProcessors = new List <Microsoft.VisualStudio.Text.Editor.KeyProcessor>();

            keyProcessors.Add(new VsKeyProcessor(_vsAdapter.Object, bufferCoordinator));
            keyProcessors.Add(new SimulationKeyProcessor(bufferCoordinator.VimBuffer.TextView));
            _defaultInputController = new DefaultInputController(bufferCoordinator.VimBuffer.TextView, keyProcessors);
            _defaultKeyboardDevice  = new DefaultKeyboardDevice(InputManager.Current);
        }
示例#36
0
 internal VsKeyProcessor(IVsAdapter adapter, IVimBufferCoordinator bufferCoordinator)
     : base(bufferCoordinator.VimBuffer)
 {
     _adapter = adapter;
     _bufferCoordinator = bufferCoordinator;
 }
示例#37
0
        internal VsSimulation(IVimBufferCoordinator bufferCoordinator, bool simulateResharper, bool simulateStandardKeyMappings, IEditorOperationsFactoryService editorOperationsFactoryService, IKeyUtil keyUtil)
        {
            _keyUtil     = keyUtil;
            _wpfTextView = (IWpfTextView)bufferCoordinator.VimBuffer.TextView;
            _factory     = new MockRepository(MockBehavior.Strict);
            _vsKeyProcessorSimulation       = new VsKeyProcessorSimulation(this, _wpfTextView);
            _testableSynchronizationContext = new TestableSynchronizationContext();
            _simulateStandardKeyMappings    = simulateStandardKeyMappings;

            // Create the IVsAdapter and pick reasonable defaults here.  Consumers can modify
            // this via an exposed property
            _vsAdapter = _factory.Create <IVsAdapter>();
            _vsAdapter.SetupGet(x => x.InAutomationFunction).Returns(false);
            _vsAdapter.SetupGet(x => x.KeyboardDevice).Returns(_vsKeyProcessorSimulation.KeyBoardDevice);
            _vsAdapter.Setup(x => x.IsReadOnly(It.IsAny <ITextBuffer>())).Returns(false);
            _vsAdapter.Setup(x => x.IsReadOnly(It.IsAny <ITextView>())).Returns(false);
            _vsAdapter.Setup(x => x.IsIncrementalSearchActive(_wpfTextView)).Returns(false);

            _resharperUtil = _factory.Create <IResharperUtil>();
            _resharperUtil.SetupGet(x => x.IsInstalled).Returns(simulateResharper);

            _displayWindowBroker = _factory.Create <IDisplayWindowBroker>();
            _displayWindowBroker.SetupGet(x => x.IsCompletionActive).Returns(false);
            _displayWindowBroker.SetupGet(x => x.IsQuickInfoActive).Returns(false);
            _displayWindowBroker.SetupGet(x => x.IsSignatureHelpActive).Returns(false);
            _displayWindowBroker.SetupGet(x => x.IsSmartTagSessionActive).Returns(false);

            _defaultCommandTarget = new DefaultCommandTarget(
                bufferCoordinator.VimBuffer.TextView,
                editorOperationsFactoryService.GetEditorOperations(bufferCoordinator.VimBuffer.TextView));

            // Create the VsCommandTarget.  It's next is the final and default Visual Studio
            // command target
            var vsTextView = _factory.Create <IVsTextView>();
            IOleCommandTarget nextCommandTarget = _defaultCommandTarget;

            vsTextView.Setup(x => x.AddCommandFilter(It.IsAny <IOleCommandTarget>(), out nextCommandTarget)).Returns(VSConstants.S_OK);
            var vsCommandTarget = VsCommandTarget.Create(
                bufferCoordinator,
                vsTextView.Object,
                _factory.Create <ITextManager>().Object,
                _vsAdapter.Object,
                _displayWindowBroker.Object,
                _resharperUtil.Object,
                _keyUtil).Value;

            // Time to setup the start command target.  If we are simulating R# then put them ahead of VsVim
            // on the IOleCommandTarget chain.  VsVim doesn't try to fight R# and prefers instead to be
            // behind them
            if (simulateResharper)
            {
                var resharperCommandTarget = new ResharperCommandTarget(_wpfTextView, vsCommandTarget);
                _commandTarget = resharperCommandTarget;
            }
            else
            {
                _commandTarget = vsCommandTarget;
            }

            // Visual Studio hides the default IOleCommandTarget inside of the IWpfTextView property
            // bag.  The default KeyProcessor implementation looks here for IOleCommandTarget to
            // process text input.
            //
            // This should always point to the head of the IOleCommandTarget chain.  In the implementation
            // it actually points to the IVsTextView implementation which then immediately routes to the
            // IOleCommandTarget head
            _wpfTextView.Properties[typeof(IOleCommandTarget)] = _commandTarget;

            // Create the input controller.  Make sure that the VsVim one is ahead in the list
            // from the default Visual Studio one.  We can guarantee this is true due to MEF
            // ordering of the components
            _vsKeyProcessorSimulation.KeyProcessors.Add(new VsKeyProcessor(_vsAdapter.Object, bufferCoordinator, _keyUtil));
            _vsKeyProcessorSimulation.KeyProcessors.Add(new SimulationKeyProcessor(bufferCoordinator.VimBuffer.TextView));
        }
示例#38
0
 protected override void Setup(string languageId)
 {
     base.Setup(languageId);
     _factory = new MockRepository(MockBehavior.Strict);
     _textBuffer = _factory.Create<ITextBuffer>();
     _adapter = _factory.Create<IVsAdapter>();
     _adapter.Setup(x => x.IsReadOnly(_textBuffer.Object)).Returns(false);
     _adapter.Setup(x => x.IsIncrementalSearchActive(It.IsAny<ITextView>())).Returns(false);
     _buffer = MockObjectFactory.CreateVimBuffer(_textBuffer.Object);
     _bufferCoordinator = new VimBufferCoordinator(_buffer.Object);
     _vsProcessor = new VsKeyProcessor(_adapter.Object, _bufferCoordinator);
     _processor = _vsProcessor;
     _device = new MockKeyboardDevice();
 }
示例#39
0
        internal static Result<VsCommandTarget> Create(
            IVimBufferCoordinator vimBufferCoordinator,
            IVsTextView vsTextView,
            ITextManager textManager,
            IVsAdapter adapter,
            IDisplayWindowBroker broker,
            IKeyUtil keyUtil,
            IVimApplicationSettings vimApplicationSettings,
            ReadOnlyCollection<ICommandTargetFactory> commandTargetFactoryList)
        {
            var vsCommandTarget = new VsCommandTarget(vimBufferCoordinator, textManager, adapter, broker, keyUtil, vimApplicationSettings);

            IOleCommandTarget nextCommandTarget;
            var hresult = vsTextView.AddCommandFilter(vsCommandTarget, out nextCommandTarget);
            if (ErrorHandler.Failed(hresult))
            {
                return Result.CreateError(hresult);
            }

            var commandTargets = commandTargetFactoryList
                .Select(x => x.CreateCommandTarget(nextCommandTarget, vimBufferCoordinator))
                .Where(x => x != null)
                .ToReadOnlyCollection();
            vsCommandTarget.CompleteInit(nextCommandTarget, commandTargets);
            return Result.CreateSuccess(vsCommandTarget);
        }
示例#40
0
        internal VsSimulation(IVimBufferCoordinator bufferCoordinator, bool simulateResharper, bool simulateStandardKeyMappings, IEditorOperationsFactoryService editorOperationsFactoryService, IKeyUtil keyUtil)
        {
            _keyUtil = keyUtil;
            _wpfTextView = (IWpfTextView)bufferCoordinator.VimBuffer.TextView;
            _factory = new MockRepository(MockBehavior.Strict);
            _vsKeyboardInputSimulation = new VsKeyboardInputSimulation(this, _wpfTextView);
            _testableSynchronizationContext = new TestableSynchronizationContext();
            _simulateStandardKeyMappings = simulateStandardKeyMappings;

            // Create the IVsAdapter and pick reasonable defaults here.  Consumers can modify 
            // this via an exposed property
            _vsAdapter = _factory.Create<IVsAdapter>();
            _vsAdapter.SetupGet(x => x.InAutomationFunction).Returns(false);
            _vsAdapter.SetupGet(x => x.KeyboardDevice).Returns(_vsKeyboardInputSimulation.KeyBoardDevice);
            _vsAdapter.Setup(x => x.IsReadOnly(It.IsAny<ITextBuffer>())).Returns(false);
            _vsAdapter.Setup(x => x.IsReadOnly(It.IsAny<ITextView>())).Returns(false);
            _vsAdapter.Setup(x => x.IsIncrementalSearchActive(_wpfTextView)).Returns(false);

            _reportDesignerUtil = _factory.Create<IReportDesignerUtil>();
            _reportDesignerUtil.Setup(x => x.IsExpressionView(_wpfTextView)).Returns(false);

            _displayWindowBroker = _factory.Create<IDisplayWindowBroker>();
            _displayWindowBroker.SetupGet(x => x.IsCompletionActive).Returns(false);
            _displayWindowBroker.SetupGet(x => x.IsQuickInfoActive).Returns(false);
            _displayWindowBroker.SetupGet(x => x.IsSignatureHelpActive).Returns(false);
            _displayWindowBroker.SetupGet(x => x.IsSmartTagSessionActive).Returns(false);

            _vimApplicationSettings = _factory.Create<IVimApplicationSettings>();
            _vimApplicationSettings.SetupGet(x => x.UseEditorDefaults).Returns(true);
            _vimApplicationSettings.SetupGet(x => x.UseEditorIndent).Returns(true);
            _vimApplicationSettings.SetupGet(x => x.UseEditorTabAndBackspace).Returns(true);

            _vsSimulationCommandTarget = new SimulationCommandTarget(
                bufferCoordinator.VimBuffer.TextView,
                editorOperationsFactoryService.GetEditorOperations(bufferCoordinator.VimBuffer.TextView));

            var textManager = _factory.Create<ITextManager>();
            var commandTargets = new List<ICommandTarget>();
            if (simulateResharper)
            {
                commandTargets.Add(ReSharperKeyUtil.GetOrCreate(bufferCoordinator));
            }
            commandTargets.Add(new StandardCommandTarget(bufferCoordinator, textManager.Object, _displayWindowBroker.Object, _vsSimulationCommandTarget));

            // Create the VsCommandTarget.  It's next is the final and default Visual Studio 
            // command target
            _vsCommandTarget = new VsCommandTarget(
                bufferCoordinator,
                textManager.Object,
                _vsAdapter.Object,
                _displayWindowBroker.Object,
                _keyUtil,
                _vimApplicationSettings.Object,
                _vsSimulationCommandTarget,
                commandTargets.ToReadOnlyCollectionShallow());

            // Time to setup the start command target.  If we are simulating R# then put them ahead of VsVim
            // on the IOleCommandTarget chain.  VsVim doesn't try to fight R# and prefers instead to be 
            // behind them
            if (simulateResharper)
            {
                _reSharperCommandTarget = new ReSharperCommandTargetSimulation(_wpfTextView, _vsCommandTarget);
                _commandTarget = _reSharperCommandTarget;
            }
            else
            {
                _commandTarget = _vsCommandTarget;
            }

            // Visual Studio hides the default IOleCommandTarget inside of the IWpfTextView property
            // bag.  The default KeyProcessor implementation looks here for IOleCommandTarget to 
            // process text input.  
            //
            // This should always point to the head of the IOleCommandTarget chain.  In the implementation
            // it actually points to the IVsTextView implementation which then immediately routes to the
            // IOleCommandTarget head
            _wpfTextView.Properties[typeof(IOleCommandTarget)] = _commandTarget;

            // Create the input controller.  Make sure that the VsVim one is ahead in the list
            // from the default Visual Studio one.  We can guarantee this is true due to MEF 
            // ordering of the components
            if (simulateResharper)
            {
                _vsKeyboardInputSimulation.KeyProcessors.Add(ReSharperKeyUtil.GetOrCreate(bufferCoordinator));
            }
            _vsKeyboardInputSimulation.KeyProcessors.Add(new VsVimKeyProcessor(_vsAdapter.Object, bufferCoordinator, _keyUtil, _reportDesignerUtil.Object));
            _vsKeyboardInputSimulation.KeyProcessors.Add((KeyProcessor)bufferCoordinator);
            _vsKeyboardInputSimulation.KeyProcessors.Add(new SimulationKeyProcessor(bufferCoordinator.VimBuffer.TextView));
        }
示例#41
0
 internal static ReSharperKeyUtil GetOrCreate(IVimBufferCoordinator vimBufferCoordinator)
 {
     return vimBufferCoordinator.VimBuffer.Properties.GetOrCreateSingletonProperty(s_propertyBagKey, () => new ReSharperKeyUtil(vimBufferCoordinator));
 }
示例#42
0
 private ReSharperKeyUtil(IVimBufferCoordinator vimBufferCoordinator)
 {
     _vimBufferCoordinator     = vimBufferCoordinator;
     _vimBuffer                = vimBufferCoordinator.VimBuffer;
     _vimBuffer.KeyInputStart += OnBufferKeyInputStart;
 }