public void Create(params string[] lines)
 {
     _textView = CreateTextView(lines);
     _textView.Caret.MoveTo(new SnapshotPoint(_textView.TextSnapshot, 0));
     _textBuffer = _textView.TextBuffer;
     _factory = new MockRepository(MockBehavior.Strict);
     _editOpts = _factory.Create<IEditorOperations>();
     _vimHost = _factory.Create<IVimHost>();
     _vimHost.Setup(x => x.IsDirty(It.IsAny<ITextBuffer>())).Returns(false);
     _operations = _factory.Create<ICommonOperations>();
     _operations.SetupGet(x => x.EditorOperations).Returns(_editOpts.Object);
     _statusUtil = _factory.Create<IStatusUtil>();
     _fileSystem = _factory.Create<IFileSystem>(MockBehavior.Strict);
     _foldManager = _factory.Create<IFoldManager>(MockBehavior.Strict);
     _vimData = new VimData();
     _vim = MockObjectFactory.CreateVim(RegisterMap, host: _vimHost.Object, vimData: _vimData, factory: _factory);
     var localSettings = new LocalSettings(Vim.GlobalSettings);
     var vimTextBuffer = MockObjectFactory.CreateVimTextBuffer(
         _textBuffer,
         vim: _vim.Object,
         localSettings: localSettings,
         factory: _factory);
     var vimBufferData = CreateVimBufferData(
         vimTextBuffer.Object,
         _textView,
         statusUtil: _statusUtil.Object);
     var vimBuffer = CreateVimBuffer(vimBufferData);
     _interpreter = new Interpreter.VimInterpreter(
         vimBuffer,
         _operations.Object,
         _foldManager.Object,
         _fileSystem.Object,
         _factory.Create<IBufferTrackingService>().Object);
 }
Exemple #2
0
 private void Create(ITextView textView)
 {
     _textView = textView;
     _textBuffer = textView.TextBuffer;
     _buffer = _textView.TextBuffer;
     _snapshot = _buffer.CurrentSnapshot;
     _buffer.Changed += delegate { _snapshot = _buffer.CurrentSnapshot; };
     _globalSettings = new Vim.GlobalSettings();
     _localSettings = new LocalSettings(_globalSettings, _textView);
     _markMap = new MarkMap(new TrackingLineColumnService());
     _vimData = new VimData();
     _search = VimUtil.CreateSearchService(_globalSettings);
     _jumpList = VimUtil.CreateJumpList();
     _statusUtil = new Mock<IStatusUtil>(MockBehavior.Strict);
     _navigator = VimUtil.CreateTextStructureNavigator(_textView.TextBuffer);
     _motionUtil = new MotionUtil(
         _textView,
         _markMap,
         _localSettings,
         _search,
         _navigator,
         _jumpList,
         _statusUtil.Object,
         _vimData);
 }
Exemple #3
0
 private void Create(ITextView textView, IEditorOptions editorOptions = null)
 {
     _textView = textView;
     _textBuffer = textView.TextBuffer;
     _snapshot = _textBuffer.CurrentSnapshot;
     _textBuffer.Changed += delegate { _snapshot = _textBuffer.CurrentSnapshot; };
     _globalSettings = new Vim.GlobalSettings();
     _localSettings = new LocalSettings(_globalSettings, FSharpOption.CreateForReference(editorOptions), FSharpOption.CreateForReference(textView));
     _markMap = new MarkMap(new TrackingLineColumnService());
     _vimData = new VimData();
     _search = VimUtil.CreateSearchService(_globalSettings);
     _jumpList = VimUtil.CreateJumpList();
     _statusUtil = new Mock<IStatusUtil>(MockBehavior.Strict);
     _navigator = VimUtil.CreateTextStructureNavigator(_textView, WordKind.NormalWord);
     _motionUtil = new MotionUtil(
         _textView,
         _markMap,
         _localSettings,
         _search,
         _navigator,
         _jumpList,
         _statusUtil.Object,
         VimUtil.GetWordUtil(textView),
         _vimData);
 }
Exemple #4
0
        public void Create(params string[] lines)
        {
            _textView = EditorUtil.CreateTextView(lines);
            _vimData = new VimData();
            _editorOptions = EditorUtil.FactoryService.EditorOptionsFactory.GetOptions(_textView);
            _textView.Caret.MoveTo(new SnapshotPoint(_textView.TextSnapshot, 0));
            _textBuffer = _textView.TextBuffer;
            _factory = new MockRepository(MockBehavior.Strict);
            _registerMap = VimUtil.CreateRegisterMap(MockObjectFactory.CreateClipboardDevice(_factory).Object);
            _host = _factory.Create<IVimHost>();
            _jumpList = _factory.Create<IJumpList>();
            _editorOperations = _factory.Create<IEditorOperations>();
            _editorOperations.Setup(x => x.AddAfterTextBufferChangePrimitive());
            _editorOperations.Setup(x => x.AddBeforeTextBufferChangePrimitive());
            _globalSettings = _factory.Create<IVimGlobalSettings>();
            _globalSettings.SetupGet(x => x.Magic).Returns(true);
            _globalSettings.SetupGet(x => x.SmartCase).Returns(false);
            _globalSettings.SetupGet(x => x.IgnoreCase).Returns(true);
            _globalSettings.SetupGet(x => x.IsVirtualEditOneMore).Returns(false);
            _globalSettings.SetupGet(x => x.UseEditorIndent).Returns(false);
            _globalSettings.SetupGet(x => x.UseEditorSettings).Returns(false);
            _globalSettings.SetupGet(x => x.VirtualEdit).Returns(String.Empty);
            _globalSettings.SetupGet(x => x.WrapScan).Returns(true);
            _settings = MockObjectFactory.CreateLocalSettings(_globalSettings.Object, _factory);
            _settings.SetupGet(x => x.AutoIndent).Returns(false);
            _settings.SetupGet(x => x.GlobalSettings).Returns(_globalSettings.Object);
            _settings.SetupGet(x => x.ExpandTab).Returns(true);
            _settings.SetupGet(x => x.TabStop).Returns(4);
            _outlining = _factory.Create<IOutliningManager>();
            _outlining
                .Setup(x => x.ExpandAll(It.IsAny<SnapshotSpan>(), It.IsAny<Predicate<ICollapsed>>()))
                .Returns<IEnumerable<ICollapsible>>(null);
            _globalSettings.SetupGet(x => x.ShiftWidth).Returns(2);
            _statusUtil = _factory.Create<IStatusUtil>();
            _searchService = VimUtil.CreateSearchService(_globalSettings.Object);
            _undoRedoOperations = VimUtil.CreateUndoRedoOperations(_statusUtil.Object);

            var data = new OperationsData(
                vimData: _vimData,
                vimHost: _host.Object,
                editorOperations: _editorOperations.Object,
                textView: _textView,
                outliningManager: FSharpOption.Create(_outlining.Object),
                jumpList: _jumpList.Object,
                localSettings: _settings.Object,
                undoRedoOperations: _undoRedoOperations,
                registerMap: _registerMap,
                editorOptions: _editorOptions,
                keyMap: null,
                statusUtil: _statusUtil.Object,
                foldManager: null,
                searchService: _searchService,
                wordUtil: VimUtil.GetWordUtil(_textView));

            _operationsRaw = new CommonOperations(data);
            _operations = _operationsRaw;
        }
 protected void Create(params string[] lines)
 {
     _textView = CreateTextView(lines);
     _textBuffer = _textView.TextBuffer;
     _globalSettings = Vim.GlobalSettings;
     _globalSettings.IgnoreCase = true;
     _globalSettings.HighlightSearch = true;
     _vimData = Vim.VimData;
     _asyncTaggerSourceRaw = new HighlightSearchTaggerSource(
         _textView,
         _globalSettings,
         _vimData,
         Vim.VimHost);
     _asyncTaggerSource = _asyncTaggerSourceRaw;
 }
Exemple #6
0
 internal static ICommonOperations CreateCommonOperations(
     ITextView textView,
     IVimLocalSettings localSettings,
     IOutliningManager outlining = null,
     IStatusUtil statusUtil = null,
     ISearchService searchService = null,
     IUndoRedoOperations undoRedoOperations = null,
     IVimData vimData = null,
     IVimHost vimHost = null,
     ITextStructureNavigator navigator = null,
     IClipboardDevice clipboardDevice = null,
     IFoldManager foldManager = null)
 {
     var editorOperations = EditorUtil.GetOperations(textView);
     var editorOptions = EditorUtil.FactoryService.EditorOptionsFactory.GetOptions(textView);
     var jumpList = new JumpList(new TrackingLineColumnService());
     var keyMap = new KeyMap();
     foldManager = foldManager ?? new FoldManager(textView.TextBuffer);
     statusUtil = statusUtil ?? new StatusUtil();
     searchService = searchService ?? CreateSearchService(localSettings.GlobalSettings);
     undoRedoOperations = undoRedoOperations ??
                          new UndoRedoOperations(statusUtil, FSharpOption<ITextUndoHistory>.None);
     vimData = vimData ?? new VimData();
     vimHost = vimHost ?? new MockVimHost();
     navigator = navigator ?? CreateTextStructureNavigator(textView.TextBuffer);
     clipboardDevice = clipboardDevice ?? new MockClipboardDevice();
     var operationsData = new OperationsData(
         editorOperations,
         editorOptions,
         foldManager,
         jumpList,
         keyMap,
         localSettings,
         outlining != null ? FSharpOption.Create(outlining) : FSharpOption<IOutliningManager>.None,
         CreateRegisterMap(clipboardDevice),
         searchService,
         EditorUtil.FactoryService.SmartIndentationService,
         statusUtil,
         textView,
         undoRedoOperations,
         vimData,
         vimHost,
         navigator);
     return new CommonOperations(operationsData);
 }
Exemple #7
0
        protected void Create(ITextView textView)
        {
            _textView = textView;
            _textBuffer = textView.TextBuffer;
            _snapshot = _textBuffer.CurrentSnapshot;
            _textBuffer.Changed += delegate { _snapshot = _textBuffer.CurrentSnapshot; };

            _vimTextBuffer = Vim.CreateVimTextBuffer(_textBuffer);
            _statusUtil = new Mock<IStatusUtil>(MockBehavior.Strict);
            var vimBufferData = CreateVimBufferData(_vimTextBuffer, _textView, statusUtil: _statusUtil.Object);
            _globalSettings = vimBufferData.LocalSettings.GlobalSettings;
            _localSettings = vimBufferData.LocalSettings;
            _markMap = vimBufferData.Vim.MarkMap;
            _vimData = vimBufferData.Vim.VimData;
            _search = vimBufferData.Vim.SearchService;
            var wordNavigator = CreateTextStructureNavigator(_textView.TextBuffer, WordKind.NormalWord);
            _motionUtil = new MotionUtil(vimBufferData);
        }
        protected virtual void Create(params string[] lines)
        {
            _textView = CreateTextView(lines);
            _textBuffer = _textView.TextBuffer;
            _vimBuffer = Vim.CreateVimBuffer(_textView);
            _vimBuffer.ErrorMessage +=
                (_, message) =>
                {
                    if (_assertOnErrorMessage)
                    {
                        throw new Exception("Error Message: " + message.Message);
                    }
                };
            _vimBuffer.WarningMessage +=
                (_, message) =>
                {
                    if (_assertOnWarningMessage)
                    {
                        throw new Exception("Warning Message: " + message.Message);
                    }
                };
            _vimBufferData = _vimBuffer.VimBufferData;
            _vimTextBuffer = _vimBuffer.VimTextBuffer;
            _normalMode = _vimBuffer.NormalMode;
            _keyMap = _vimBuffer.Vim.KeyMap;
            _localSettings = _vimBuffer.LocalSettings;
            _globalSettings = _localSettings.GlobalSettings;
            _windowSettings = _vimBuffer.WindowSettings;
            _jumpList = _vimBuffer.JumpList;
            _vimHost = (MockVimHost)_vimBuffer.Vim.VimHost;
            _vimHost.BeepCount = 0;
            _vimData = Vim.VimData;
            _foldManager = FoldManagerFactory.GetFoldManager(_textView);
            _clipboardDevice = (TestableClipboardDevice)CompositionContainer.GetExportedValue<IClipboardDevice>();

            // Many of the operations operate on both the visual and edit / text snapshot
            // simultaneously.  Ensure that our setup code is producing a proper IElisionSnapshot
            // for the Visual portion so we can root out any bad mixing of instances between
            // the two
            Assert.True(_textView.VisualSnapshot is IElisionSnapshot);
            Assert.True(_textView.VisualSnapshot != _textView.TextSnapshot);
        }
Exemple #9
0
        protected void Create(params string[] lines)
        {
            _vimHost = (MockVimHost)Vim.VimHost;
            _textView = CreateTextView(lines);
            _textBuffer = _textView.TextBuffer;
            _vimTextBuffer = CreateVimTextBufferCore(_textBuffer);
            _localSettings = _vimTextBuffer.LocalSettings;

            var foldManager = CreateFoldManager(_textView);

            _factory = new MockRepository(MockBehavior.Loose);
            _statusUtil = _factory.Create<IStatusUtil>();
            _bulkOperations = new TestableBulkOperations();

            var vimBufferData = CreateVimBufferData(
                _vimTextBuffer,
                _textView,
                statusUtil: _statusUtil.Object);
            _jumpList = vimBufferData.JumpList;
            _windowSettings = vimBufferData.WindowSettings;

            _vimData = Vim.VimData;
            _macroRecorder = Vim.MacroRecorder;
            _globalSettings = Vim.GlobalSettings;

            var operations = CreateCommonOperations(vimBufferData);
            var lineChangeTracker = new LineChangeTracker(vimBufferData);
            _motionUtil = new MotionUtil(vimBufferData, operations);
            _commandUtil = new CommandUtil(
                vimBufferData,
                _motionUtil,
                operations,
                foldManager,
                new InsertUtil(vimBufferData, _motionUtil, operations),
                _bulkOperations,
                MouseDevice,
                lineChangeTracker);

            var outliningManagerService = CompositionContainer.GetExportedValue<IOutliningManagerService>();
            _outliningManager = outliningManagerService.GetOutliningManager(_textView);
        }
Exemple #10
0
        private void Create(params string[] lines)
        {
            _vimHost = (MockVimHost)Vim.VimHost;
            _textView = CreateTextView(lines);
            _globalSettings = Vim.GlobalSettings;
            _globalSettings.IncrementalSearch = true;
            _globalSettings.WrapScan = true;

            var vimTextBuffer = Vim.CreateVimTextBuffer(_textView.TextBuffer);

            _factory = new MockRepository(MockBehavior.Strict);
            _statusUtil = _factory.Create<IStatusUtil>();
            _statusUtil.Setup(x => x.OnWarning(Resources.Common_SearchBackwardWrapped));
            _statusUtil.Setup(x => x.OnWarning(Resources.Common_SearchForwardWrapped));

            _vimData = Vim.VimData;
            var vimBufferData = CreateVimBufferData(vimTextBuffer, _textView);
            var operations = CommonOperationsFactory.GetCommonOperations(vimBufferData);
            _searchRaw = new IncrementalSearch(vimBufferData, operations);
            _search = _searchRaw;
        }
Exemple #11
0
 protected void Create(params string[] lines)
 {
     _statusUtil = new TestableStatusUtil();
     _vimData = Vim.VimData;
     _vimBufferData = CreateVimBufferData(
         CreateTextView(lines),
         statusUtil: _statusUtil);
     _vimBuffer = CreateVimBuffer(_vimBufferData);
     _vimTextBuffer = _vimBufferData.VimTextBuffer;
     _localSettings = _vimBufferData.LocalSettings;
     _globalSettings = _localSettings.GlobalSettings;
     _textBuffer = _vimBufferData.TextBuffer;
     _textView = _vimBufferData.TextView;
     _interpreter = new global::Vim.Interpreter.Interpreter(
         _vimBuffer,
         CommonOperationsFactory.GetCommonOperations(_vimBufferData),
         FoldManagerFactory.GetFoldManager(_vimBufferData.TextView),
         new FileSystem(),
         BufferTrackingService);
     _keyMap = Vim.KeyMap;
 }
Exemple #12
0
 public static Mock<IVim> CreateVim(
     IRegisterMap registerMap = null,
     IMarkMap map = null,
     IVimGlobalSettings settings = null,
     IVimHost host = null,
     IKeyMap keyMap = null,
     IKeyboardDevice keyboardDevice = null,
     IMouseDevice mouseDevice = null,
     IVimData vimData = null,
     IMacroRecorder macroRecorder = null,
     ISearchService searchService = null,
     Dictionary<string, VariableValue> variableMap = null,
     MockRepository factory = null)
 {
     factory = factory ?? new MockRepository(MockBehavior.Strict);
     registerMap = registerMap ?? CreateRegisterMap().Object;
     map = map ?? new MarkMap(new BufferTrackingService());
     settings = settings ?? new GlobalSettings();
     host = host ?? new MockVimHost();
     keyMap = keyMap ?? (new KeyMap(settings, new Dictionary<string, VariableValue>()));
     macroRecorder = macroRecorder ?? CreateMacroRecorder(factory: factory).Object;
     searchService = searchService ?? factory.Create<ISearchService>().Object;
     keyboardDevice = keyboardDevice ?? (factory.Create<IKeyboardDevice>(MockBehavior.Loose)).Object;
     mouseDevice = mouseDevice ?? (factory.Create<IMouseDevice>(MockBehavior.Loose)).Object;
     vimData = vimData ?? VimUtil.CreateVimData();
     variableMap = variableMap ?? new Dictionary<string, VariableValue>();
     var mock = factory.Create<IVim>(MockBehavior.Strict);
     mock.SetupGet(x => x.RegisterMap).Returns(registerMap);
     mock.SetupGet(x => x.MarkMap).Returns(map);
     mock.SetupGet(x => x.GlobalSettings).Returns(settings);
     mock.SetupGet(x => x.VimHost).Returns(host);
     mock.SetupGet(x => x.KeyMap).Returns(keyMap);
     mock.SetupGet(x => x.VimData).Returns(vimData);
     mock.SetupGet(x => x.MacroRecorder).Returns(macroRecorder);
     mock.SetupGet(x => x.SearchService).Returns(searchService);
     mock.SetupGet(x => x.VariableMap).Returns(variableMap);
     return mock;
 }
Exemple #13
0
        private void Create(params string[] lines)
        {
            _textBuffer = CreateTextBuffer(lines);
            _textView = MockObjectFactory.CreateTextView(_textBuffer);
            _textView.SetupGet(x => x.HasAggregateFocus).Returns(true);

            // Setup normal mode so that we can provide an ICommandRunner to 
            // recieve commands from
            _factory = new MockRepository(MockBehavior.Loose) {DefaultValue = DefaultValue.Mock};
            _runner = _factory.Create<ICommandRunner>(MockBehavior.Loose);
            _normalMode = _factory.Create<INormalMode>(MockBehavior.Strict);
            _normalMode.SetupGet(x => x.CommandRunner).Returns(_runner.Object);

            // Create the IVimBuffer instance
            _buffer = _factory.Create<IVimBuffer>(MockBehavior.Loose);
            _buffer.DefaultValue = DefaultValue.Mock;
            _buffer.SetupGet(x => x.NormalMode).Returns(_normalMode.Object);

            _vimData = VimUtil.CreateVimData();
            var vim = MockObjectFactory.CreateVim(vimData: _vimData);
            _tracker = new ChangeTracker(vim.Object);
            _tracker.OnVimBufferCreated(_buffer.Object);
        }
Exemple #14
0
 public virtual void VimDataCreated(IVimData vimData)
 {
 }
Exemple #15
0
 string IVimHost.RunCommand(string command, string arguments, IVimData vimData)
 {
     return(RunCommandFunc(command, arguments, vimData));
 }
Exemple #16
0
        public void CreateCore(IMotionUtil motionUtil, params string[] lines)
        {
            _textView = EditorUtil.CreateTextView(lines);
            _textView.Caret.MoveTo(new SnapshotPoint(_textView.TextSnapshot, 0));
            _map = VimUtil.CreateRegisterMap(MockObjectFactory.CreateClipboardDevice().Object);
            _unnamedRegister = _map.GetRegister(RegisterName.Unnamed);
            _factory = new MockRepository(MockBehavior.Strict);
            _editorOperations = _factory.Create<IEditorOperations>(MockBehavior.Loose);
            _incrementalSearch = MockObjectFactory.CreateIncrementalSearch(factory: _factory);
            _jumpList = _factory.Create<IJumpList>(MockBehavior.Strict);
            _statusUtil = _factory.Create<IStatusUtil>(MockBehavior.Strict);
            _foldManager = _factory.Create<IFoldManager>(MockBehavior.Strict);
            _host = _factory.Create<IVimHost>(MockBehavior.Loose);
            _commandUtil = _factory.Create<ICommandUtil>();
            _displayWindowBroker = _factory.Create<IDisplayWindowBroker>(MockBehavior.Strict);
            _displayWindowBroker.SetupGet(x => x.IsCompletionActive).Returns(false);
            _displayWindowBroker.SetupGet(x => x.IsSignatureHelpActive).Returns(false);
            _displayWindowBroker.SetupGet(x => x.IsSmartTagSessionActive).Returns(false);
            _vimData = new VimData();

            _globalSettings = new Vim.GlobalSettings();
            _localSettings = new LocalSettings(_globalSettings, EditorUtil.GetEditorOptions(_textView), _textView);
            motionUtil = motionUtil ?? VimUtil.CreateTextViewMotionUtil(
                _textView,
                new MarkMap(new TrackingLineColumnService()),
                _localSettings);
            _buffer = MockObjectFactory.CreateVimBuffer(
                _textView,
                "test",
                MockObjectFactory.CreateVim(_map, host: _host.Object, vimData: _vimData).Object,
                _jumpList.Object,
                incrementalSearch: _incrementalSearch.Object,
                motionUtil: motionUtil,
                settings: _localSettings);
            _operations = _factory.Create<ICommonOperations>(MockBehavior.Strict);
            _operations.SetupGet(x => x.EditorOperations).Returns(_editorOperations.Object);
            _operations.SetupGet(x => x.TextView).Returns(_textView);

            var capture = new MotionCapture(
                _host.Object,
                _textView,
                _incrementalSearch.Object,
                new LocalSettings(new GlobalSettings(), EditorUtil.GetEditorOptions(_textView), _textView));
            var runner = new CommandRunner(_textView, _map, capture, _commandUtil.Object, _statusUtil.Object, VisualKind.Character);
            _modeRaw = new NormalMode(
                _buffer.Object,
                _operations.Object,
                _statusUtil.Object,
                _displayWindowBroker.Object,
                runner,
                capture);
            _mode = _modeRaw;
            _mode.OnEnter(ModeArgument.None);
        }
Exemple #17
0
 RunCommandResults IVimHost.RunCommand(string command, string arguments, string input, IVimData vimData)
 {
     return(RunCommand(command, arguments, input, vimData));
 }
Exemple #18
0
 protected VimDataTest()
 {
     _globalSettings = new GlobalSettings();
     _vimDataRaw = new VimData(_globalSettings);
     _vimData = _vimDataRaw;
 }
 public void Create(params string[] lines)
 {
     _textView = CreateTextView(lines);
     _textView.Caret.MoveTo(new SnapshotPoint(_textView.TextSnapshot, 0));
     _textBuffer = _textView.TextBuffer;
     _factory = new MockRepository(MockBehavior.Strict);
     _registerMap = VimUtil.CreateRegisterMap(MockObjectFactory.CreateClipboardDevice(_factory).Object);
     _editOpts = _factory.Create<IEditorOperations>();
     _vimHost = _factory.Create<IVimHost>();
     _operations = _factory.Create<ICommonOperations>();
     _operations.SetupGet(x => x.EditorOperations).Returns(_editOpts.Object);
     _commandOperations = _factory.Create<IOperations>();
     _statusUtil = _factory.Create<IStatusUtil>();
     _fileSystem = _factory.Create<IFileSystem>(MockBehavior.Strict);
     _foldManager = _factory.Create<IFoldManager>(MockBehavior.Strict);
     _vimData = new VimData();
     _vim = MockObjectFactory.CreateVim(_registerMap, host: _vimHost.Object, vimData: _vimData, factory: _factory);
     var localSettings = new LocalSettings(Vim.GlobalSettings);
     var vimTextBuffer = MockObjectFactory.CreateVimTextBuffer(
         _textBuffer,
         vim: _vim.Object,
         localSettings: localSettings,
         factory: _factory);
     var vimBufferData = CreateVimBufferData(
         vimTextBuffer.Object,
         _textView,
         statusUtil: _statusUtil.Object);
     _processorRaw = new CommandProcessor(
         vimBufferData,
         _operations.Object,
         _commandOperations.Object,
         _fileSystem.Object,
         _foldManager.Object);
     _processor = _processorRaw;
 }
 private void Create(params string[] lines)
 {
     _textView = EditorUtil.CreateView(lines);
     _factory = new MockRepository(MockBehavior.Strict);
     _host = _factory.Create<IVimHost>();
     _statusUtil = _factory.Create<IStatusUtil>();
     _registerMap = VimUtil.CreateRegisterMap(MockObjectFactory.CreateClipboardDevice(_factory).Object);
     _vimData = new VimData();
     var settings = new GlobalSettings();
     var localSettings = new LocalSettings(settings, _textView);
     var motionUtil = VimUtil.CreateTextViewMotionUtil(
         _textView,
         settings: localSettings,
         vimData: _vimData);
     var capture = new MotionCapture(
         _host.Object,
         _textView,
         MockObjectFactory.CreateIncrementalSearch(factory: _factory).Object,
         localSettings);
     _commandUtil = VimUtil.CreateCommandUtil(
         _textView,
         motionUtil: motionUtil,
         statusUtil: _statusUtil.Object,
         registerMap: _registerMap,
         vimData: _vimData);
     _runnerRaw = new CommandRunner(
         _textView,
         _registerMap,
         capture,
         _commandUtil,
         _statusUtil.Object,
         VisualKind.Character);
     _runner = _runnerRaw;
 }
Exemple #21
0
 string IVimHost.RunCommand(string command, string arguments, IVimData vimData)
 {
     return RunCommandFunc(command, arguments, vimData);
 }
Exemple #22
0
        /// <summary>
        /// Run the specified command on the supplied input, capture it's output and
        /// return it to the caller
        /// </summary>
        public virtual RunCommandResults RunCommand(string command, string arguments, string input, IVimData vimdata)
        {
            // Use a (generous) timeout since we have no way to interrupt it.
            var timeout = 30 * 1000;

            // Avoid redirection for the 'start' command.
            var doRedirect = !arguments.StartsWith("/c start ", StringComparison.CurrentCultureIgnoreCase);

            // Populate the start info.
            var startInfo = new ProcessStartInfo
            {
                FileName               = command,
                Arguments              = arguments,
                UseShellExecute        = false,
                RedirectStandardInput  = doRedirect,
                RedirectStandardOutput = doRedirect,
                RedirectStandardError  = doRedirect,
                CreateNoWindow         = true,
                WorkingDirectory       = vimdata.CurrentDirectory
            };

            // Start the process and tasks to manage the I/O.
            try
            {
                var process = Process.Start(startInfo);
                if (doRedirect)
                {
                    var stdin      = process.StandardInput;
                    var stdout     = process.StandardOutput;
                    var stderr     = process.StandardError;
                    var stdinTask  = Task.Run(() => { stdin.Write(input); stdin.Close(); });
                    var stdoutTask = Task.Run(() => stdout.ReadToEnd());
                    var stderrTask = Task.Run(() => stderr.ReadToEnd());
                    if (process.WaitForExit(timeout))
                    {
                        return(new RunCommandResults(process.ExitCode, stdoutTask.Result, stderrTask.Result));
                    }
                }
                else
                {
                    if (process.WaitForExit(timeout))
                    {
                        return(new RunCommandResults(process.ExitCode, String.Empty, String.Empty));
                    }
                }
                throw new TimeoutException();
            }
            catch (Exception ex)
            {
                return(new RunCommandResults(-1, "", ex.Message));
            }
        }
Exemple #23
0
 public virtual void VimDataCreated(IVimData vimData)
 {
 }
Exemple #24
0
 /// <summary>
 /// Run the specified command, capture it's output and return it to the caller
 /// </summary>
 public virtual string RunCommand(string command, string arguments, IVimData vimdata)
 {
     var startInfo = new ProcessStartInfo
                         {
                             FileName = command,
                             Arguments = arguments,
                             RedirectStandardOutput = true,
                             UseShellExecute = false,
                             WorkingDirectory = vimdata.CurrentDirectory
                         };
     try
     {
         var process = Process.Start(startInfo);
         process.WaitForExit();
         return process.StandardOutput.ReadToEnd();
     }
     catch (Exception ex)
     {
         return ex.Message;
     }
 }
        public void Create(params string[] lines)
        {
            _textView = CreateTextView(lines);
            _textView.Caret.MoveTo(new SnapshotPoint(_textView.TextSnapshot, 0));
            _textBuffer = _textView.TextBuffer;
            _foldManager = FoldManagerFactory.GetFoldManager(_textView);
            _factory = new MockRepository(MockBehavior.Strict);

            // Create the Vim instance with our Mock'd services
            _vimData = new VimData();
            var registerMap = VimUtil.CreateRegisterMap(MockObjectFactory.CreateClipboardDevice(_factory).Object);
            _vimHost = _factory.Create<IVimHost>();
            _globalSettings = _factory.Create<IVimGlobalSettings>();
            _globalSettings.SetupGet(x => x.Magic).Returns(true);
            _globalSettings.SetupGet(x => x.SmartCase).Returns(false);
            _globalSettings.SetupGet(x => x.IgnoreCase).Returns(true);
            _globalSettings.SetupGet(x => x.IsVirtualEditOneMore).Returns(false);
            _globalSettings.SetupGet(x => x.SelectionKind).Returns(SelectionKind.Inclusive);
            _globalSettings.SetupGet(x => x.UseEditorIndent).Returns(false);
            _globalSettings.SetupGet(x => x.UseEditorSettings).Returns(false);
            _globalSettings.SetupGet(x => x.VirtualEdit).Returns(String.Empty);
            _globalSettings.SetupGet(x => x.WrapScan).Returns(true);
            _globalSettings.SetupGet(x => x.ShiftWidth).Returns(2);
            _searchService = new SearchService(TextSearchService, _globalSettings.Object);
            var vim = MockObjectFactory.CreateVim(
                registerMap: registerMap,
                host: _vimHost.Object,
                settings: _globalSettings.Object,
                searchService: _searchService,
                factory: _factory);

            // Create the IVimTextBuffer instance with our Mock'd services
            _localSettings = MockObjectFactory.CreateLocalSettings(_globalSettings.Object, _factory);
            _localSettings.SetupGet(x => x.AutoIndent).Returns(false);
            _localSettings.SetupGet(x => x.GlobalSettings).Returns(_globalSettings.Object);
            _localSettings.SetupGet(x => x.ExpandTab).Returns(true);
            _localSettings.SetupGet(x => x.TabStop).Returns(4);
            _vimTextBuffer = MockObjectFactory.CreateVimTextBuffer(
                _textBuffer,
                localSettings: _localSettings.Object,
                vim: vim.Object,
                factory: _factory);

            // Create the VimBufferData instance with our Mock'd services
            _jumpList = _factory.Create<IJumpList>();
            _statusUtil = _factory.Create<IStatusUtil>();
            _undoRedoOperations = VimUtil.CreateUndoRedoOperations(_statusUtil.Object);
            var vimBufferData = CreateVimBufferData(
                _vimTextBuffer.Object,
                _textView,
                statusUtil: _statusUtil.Object,
                jumpList: _jumpList.Object,
                undoRedoOperations: _undoRedoOperations);

            _smartIndentationService = _factory.Create<ISmartIndentationService>();
            _outlining = _factory.Create<IOutliningManager>();
            _outlining
                .Setup(x => x.ExpandAll(It.IsAny<SnapshotSpan>(), It.IsAny<Predicate<ICollapsed>>()))
                .Returns<IEnumerable<ICollapsible>>(null);

            _operationsRaw = new CommonOperations(
                vimBufferData,
                EditorOperationsFactoryService.GetEditorOperations(_textView),
                FSharpOption.Create(_outlining.Object),
                _smartIndentationService.Object);
            _operations = _operationsRaw;
        }
 public void Create(params string[] lines)
 {
     _textView = EditorUtil.CreateView(lines);
     _textView.Caret.MoveTo(new SnapshotPoint(_textView.TextSnapshot, 0));
     _textBuffer = _textView.TextBuffer;
     _factory = new MockRepository(MockBehavior.Strict);
     _map = VimUtil.CreateRegisterMap(MockObjectFactory.CreateClipboardDevice(_factory).Object);
     _editOpts = _factory.Create<IEditorOperations>();
     _host = _factory.Create<IVimHost>();
     _operations = _factory.Create<IOperations>();
     _operations.SetupGet(x => x.EditorOperations).Returns(_editOpts.Object);
     _statusUtil = _factory.Create<IStatusUtil>();
     _fileSystem = _factory.Create<IFileSystem>(MockBehavior.Strict);
     _vimData = new VimData();
     _bufferData = MockObjectFactory.CreateVimBuffer(
         _textView,
         "test",
         MockObjectFactory.CreateVim(_map, host: _host.Object, vimData: _vimData).Object);
     _processorRaw = new Vim.Modes.Command.CommandProcessor(_bufferData.Object, _operations.Object, _statusUtil.Object, _fileSystem.Object);
     _processor = _processorRaw;
 }
Exemple #27
0
 private void Create(params string[] lines)
 {
     _textView = EditorUtil.CreateView(lines);
     _factory = new MockRepository(MockBehavior.Strict);
     _host = _factory.Create<IVimHost>();
     _statusUtil = _factory.Create<IStatusUtil>();
     _registerMap = VimUtil.CreateRegisterMap(MockObjectFactory.CreateClipboardDevice(_factory).Object);
     _vimData = new VimData();
     var capture = new MotionCapture(
         _host.Object,
         _textView,
         new TextViewMotionUtil(
             _textView,
             new MarkMap(new TrackingLineColumnService()),
             new Vim.LocalSettings(new Vim.GlobalSettings(), _textView)),
         MockObjectFactory.CreateIncrementalSearch(factory: _factory).Object,
         _factory.Create<IJumpList>().Object,
         _vimData,
         new LocalSettings(new Vim.GlobalSettings(), _textView));
     _runnerRaw = new CommandRunner(
         _textView,
         _registerMap,
         (IMotionCapture)capture,
         _statusUtil.Object);
     _runner = _runnerRaw;
 }
 private void Create(params string[] lines)
 {
     _textView = CreateTextView(lines);
     _textBuffer = _textView.TextBuffer;
     _globalSettings = new GlobalSettings();
     _globalSettings.IgnoreCase = true;
     _globalSettings.HighlightSearch = true;
     _searchService = Vim.SearchService;
     _vimData = Vim.VimData;
     _asyncTaggerSourceRaw = new HighlightSearchTaggerSource(
         _textView,
         _globalSettings,
         CreateTextStructureNavigator(_textBuffer, WordKind.NormalWord),
         _searchService,
         _vimData,
         Vim.VimHost);
     _asyncTaggerSource = _asyncTaggerSourceRaw;
 }
Exemple #29
0
        private void Create(params string[] lines)
        {
            _vimHost = (MockVimHost)Vim.VimHost;
            _textView = CreateTextView(lines);
            _textBuffer = _textView.TextBuffer;
            _vimTextBuffer = Vim.CreateVimTextBuffer(_textBuffer);
            _localSettings = _vimTextBuffer.LocalSettings;

            _foldManager = FoldManagerFactory.GetFoldManager(_textView);

            _factory = new MockRepository(MockBehavior.Loose);
            _statusUtil = _factory.Create<IStatusUtil>();
            _smartIdentationService = _factory.Create<ISmartIndentationService>();

            var vimBufferData = CreateVimBufferData(
                _vimTextBuffer,
                _textView,
                statusUtil: _statusUtil.Object);
            _jumpList = vimBufferData.JumpList;
            _windowSettings = vimBufferData.WindowSettings;

            _vimData = Vim.VimData;
            _macroRecorder = Vim.MacroRecorder;
            _registerMap = Vim.RegisterMap;
            _globalSettings = Vim.GlobalSettings;

            var operations = CommonOperationsFactory.GetCommonOperations(vimBufferData);
            _motionUtil = new MotionUtil(vimBufferData);
            _commandUtil = new CommandUtil(
                vimBufferData,
                _motionUtil,
                operations,
                _smartIdentationService.Object,
                _foldManager,
                new InsertUtil(vimBufferData, operations));
        }
Exemple #30
0
 private void Create(params string[] lines)
 {
     _textView = EditorUtil.CreateTextView(lines);
     _globalSettings = new Vim.GlobalSettings();
     _globalSettings.IncrementalSearch = true;
     _globalSettings.WrapScan = true;
     _localSettings = new LocalSettings(_globalSettings, EditorUtil.GetEditorOptions(_textView), _textView);
     _nav = VimUtil.CreateTextStructureNavigator(_textView, WordKind.NormalWord);
     _factory = new MockRepository(MockBehavior.Strict);
     _vimHost = _factory.Create<IVimHost>();
     _vimHost.Setup(x => x.EnsureVisible(_textView, It.IsAny<SnapshotPoint>()));
     _statusUtil = _factory.Create<IStatusUtil>();
     _statusUtil.Setup(x => x.OnWarning(Resources.Common_SearchBackwardWrapped));
     _statusUtil.Setup(x => x.OnWarning(Resources.Common_SearchForwardWrapped));
     _vimData = new VimData();
     _operations = VimUtil.CreateCommonOperations(
         textView: _textView,
         localSettings: _localSettings,
         vimHost: _vimHost.Object,
         statusUtil: _statusUtil.Object);
     _searchRaw = new IncrementalSearch(
         _operations,
         _localSettings,
         _nav,
         _statusUtil.Object,
         _vimData);
     _search = _searchRaw;
 }
Exemple #31
0
        public void Create(params string[] lines)
        {
            _textView = EditorUtil.CreateView(lines);
            _vimData = new VimData();
            _textView.Caret.MoveTo(new SnapshotPoint(_textView.TextSnapshot, 0));
            _textBuffer = _textView.TextBuffer;
            _factory = new MockRepository(MockBehavior.Strict);
            _registerMap = VimUtil.CreateRegisterMap(MockObjectFactory.CreateClipboardDevice(_factory).Object);
            _host = _factory.Create<IVimHost>();
            _jumpList = _factory.Create<IJumpList>();
            _editorOptions = _factory.Create<IEditorOptions>();
            _editorOptions.Setup(x => x.GetOptionValue(DefaultOptions.ConvertTabsToSpacesOptionId)).Returns(true);
            _editorOperations = _factory.Create<IEditorOperations>();
            _editorOperations.Setup(x => x.AddAfterTextBufferChangePrimitive());
            _editorOperations.Setup(x => x.AddBeforeTextBufferChangePrimitive());
            _globalSettings = _factory.Create<IVimGlobalSettings>();
            _globalSettings.SetupGet(x => x.Magic).Returns(true);
            _globalSettings.SetupGet(x => x.SmartCase).Returns(false);
            _globalSettings.SetupGet(x => x.IgnoreCase).Returns(true);
            _globalSettings.SetupGet(x => x.UseEditorIndent).Returns(false);
            _globalSettings.SetupGet(x => x.UseEditorTabSettings).Returns(false);
            _settings = MockObjectFactory.CreateLocalSettings(_globalSettings.Object, _factory);
            _settings.SetupGet(x => x.AutoIndent).Returns(false);
            _settings.SetupGet(x => x.GlobalSettings).Returns(_globalSettings.Object);
            _settings.SetupGet(x => x.ExpandTab).Returns(true);
            _settings.SetupGet(x => x.TabStop).Returns(4);
            _outlining = _factory.Create<IOutliningManager>();
            _globalSettings.SetupGet(x => x.ShiftWidth).Returns(2);
            _statusUtil = _factory.Create<IStatusUtil>();
            _undoRedoOperations = _factory.Create<IUndoRedoOperations>();
            _undoRedoOperations.Setup(x => x.CreateUndoTransaction(It.IsAny<string>())).Returns<string>(name => new UndoTransaction(FSharpOption.Create(EditorUtil.GetUndoHistory(_textView.TextBuffer).CreateTransaction(name))));
            _smartIndent = _factory.Create<ISmartIndentationService>();
            _searchService = new SearchService(EditorUtil.FactoryService.TextSearchService, _globalSettings.Object);

            var data = new OperationsData(
                vimData: _vimData,
                vimHost: _host.Object,
                editorOperations: _editorOperations.Object,
                textView: _textView,
                outliningManager: FSharpOption.Create(_outlining.Object),
                jumpList: _jumpList.Object,
                localSettings: _settings.Object,
                undoRedoOperations: _undoRedoOperations.Object,
                registerMap: _registerMap,
                editorOptions: _editorOptions.Object,
                keyMap: null,
                navigator: null,
                statusUtil: _statusUtil.Object,
                foldManager: null,
                searchService: _searchService,
                smartIndentationService: _smartIndent.Object);

            _operationsRaw = new CommonOperations(data);
            _operations = _operationsRaw;
        }
 private void Create(params string[] lines)
 {
     _textBuffer = EditorUtil.CreateTextBuffer(lines);
     _globalSettings = new GlobalSettings();
     _globalSettings.IgnoreCase = true;
     _globalSettings.HighlightSearch = true;
     _vimData = new VimData();
     _searchService = VimUtil.CreateSearchService();
     _taggerRaw = new HighlightIncrementalSearchTagger(
         _textBuffer,
         _globalSettings,
         VimUtil.CreateTextStructureNavigator(_textBuffer, WordKind.NormalWord),
         _searchService,
         _vimData);
     _tagger = _taggerRaw;
 }
        public void Create(params string[] lines)
        {
            var tuple = EditorUtil.CreateTextViewAndEditorOperations(lines);
            _textView = tuple.Item1;
            _textBuffer = _textView.TextBuffer;
            var service = EditorUtil.FactoryService;
            _vimBuffer = service.Vim.CreateVimBuffer(_textView);
            _vimBuffer.ErrorMessage +=
                (_, message) =>
                {
                    if (_assertOnErrorMessage)
                    {
                        Assert.Fail("Error Message: " + message);
                    }
                };
            _vimBuffer.WarningMessage +=
                (_, message) =>
                {
                    if (_assertOnWarningMessage)
                    {
                        Assert.Fail("Warning Message: " + message);
                    }
                };
            _vimTextBuffer = _vimBuffer.VimTextBuffer;
            _keyMap = _vimBuffer.Vim.KeyMap;
            _globalSettings = _vimBuffer.LocalSettings.GlobalSettings;
            _jumpList = _vimBuffer.JumpList;
            _vimHost = (MockVimHost)_vimBuffer.Vim.VimHost;
            _vimHost.BeepCount = 0;
            _vimData = service.Vim.VimData;
            _foldManager = EditorUtil.FactoryService.FoldManagerFactory.GetFoldManager(_textView);

            // Many of the operations operate on both the visual and edit / text snapshot
            // simultaneously.  Ensure that our setup code is producing a proper IElisionSnapshot
            // for the Visual portion so we can root out any bad mixing of instances between
            // the two
            Assert.IsTrue(_textView.VisualSnapshot is IElisionSnapshot);
            Assert.IsTrue(_textView.VisualSnapshot != _textView.TextSnapshot);
        }
Exemple #34
0
        private void Create(params string[] lines)
        {
            _textView = EditorUtil.CreateView(lines);
            _textBuffer = _textView.TextBuffer;

            _factory = new MockRepository(MockBehavior.Loose);
            _vimHost = _factory.Create<IVimHost>();
            _statusUtil = _factory.Create<IStatusUtil>();
            _operations = _factory.Create<ICommonOperations>();
            _operations.Setup(x => x.EnsureCaretOnScreenAndTextExpanded());
            _operations.Setup(x => x.RaiseSearchResultMessages(It.IsAny<SearchResult>()));
            _operations.Setup(x => x.EditorOptions).Returns(EditorUtil.FactoryService.EditorOptionsFactory.GetOptions(_textView));
            _recorder = _factory.Create<IMacroRecorder>(MockBehavior.Loose);
            _smartIdentationService = _factory.Create<ISmartIndentationService>();

            _vimData = new VimData();
            _registerMap = VimUtil.CreateRegisterMap(MockObjectFactory.CreateClipboardDevice().Object);
            _markMap = new MarkMap(new TrackingLineColumnService());
            _globalSettings = new GlobalSettings();
            _localSettings = new LocalSettings(_globalSettings, _textView);

            var localSettings = new LocalSettings(new Vim.GlobalSettings());
            _motionUtil = VimUtil.CreateTextViewMotionUtil(
                _textView,
                settings: localSettings,
                vimData: _vimData);
            _commandUtil = VimUtil.CreateCommandUtil(
                _textView,
                _operations.Object,
                _motionUtil,
                statusUtil: _statusUtil.Object,
                localSettings: _localSettings,
                registerMap: _registerMap,
                markMap: _markMap,
                vimData: _vimData,
                smartIndentationService: _smartIdentationService.Object,
                recorder: _recorder.Object);
            _jumpList = _commandUtil._jumpList;
        }