public IOleCommandTarget GetCommandTarget(IWpfTextView textView, IOleCommandTarget nextTarget) { if (textView.TextBuffer.ContentType.IsOfType(CodeRemoteContentDefinition.CodeRemoteContentTypeName)) { // We want default handling when this is a remote buffer return(null); } var window = textView.TextBuffer.GetInteractiveWindow(); var controller = IntellisenseControllerProvider.GetOrCreateController( _editorServices.Site, _editorServices.ComponentModel, textView ); controller._oldTarget = nextTarget; var editFilter = EditFilter.GetOrCreate(_editorServices, textView, controller); if (window == null) { return(editFilter); } textView.Properties[IntellisenseController.SuppressErrorLists] = IntellisenseController.SuppressErrorLists; return(ReplEditFilter.GetOrCreate(_editorServices.Site, _editorServices.ComponentModel, textView, editFilter)); }
private static async Task CodeFormattingTest(string input, object selection, string expected, object expectedSelection, CodeFormattingOptions options, bool formatSelected = true) { var fact = InterpreterFactoryCreator.CreateAnalysisInterpreterFactory(new Version(2, 7)); var editorTestToolset = new EditorTestToolset().WithPythonToolsService(); var services = editorTestToolset.GetPythonEditorServices(); editorTestToolset.GetService <IPythonToolsOptionsService>().ImportFrom(options); using (var analyzer = await VsProjectAnalyzer.CreateForTestsAsync(services, fact)) { var analysisStartedTask = EventTaskSources.VsProjectAnalyzer.AnalysisStarted.Create(analyzer); var buffer = editorTestToolset.CreatePythonTextBuffer(input, analyzer); var view = editorTestToolset.CreateTextView(buffer); await analysisStartedTask; var bi = services.GetBufferInfo(buffer); var entry = await analyzer.AnalyzeFileAsync(bi.Filename); Assert.AreEqual(entry, bi.TrySetAnalysisEntry(entry, null), "Failed to set analysis entry"); entry.GetOrCreateBufferParser(services).AddBuffer(buffer); if (formatSelected) { var selectionSpan = new SnapshotSpan( buffer.CurrentSnapshot, ExtractMethodTests.GetSelectionSpan(input, selection) ); await editorTestToolset.UIThread.InvokeTask(async() => { view.Selection.Select(selectionSpan, false); await EditFilter.GetOrCreate(services, view).FormatSelectionAsync(); }); } else { await editorTestToolset.UIThread.InvokeTask(async() => { await EditFilter.GetOrCreate(services, view).FormatDocumentAsync(); }); } Assert.AreEqual(expected, view.TextBuffer.CurrentSnapshot.GetText()); if (expectedSelection != null) { Assert.AreEqual( ExtractMethodTests.GetSelectionSpan(expected, expectedSelection), view.Selection.StreamSelectionSpan.SnapshotSpan.Span ); } } }
int IVsCodeWindowEvents.OnNewView(IVsTextView vsTextView) { _viewCount++; if (TryGetTextView(vsTextView, out var wpfTextView)) { var services = ComponentModel.GetService <PythonEditorServices>(); EditFilter.GetOrCreate(services, vsTextView); new TextViewFilter(services, vsTextView); wpfTextView.GotAggregateFocus += OnTextViewGotAggregateFocus; wpfTextView.LostAggregateFocus += OnTextViewLostAggregateFocus; } return(VSConstants.S_OK); }
int IVsCodeWindowEvents.OnNewView(IVsTextView vsTextView) { _viewCount++; var wpfTextView = VsEditorAdaptersFactoryService.GetWpfTextView(vsTextView); if (wpfTextView != null) { var factory = ComponentModel.GetService <IEditorOperationsFactoryService>(); EditFilter.GetOrCreate(_serviceProvider, ComponentModel, vsTextView); new TextViewFilter(_serviceProvider, vsTextView); wpfTextView.GotAggregateFocus += OnTextViewGotAggregateFocus; wpfTextView.LostAggregateFocus += OnTextViewLostAggregateFocus; } return(VSConstants.S_OK); }
int IVsCodeWindowEvents.OnNewView(IVsTextView vsTextView) { _viewCount++; var wpfTextView = VsEditorAdaptersFactoryService.GetWpfTextView(vsTextView); if (wpfTextView != null) { var services = ComponentModel.GetService <PythonEditorServices>(); EditFilter.GetOrCreate(services, vsTextView); new TextViewFilter(services, vsTextView); wpfTextView.GotAggregateFocus += OnTextViewGotAggregateFocus; wpfTextView.LostAggregateFocus += OnTextViewLostAggregateFocus; } return(VSConstants.S_OK); }
public IOleCommandTarget GetCommandTarget(IWpfTextView textView, IOleCommandTarget nextTarget) { var window = textView.TextBuffer.GetInteractiveWindow(); var controller = IntellisenseControllerProvider.GetOrCreateController( _serviceProvider, _componentModel, textView ); controller._oldTarget = nextTarget; var editFilter = EditFilter.GetOrCreate(_serviceProvider, _componentModel, textView, controller); if (window == null) { return(editFilter); } return(ReplEditFilter.GetOrCreate(_serviceProvider, _componentModel, textView, editFilter)); }
public IOleCommandTarget GetCommandTarget(IWpfTextView textView, IOleCommandTarget nextTarget) { var window = textView.TextBuffer.GetInteractiveWindow(); var controller = IntellisenseControllerProvider.GetOrCreateController( _editorServices.Site, _editorServices.ComponentModel, textView ); controller._oldTarget = nextTarget; var editFilter = EditFilter.GetOrCreate(_editorServices, textView, controller); if (window == null) { return(editFilter); } textView.Properties[IntellisenseController.SuppressErrorLists] = IntellisenseController.SuppressErrorLists; return(ReplEditFilter.GetOrCreate(_editorServices.Site, _editorServices.ComponentModel, textView, editFilter)); }