public IInteractiveWindowVisualComponent Create(int instanceId, IInteractiveEvaluator evaluator) { var tb = new TextBufferMock(string.Empty, RContentTypeDefinition.ContentType); var container = new VisualComponentContainerStub<RInteractiveWindowVisualComponent>(); var component = new RInteractiveWindowVisualComponent(new InteractiveWindowMock(new WpfTextViewMock(tb), evaluator), container); container.Component = component; return component; }
internal VsInteractiveWindow(IComponentModel model, Guid providerId, int instanceId, string title, IInteractiveEvaluator evaluator, __VSCREATETOOLWIN creationFlags) { _componentModel = model; this.Caption = title; _editorAdapters = _componentModel.GetService<IVsEditorAdaptersFactoryService>(); _evaluator = evaluator; // The following calls this.OnCreate: Guid clsId = this.ToolClsid; Guid empty = Guid.Empty; Guid typeId = providerId; IVsWindowFrame frame; var vsShell = (IVsUIShell)ServiceProvider.GlobalProvider.GetService(typeof(SVsUIShell)); // we don't pass __VSCREATETOOLWIN.CTW_fMultiInstance because multi instance panes are // destroyed when closed. We are really multi instance but we don't want to be closed. ErrorHandler.ThrowOnFailure( vsShell.CreateToolWindow( (uint)(__VSCREATETOOLWIN.CTW_fInitNew | __VSCREATETOOLWIN.CTW_fToolbarHost | creationFlags), (uint)instanceId, this.GetIVsWindowPane(), ref clsId, ref typeId, ref empty, null, title, null, out frame ) ); this.Frame = frame; }
public IInteractiveWindowVisualComponent Create(int instanceId, IInteractiveEvaluator evaluator, IRSessionProvider sessionProvider) { VsAppShell.Current.AssertIsOnMainThread(); var vsWindow = _vsInteractiveWindowFactoryLazy.Value.Create(RGuidList.ReplInteractiveWindowProviderGuid, instanceId, string.Empty, evaluator); var contentType = _contentTypeRegistryService.GetContentType(RContentTypeDefinition.ContentType); vsWindow.SetLanguage(RGuidList.RLanguageServiceGuid, contentType); var toolWindow = (ToolWindowPane)vsWindow; var componentContainer = new VisualComponentToolWindowAdapter<IInteractiveWindowVisualComponent>(toolWindow); var component = new RInteractiveWindowVisualComponent(vsWindow.InteractiveWindow, componentContainer, sessionProvider, _shell); componentContainer.Component = component; return component; }
public IInteractiveWindowVisualComponent Create(int instanceId, IInteractiveEvaluator evaluator) { VsAppShell.Current.AssertIsOnMainThread(); var vsWindow = _vsInteractiveWindowFactoryLazy.Value.Create(RGuidList.ReplInteractiveWindowProviderGuid, instanceId, Resources.ReplWindowName, evaluator); vsWindow.SetLanguage(RGuidList.RLanguageServiceGuid, _contentType); var toolWindow = (ToolWindowPane) vsWindow; ((IVsWindowFrame)toolWindow.Frame).SetProperty((int)__VSFPROPID4.VSFPROPID_TabImage, Resources.ReplWindowIcon); var componentContainer = new VisualComponentToolWindowAdapter<IInteractiveWindowVisualComponent>(toolWindow); var component = new RInteractiveWindowVisualComponent(vsWindow.InteractiveWindow, componentContainer); componentContainer.Component = component; return component; }
private void DetachMultipleScopeHandling(IInteractiveEvaluator evaluator) { var mse = evaluator as IMultipleScopeEvaluator; if (mse == null) { return; } mse.AvailableScopesChanged -= Evaluator_AvailableScopesChanged; mse.MultipleScopeSupportChanged -= Evaluator_MultipleScopeSupportChanged; MultipleScopeSupportChanged?.Invoke(this, EventArgs.Empty); AvailableScopesChanged?.Invoke(this, EventArgs.Empty); }
internal VsInteractiveWindow( IComponentModel model, Guid providerId, int instanceId, string title, IInteractiveEvaluator evaluator, __VSCREATETOOLWIN creationFlags, Guid toolbarCommandSet, uint toolbarId, IOleCommandTarget toolbarCommandTarget) { ThreadHelper.ThrowIfNotOnUIThread(); _componentModel = model; Caption = title; _editorAdapters = _componentModel.GetService <IVsEditorAdaptersFactoryService>(); _evaluator = evaluator; _toolbarCommandSet = toolbarCommandSet; _toolbarCommandTarget = toolbarCommandTarget; _toolbarId = toolbarId; // The following calls this.OnCreate: Guid clsId = ToolClsid; Guid empty = Guid.Empty; Guid typeId = providerId; IVsWindowFrame frame; var vsShell = (IVsUIShell)ServiceProvider.GlobalProvider.GetService(typeof(SVsUIShell)); // we don't pass __VSCREATETOOLWIN.CTW_fMultiInstance because multi instance panes are // destroyed when closed. We are really multi instance but we don't want to be closed. ErrorHandler.ThrowOnFailure( vsShell.CreateToolWindow( (uint)(__VSCREATETOOLWIN.CTW_fInitNew | __VSCREATETOOLWIN.CTW_fToolbarHost | creationFlags), (uint)instanceId, GetIVsWindowPane(), ref clsId, ref typeId, ref empty, null, title, null, out frame ) ); var guid = GetType().GUID; ErrorHandler.ThrowOnFailure(frame.SetGuidProperty((int)__VSFPROPID.VSFPROPID_CmdUIGuid, ref guid)); Frame = frame; }
private async Task ResetInteractiveAsync( IInteractiveWindow interactiveWindow, ImmutableArray <string> referencePaths, ImmutableArray <string> referenceSearchPaths, ImmutableArray <string> sourceSearchPaths, ImmutableArray <string> namespacesToImport, string projectDirectory, IWaitContext waitContext) { // First, open the repl window. IInteractiveEvaluator evaluator = interactiveWindow.Evaluator; // If the user hits the cancel button on the wait indicator, then we want to stop the // build. using (waitContext.CancellationToken.Register(() => CancelBuildProject(), useSynchronizationContext: true)) { // First, start a build. // If the build fails do not reset the REPL. var builtSuccessfully = await BuildProject().ConfigureAwait(true); if (!builtSuccessfully) { return; } } // Then reset the REPL waitContext.Message = InteractiveEditorFeaturesResources.ResettingInteractive; await interactiveWindow.Operations.ResetAsync(initialize : true).ConfigureAwait(true); // TODO: load context from an rsp file. // Now send the reference paths we've collected to the repl. // The SetPathsAsync method is not available through an Interface. // Execute the method only if the cast to a concrete InteractiveEvaluator succeeds. InteractiveEvaluator interactiveEvaluator = evaluator as InteractiveEvaluator; if (interactiveEvaluator != null) { await interactiveEvaluator.SetPathsAsync(referenceSearchPaths, sourceSearchPaths, projectDirectory).ConfigureAwait(true); } var editorOptions = _editorOptionsFactoryService.GetOptions(interactiveWindow.CurrentLanguageBuffer); var importReferencesCommand = referencePaths.Select(_createReference); var importNamespacesCommand = namespacesToImport.Select(_createImport).Join(editorOptions.GetNewLineCharacter()); await interactiveWindow.SubmitAsync(importReferencesCommand.Concat(new[] { importNamespacesCommand })).ConfigureAwait(true); }
private void SaveInteractiveInfo(int id, IInteractiveEvaluator evaluator, IContentType contentType, string[] roles, string title, Guid languageServiceGuid, string replId) { using (var root = GetRegistryRoot()) { if (root != null) { using (var replInfo = root.CreateSubKey(id.ToString())) { replInfo.SetValue(ContentTypeKey, contentType.TypeName); replInfo.SetValue(TitleKey, title); replInfo.SetValue(ReplIdKey, replId.ToString()); replInfo.SetValue(LanguageServiceGuidKey, languageServiceGuid.ToString()); } } } }
private async Task DoInitializeAsync(IInteractiveEvaluator eval) { await eval.InitializeAsync(); var view = eval?.CurrentWindow?.TextView; var buffer = eval?.CurrentWindow?.CurrentLanguageBuffer; if (view != null && buffer != null) { var controller = IntellisenseControllerProvider.GetOrCreateController(_serviceProvider, _serviceProvider.GetComponentModel(), view); controller.DisconnectSubjectBuffer(buffer); controller.ConnectSubjectBuffer(buffer); } }
private void DetachWindow(IInteractiveEvaluator oldEval) { var oldView = oldEval?.CurrentWindow?.TextView; if (oldView != null) { foreach (var buffer in oldView.BufferGraph.GetTextBuffers(EditorExtensions.IsPythonContent)) { if (oldEval.CurrentWindow.CurrentLanguageBuffer == buffer) { continue; } buffer.Properties[BufferParser.DoNotParse] = BufferParser.DoNotParse; } } }
public IInteractiveWindowVisualComponent Create(int instanceId, IInteractiveEvaluator evaluator, IRSessionProvider sessionProvider) { VsAppShell.Current.AssertIsOnMainThread(); var vsWindow = _vsInteractiveWindowFactoryLazy.Value.Create(RGuidList.ReplInteractiveWindowProviderGuid, instanceId, string.Empty, evaluator); var contentType = _contentTypeRegistryService.GetContentType(RContentTypeDefinition.ContentType); vsWindow.SetLanguage(RGuidList.RLanguageServiceGuid, contentType); var toolWindow = (ToolWindowPane)vsWindow; var componentContainer = new VisualComponentToolWindowAdapter <IInteractiveWindowVisualComponent>(toolWindow); var component = new RInteractiveWindowVisualComponent(vsWindow.InteractiveWindow, componentContainer, sessionProvider, _shell); componentContainer.Component = component; return(component); }
public IInteractiveWindow CreateWindow(IInteractiveEvaluator evaluator) { if (evaluator == null) { throw new ArgumentNullException(nameof(evaluator)); } return(new InteractiveWindow( windowFactoryService, contentTypeRegistry, bufferFactory, projectionBufferFactory, editorOperationsFactory, editorFactory, intellisenseSessionStackMap, smartIndenterService, evaluator)); }
public IInteractiveWindow CreateWindow(IInteractiveEvaluator evaluator) { if (evaluator == null) { throw new ArgumentNullException(nameof(evaluator)); } return new InteractiveWindow( _windowFactoryService, _contentTypeRegistry, _bufferFactory, _projectionBufferFactory, _editorOperationsFactory, _editorFactory, _intellisenseSessionStackMap, _smartIndenterService, evaluator); }
public IInteractiveWindowVisualComponent Create(int instanceId, IInteractiveEvaluator evaluator) { VsAppShell.Current.AssertIsOnMainThread(); var vsWindow = _vsInteractiveWindowFactoryLazy.Value.Create(RGuidList.ReplInteractiveWindowProviderGuid, instanceId, Resources.ReplWindowName, evaluator); vsWindow.SetLanguage(RGuidList.RLanguageServiceGuid, _contentType); var toolWindow = (ToolWindowPane) vsWindow; var frame = (IVsWindowFrame)toolWindow.Frame; frame.SetProperty((int)__VSFPROPID4.VSFPROPID_TabImage, Resources.ReplWindowIcon); // TODO: figure out why REPL window doesn't get 'force create' flag set // For now, set it forcibly when window is shown object value; frame.GetProperty((int)__VSFPROPID.VSFPROPID_CreateToolWinFlags, out value); frame.SetProperty((int)__VSFPROPID.VSFPROPID_CreateToolWinFlags, (int)value | (int)__VSCREATETOOLWIN.CTW_fForceCreate); var componentContainer = new VisualComponentToolWindowAdapter<IInteractiveWindowVisualComponent>(toolWindow); var component = new RInteractiveWindowVisualComponent(vsWindow.InteractiveWindow, componentContainer); componentContainer.Component = component; return component; }
public IInteractiveWindow CreateWindow(IInteractiveEvaluator evaluator) { if (evaluator == null) { throw new ArgumentNullException(nameof(evaluator)); } return(new InteractiveWindow( _windowFactoryService, _contentTypeRegistry, _bufferFactory, _projectionBufferFactory, _editorOperationsFactory, _editorFactory, _rtfBuilderService, _intellisenseSessionStackMap, _smartIndenterService, evaluator, _waitIndicator)); }
private void DetachWindow(IInteractiveEvaluator oldEval) { var oldView = oldEval?.CurrentWindow?.TextView; if (oldView != null) { foreach (var buffer in oldView.BufferGraph.GetTextBuffers(EditorExtensions.IsPythonContent)) { if (oldEval.CurrentWindow.CurrentLanguageBuffer == buffer) { continue; } var tb = PythonTextBufferInfo.TryGetForBuffer(buffer); if (tb != null) { tb.DoNotParse = true; } } } }
private IVsInteractiveWindow CreateInteractiveWindowInternal( IInteractiveEvaluator evaluator, IContentType contentType, bool alwaysCreate, int id, string title, Guid languageServiceGuid, string replId ) { var creationFlags = __VSCREATETOOLWIN.CTW_fMultiInstance | __VSCREATETOOLWIN.CTW_fActivateWithProject; if (alwaysCreate) { creationFlags |= __VSCREATETOOLWIN.CTW_fForceCreate; } var replWindow = _windowFactory.Create(GuidList.guidPythonInteractiveWindowGuid, id, title, evaluator, creationFlags); replWindow.InteractiveWindow.Properties[VsInteractiveWindowKey] = replWindow; var toolWindow = replWindow as ToolWindowPane; if (toolWindow != null) { toolWindow.BitmapImageMoniker = KnownMonikers.PYInteractiveWindow; } replWindow.SetLanguage(GuidList.guidPythonLanguageServiceGuid, contentType); replWindow.InteractiveWindow.InitializeAsync(); var selectEval = evaluator as SelectableReplEvaluator; if (selectEval != null) { selectEval.ProvideInteractiveWindowEvents(InteractiveWindowEvents.GetOrCreate(replWindow)); } return(replWindow); }
public IInteractiveWindowVisualComponent Create(int instanceId, IInteractiveEvaluator evaluator, IRSessionProvider sessionProvider) { _shell.MainThread().Assert(); var vsf2 = _vsInteractiveWindowFactoryLazy.Value; var vsWindow2 = vsf2.Create(RGuidList.ReplInteractiveWindowProviderGuid, instanceId, string.Empty, evaluator, 0, RGuidList.RCmdSetGuid, RPackageCommandId.replWindowToolBarId, null); var contentType = _contentTypeRegistryService.GetContentType(RContentTypeDefinition.ContentType); vsWindow2.SetLanguage(RGuidList.RLanguageServiceGuid, contentType); var toolWindow = (ToolWindowPane)vsWindow2; var componentContainer = new VisualComponentToolWindowAdapter <IInteractiveWindowVisualComponent>(toolWindow, _shell.Services); var component = new RInteractiveWindowVisualComponent(vsWindow2.InteractiveWindow, componentContainer, sessionProvider, _shell); componentContainer.Component = component; RegisterFocusPreservingWindow(toolWindow); return(component); }
public void SetEvaluator(string id) { if (_evaluatorId == id && _evaluator != null) { return; } var eval = string.IsNullOrEmpty(id) ? null : _providers.Select(p => p.GetEvaluator(id)).FirstOrDefault(e => e != null); var oldEval = _evaluator; _evaluator = null; if (oldEval != null) { DetachWindow(oldEval); DetachMultipleScopeHandling(oldEval); oldEval.Dispose(); } _evaluator = eval; _evaluatorId = id; if (eval != null) { eval.CurrentWindow = CurrentWindow; if (eval.CurrentWindow != null) { // Otherwise, we'll initialize when the window is set DoInitializeAsync(eval).DoNotWait(); } } UpdateCaption(); PersistEvaluator(); EvaluatorChanged?.Invoke(this, EventArgs.Empty); AttachMultipleScopeHandling(eval); }
public InteractiveWindow( IInteractiveWindowEditorFactoryService host, IContentTypeRegistryService contentTypeRegistry, ITextBufferFactoryService bufferFactory, IProjectionBufferFactoryService projectionBufferFactory, IEditorOperationsFactoryService editorOperationsFactory, ITextBufferUndoManagerProvider textBufferUndoManagerProvider, ITextEditorFactoryService editorFactory, IRtfBuilderService rtfBuilderService, IIntellisenseSessionStackMapService intellisenseSessionStackMap, ISmartIndentationService smartIndenterService, IInteractiveEvaluator evaluator, IWaitIndicator waitIndicator) { if (evaluator == null) { throw new ArgumentNullException(nameof(evaluator)); } _uiOnly = new UIThreadOnly( this, host, contentTypeRegistry, bufferFactory, projectionBufferFactory, editorOperationsFactory, textBufferUndoManagerProvider, editorFactory, rtfBuilderService, intellisenseSessionStackMap, smartIndenterService, evaluator, waitIndicator); evaluator.CurrentWindow = this; RequiresUIThread(); }
private IVsInteractiveWindow CreateReplWindowInternal(IInteractiveEvaluator evaluator, int id, string title, Guid languageServiceGuid) { var creationFlags = __VSCREATETOOLWIN.CTW_fMultiInstance | __VSCREATETOOLWIN.CTW_fActivateWithProject | __VSCREATETOOLWIN.CTW_fForceCreate; var replWindow = this.windowFactory.Create( Guids.NodejsInteractiveWindow, id, title, evaluator, creationFlags); if (replWindow is ToolWindowPane toolwindow) { toolwindow.BitmapImageMoniker = KnownMonikers.JSInteractiveWindow; } replWindow.SetLanguage(languageServiceGuid, this.typeScriptContentType); replWindow.InteractiveWindow.InitializeAsync(); return(replWindow); }
public IInteractiveWindowVisualComponent Create(int instanceId, IInteractiveEvaluator evaluator) { VsAppShell.Current.AssertIsOnMainThread(); var vsWindow = _vsInteractiveWindowFactoryLazy.Value.Create(RGuidList.ReplInteractiveWindowProviderGuid, instanceId, Resources.ReplWindowName, evaluator); vsWindow.SetLanguage(RGuidList.RLanguageServiceGuid, _contentType); var toolWindow = (ToolWindowPane)vsWindow; var frame = (IVsWindowFrame)toolWindow.Frame; frame.SetProperty((int)__VSFPROPID4.VSFPROPID_TabImage, Resources.ReplWindowIcon); // TODO: figure out why REPL window doesn't get 'force create' flag set // For now, set it forcibly when window is shown object value; frame.GetProperty((int)__VSFPROPID.VSFPROPID_CreateToolWinFlags, out value); frame.SetProperty((int)__VSFPROPID.VSFPROPID_CreateToolWinFlags, (int)value | (int)__VSCREATETOOLWIN.CTW_fForceCreate); var componentContainer = new VisualComponentToolWindowAdapter <IInteractiveWindowVisualComponent>(toolWindow); var component = new RInteractiveWindowVisualComponent(vsWindow.InteractiveWindow, componentContainer); componentContainer.Component = component; return(component); }
public bool SupportsCodeFixes(Document document) { SourceText sourceText; if (document.TryGetText(out sourceText)) { ITextBuffer buffer = sourceText.Container.TryGetTextBuffer(); if (buffer != null) { IInteractiveEvaluator evaluator = (IInteractiveEvaluator)buffer.Properties[typeof(IInteractiveEvaluator)]; IInteractiveWindow window = evaluator?.CurrentWindow; if (window?.CurrentLanguageBuffer == buffer) { // These are only correct if we're on the UI thread. // Otherwise, they're guesses and they might change immediately even if they're correct. // If we return true and the buffer later becomes readonly, it appears that the // the code fix simply has no effect. return(!window.IsResetting && !window.IsRunning); } } } return(false); }
private InteractiveWindowInfo CreateInteractiveWindowInternal(IInteractiveEvaluator evaluator, IContentType contentType, string[] roles, int id, string title, Guid languageServiceGuid, string replId) { var service = (IVsUIShell)ServiceProvider.GlobalProvider.GetService(typeof(SVsUIShell)); var model = (IComponentModel)ServiceProvider.GlobalProvider.GetService(typeof(SComponentModel)); SaveInteractiveInfo(id, evaluator, contentType, roles, title, languageServiceGuid, replId); // we don't pass __VSCREATETOOLWIN.CTW_fMultiInstance because multi instance panes are // destroyed when closed. We are really multi instance but we don't want to be closed. This // seems to work fine. __VSCREATETOOLWIN creationFlags = 0; if (!roles.Contains("DontPersist")) { creationFlags |= __VSCREATETOOLWIN.CTW_fForceCreate; } var replWindow = _windowFactory.Create(GuidList.guidPythonInteractiveWindowGuid, id, title, evaluator, creationFlags); replWindow.SetLanguage(GuidList.guidPythonLanguageServiceGuid, contentType); replWindow.InteractiveWindow.InitializeAsync(); return(_windows[id] = new InteractiveWindowInfo(replWindow, replId)); }
public UIThreadOnly( InteractiveWindow window, IInteractiveWindowEditorFactoryService factory, IContentTypeRegistryService contentTypeRegistry, ITextBufferFactoryService bufferFactory, IProjectionBufferFactoryService projectionBufferFactory, IEditorOperationsFactoryService editorOperationsFactory, ITextEditorFactoryService editorFactory, IRtfBuilderService rtfBuilderService, IIntellisenseSessionStackMapService intellisenseSessionStackMap, ISmartIndentationService smartIndenterService, IInteractiveEvaluator evaluator, IWaitIndicator waitIndicator) { _window = window; _factory = factory; _rtfBuilderService = (IRtfBuilderService2)rtfBuilderService; _intellisenseSessionStackMap = intellisenseSessionStackMap; _smartIndenterService = smartIndenterService; _waitIndicator = waitIndicator; Evaluator = evaluator; var replContentType = contentTypeRegistry.GetContentType(PredefinedInteractiveContentTypes.InteractiveContentTypeName); var replOutputContentType = contentTypeRegistry.GetContentType(PredefinedInteractiveContentTypes.InteractiveOutputContentTypeName); OutputBuffer = bufferFactory.CreateTextBuffer(replOutputContentType); StandardInputBuffer = bufferFactory.CreateTextBuffer(); _inertType = bufferFactory.InertContentType; _projectionBuffer = projectionBufferFactory.CreateProjectionBuffer( new EditResolver(window), Array.Empty<object>(), ProjectionBufferOptions.None, replContentType); _projectionBuffer.Properties.AddProperty(typeof(InteractiveWindow), window); AppendNewOutputProjectionBuffer(); _projectionBuffer.Changed += new EventHandler<TextContentChangedEventArgs>(ProjectionBufferChanged); var roleSet = editorFactory.CreateTextViewRoleSet( PredefinedTextViewRoles.Analyzable, PredefinedTextViewRoles.Editable, PredefinedTextViewRoles.Interactive, PredefinedTextViewRoles.Zoomable, PredefinedInteractiveTextViewRoles.InteractiveTextViewRole); TextView = factory.CreateTextView(window, _projectionBuffer, roleSet); TextView.Caret.PositionChanged += CaretPositionChanged; var options = TextView.Options; options.SetOptionValue(DefaultTextViewHostOptions.HorizontalScrollBarId, true); options.SetOptionValue(DefaultTextViewHostOptions.LineNumberMarginId, false); options.SetOptionValue(DefaultTextViewHostOptions.OutliningMarginId, false); options.SetOptionValue(DefaultTextViewHostOptions.GlyphMarginId, false); options.SetOptionValue(DefaultTextViewOptions.WordWrapStyleId, WordWrapStyles.None); _lineBreakString = options.GetNewLineCharacter(); EditorOperations = editorOperationsFactory.GetEditorOperations(TextView); _buffer = new OutputBuffer(window); OutputWriter = new InteractiveWindowWriter(window, spans: null); SortedSpans errorSpans = new SortedSpans(); ErrorOutputWriter = new InteractiveWindowWriter(window, errorSpans); OutputClassifierProvider.AttachToBuffer(OutputBuffer, errorSpans); }
public void SetEvaluator(string id) { if (_evaluatorId == id && _evaluator != null) { return; } var eval = string.IsNullOrEmpty(id) ? null : _providers.Select(p => p.GetEvaluator(id)).FirstOrDefault(e => e != null); var oldEval = _evaluator; _evaluator = null; if (oldEval != null) { DetachWindow(oldEval); DetachMultipleScopeHandling(oldEval); } _evaluator = eval; _evaluatorId = id; if (eval != null) { eval.CurrentWindow = CurrentWindow; if (eval.CurrentWindow != null) { // Otherwise, we'll initialize when the window is set DoInitializeAsync(eval).DoNotWait(); } } UpdateCaption(); PersistEvaluator(); EvaluatorChanged?.Invoke(this, EventArgs.Empty); AttachMultipleScopeHandling(eval); }
private InteractiveWindowInfo CreateInteractiveWindow(IInteractiveEvaluator/*!*/ evaluator, IContentType/*!*/ contentType, string[] roles, int id, string/*!*/ title, Guid languageServiceGuid, string replId) { return CreateInteractiveWindowInternal(evaluator, contentType, roles, id, title, languageServiceGuid, replId); }
public InteractiveWindow( IInteractiveWindowEditorFactoryService host, IContentTypeRegistryService contentTypeRegistry, ITextBufferFactoryService bufferFactory, IProjectionBufferFactoryService projectionBufferFactory, IEditorOperationsFactoryService editorOperationsFactory, ITextEditorFactoryService editorFactory, IRtfBuilderService rtfBuilderService, IIntellisenseSessionStackMapService intellisenseSessionStackMap, ISmartIndentationService smartIndenterService, IInteractiveEvaluator evaluator) { if (evaluator == null) { throw new ArgumentNullException(nameof(evaluator)); } _dangerous_uiOnly = new UIThreadOnly(this, host); this.Properties = new PropertyCollection(); _history = new History(); _intellisenseSessionStackMap = intellisenseSessionStackMap; _smartIndenterService = smartIndenterService; var replContentType = contentTypeRegistry.GetContentType(PredefinedInteractiveContentTypes.InteractiveContentTypeName); var replOutputContentType = contentTypeRegistry.GetContentType(PredefinedInteractiveContentTypes.InteractiveOutputContentTypeName); _outputBuffer = bufferFactory.CreateTextBuffer(replOutputContentType); _standardInputBuffer = bufferFactory.CreateTextBuffer(); _promptBuffer = bufferFactory.CreateTextBuffer(); _secondaryPromptBuffer = bufferFactory.CreateTextBuffer(); _standardInputPromptBuffer = bufferFactory.CreateTextBuffer(); _outputLineBreakBuffer = bufferFactory.CreateTextBuffer(); var projBuffer = projectionBufferFactory.CreateProjectionBuffer( new EditResolver(this), Array.Empty <object>(), ProjectionBufferOptions.None, replContentType); projBuffer.Properties.AddProperty(typeof(InteractiveWindow), this); _projectionBuffer = projBuffer; _dangerous_uiOnly.AppendNewOutputProjectionBuffer(); // Constructor runs on UI thread. projBuffer.Changed += new EventHandler <TextContentChangedEventArgs>(ProjectionBufferChanged); var roleSet = editorFactory.CreateTextViewRoleSet( PredefinedTextViewRoles.Analyzable, PredefinedTextViewRoles.Editable, PredefinedTextViewRoles.Interactive, PredefinedTextViewRoles.Zoomable, PredefinedInteractiveTextViewRoles.InteractiveTextViewRole); _textView = host.CreateTextView(this, projBuffer, roleSet); _textView.Caret.PositionChanged += CaretPositionChanged; _textView.Options.SetOptionValue(DefaultTextViewHostOptions.HorizontalScrollBarId, false); _textView.Options.SetOptionValue(DefaultTextViewHostOptions.LineNumberMarginId, false); _textView.Options.SetOptionValue(DefaultTextViewHostOptions.OutliningMarginId, false); _textView.Options.SetOptionValue(DefaultTextViewHostOptions.GlyphMarginId, false); _textView.Options.SetOptionValue(DefaultTextViewOptions.WordWrapStyleId, WordWrapStyles.WordWrap); _lineBreakString = _textView.Options.GetNewLineCharacter(); _dangerous_uiOnly.EditorOperations = editorOperationsFactory.GetEditorOperations(_textView); // Constructor runs on UI thread. _buffer = new OutputBuffer(this); _outputWriter = new InteractiveWindowWriter(this, spans: null); SortedSpans errorSpans = new SortedSpans(); _errorOutputWriter = new InteractiveWindowWriter(this, errorSpans); OutputClassifierProvider.AttachToBuffer(_outputBuffer, errorSpans); _rtfBuilderService = rtfBuilderService; RequiresUIThread(); evaluator.CurrentWindow = this; _evaluator = evaluator; }
private async Task DoInitializeAsync(IInteractiveEvaluator eval) { await eval.InitializeAsync(); }
private InteractiveWindowInfo CreateInteractiveWindow(IInteractiveEvaluator /*!*/ evaluator, IContentType /*!*/ contentType, string[] roles, int id, string /*!*/ title, Guid languageServiceGuid, string replId) { return(CreateInteractiveWindowInternal(evaluator, contentType, roles, id, title, languageServiceGuid, replId)); }
public InteractiveWindowMock(IWpfTextView textView, IInteractiveEvaluator evaluator = null) { TextView = textView; _textBuffer = textView.TextBuffer; Evaluator = evaluator ?? new InteractiveEvaluatorMock(this); }
public static Task <ExecutionResult> Reset(this IInteractiveEvaluator self) { return(self.ResetAsync()); }
public static Task <ExecutionResult> ExecuteText(this IInteractiveEvaluator self, string text) { return(self.ExecuteCodeAsync(text)); }
public IVsInteractiveWindow Create(Guid providerId, int instanceId, string title, IInteractiveEvaluator evaluator) { return new VsInteractiveWindow(_componentModel, providerId, instanceId, title, evaluator); }
public void Dispose() { _evaluator?.Dispose(); _evaluator = null; _window = null; }
private IVsInteractiveWindow CreateInteractiveWindowInternal( IInteractiveEvaluator evaluator, IContentType contentType, bool alwaysCreate, int id, string title, Guid languageServiceGuid, string replId ) { var creationFlags = __VSCREATETOOLWIN.CTW_fMultiInstance | __VSCREATETOOLWIN.CTW_fActivateWithProject; if (alwaysCreate) { creationFlags |= __VSCREATETOOLWIN.CTW_fForceCreate; } var replWindow = _windowFactory.Create(GuidList.guidPythonInteractiveWindowGuid, id, title, evaluator, creationFlags); replWindow.InteractiveWindow.Properties[VsInteractiveWindowKey] = replWindow; var toolWindow = replWindow as ToolWindowPane; if (toolWindow != null) { toolWindow.BitmapImageMoniker = KnownMonikers.PYInteractiveWindow; } replWindow.SetLanguage(GuidList.guidPythonLanguageServiceGuid, contentType); replWindow.InteractiveWindow.InitializeAsync(); var selectEval = evaluator as SelectableReplEvaluator; if (selectEval != null) { selectEval.ProvideInteractiveWindowEvents(InteractiveWindowEvents.GetOrCreate(replWindow)); } return replWindow; }
public IVsInteractiveWindow Create(Guid providerId, int instanceId, string title, IInteractiveEvaluator evaluator) { return(new VsInteractiveWindow(_componentModel, providerId, instanceId, title, evaluator)); }
private void DetachWindow(IInteractiveEvaluator oldEval) { }
public VsInteractiveWindowMock(IWpfTextView textView, IInteractiveEvaluator evaluator) { _textView = textView; InteractiveWindow = new InteractiveWindowMock(_textView, evaluator); }
private InteractiveWindowInfo CreateInteractiveWindowInternal(IInteractiveEvaluator evaluator, IContentType contentType, string[] roles, int id, string title, Guid languageServiceGuid, string replId) { var service = (IVsUIShell)ServiceProvider.GlobalProvider.GetService(typeof(SVsUIShell)); var model = (IComponentModel)ServiceProvider.GlobalProvider.GetService(typeof(SComponentModel)); SaveInteractiveInfo(id, evaluator, contentType, roles, title, languageServiceGuid, replId); // we don't pass __VSCREATETOOLWIN.CTW_fMultiInstance because multi instance panes are // destroyed when closed. We are really multi instance but we don't want to be closed. This // seems to work fine. __VSCREATETOOLWIN creationFlags = 0; if (!roles.Contains("DontPersist")) { creationFlags |= __VSCREATETOOLWIN.CTW_fForceCreate; } var replWindow = _windowFactory.Create(GuidList.guidPythonInteractiveWindowGuid, id, title, evaluator, creationFlags); replWindow.SetLanguage(GuidList.guidPythonLanguageServiceGuid, contentType); replWindow.InteractiveWindow.InitializeAsync(); return _windows[id] = new InteractiveWindowInfo(replWindow, replId); }
internal VsInteractiveWindow(IComponentModel model, Guid providerId, int instanceId, string title, IInteractiveEvaluator evaluator, __VSCREATETOOLWIN creationFlags) { _componentModel = model; this.Caption = title; _editorAdapters = _componentModel.GetService <IVsEditorAdaptersFactoryService>(); _evaluator = evaluator; // The following calls this.OnCreate: Guid clsId = this.ToolClsid; Guid empty = Guid.Empty; Guid typeId = providerId; IVsWindowFrame frame; var vsShell = (IVsUIShell)ServiceProvider.GlobalProvider.GetService(typeof(SVsUIShell)); // we don't pass __VSCREATETOOLWIN.CTW_fMultiInstance because multi instance panes are // destroyed when closed. We are really multi instance but we don't want to be closed. ErrorHandler.ThrowOnFailure( vsShell.CreateToolWindow( (uint)(__VSCREATETOOLWIN.CTW_fInitNew | __VSCREATETOOLWIN.CTW_fToolbarHost | creationFlags), (uint)instanceId, this.GetIVsWindowPane(), ref clsId, ref typeId, ref empty, null, title, null, out frame ) ); this.Frame = frame; }
public IVsInteractiveWindow Create(Guid providerId, int instanceId, string title, IInteractiveEvaluator evaluator, __VSCREATETOOLWIN creationFlags) { return new VsInteractiveWindow(_componentModel, providerId, instanceId, title, evaluator, creationFlags); }
public IVsInteractiveWindow Create(Guid providerId, int instanceId, string title, IInteractiveEvaluator evaluator, __VSCREATETOOLWIN creationFlags = 0) { return new VsInteractiveWindowMock(new WpfTextViewMock(new TextBufferMock(string.Empty, "R"))); }
internal static IInteractiveWindowCommands GetInteractiveCommands( IServiceProvider serviceProvider, IInteractiveWindow window, IInteractiveEvaluator eval ) { var model = serviceProvider.GetComponentModel(); var cmdFactory = model.GetService<IInteractiveWindowCommandsFactory>(); var cmds = model.GetExtensions<IInteractiveWindowCommand>(); var roles = eval.GetType() .GetCustomAttributes(typeof(InteractiveWindowRoleAttribute), true) .Select(r => ((InteractiveWindowRoleAttribute)r).Name) .ToArray(); var contentTypeRegistry = model.GetService<IContentTypeRegistryService>(); var contentTypes = eval.GetType() .GetCustomAttributes(typeof(ContentTypeAttribute), true) .Select(r => contentTypeRegistry.GetContentType(((ContentTypeAttribute)r).ContentTypes)) .ToArray(); return cmdFactory.CreateInteractiveCommands( window, "$", cmds.Where(x => IsCommandApplicable(x, roles, contentTypes)) ); }
public IVsInteractiveWindow Create(Guid providerId, int instanceId, string title, IInteractiveEvaluator evaluator, __VSCREATETOOLWIN creationFlags) { return(Create(providerId, instanceId, title, evaluator, creationFlags, Guid.Empty, 0, null)); }
public InteractiveWindow( IInteractiveWindowEditorFactoryService host, IContentTypeRegistryService contentTypeRegistry, ITextBufferFactoryService bufferFactory, IProjectionBufferFactoryService projectionBufferFactory, IEditorOperationsFactoryService editorOperationsFactory, ITextEditorFactoryService editorFactory, IIntellisenseSessionStackMapService intellisenseSessionStackMap, ISmartIndentationService smartIndenterService, IInteractiveEvaluator evaluator) { if (evaluator == null) { throw new ArgumentNullException(nameof(evaluator)); } _dangerous_uiOnly = new UIThreadOnly(this, host); this.Properties = new PropertyCollection(); _history = new History(); _intellisenseSessionStackMap = intellisenseSessionStackMap; _smartIndenterService = smartIndenterService; var textContentType = contentTypeRegistry.GetContentType("text"); var replContentType = contentTypeRegistry.GetContentType(PredefinedInteractiveContentTypes.InteractiveContentTypeName); var replOutputContentType = contentTypeRegistry.GetContentType(PredefinedInteractiveContentTypes.InteractiveOutputContentTypeName); _outputBuffer = bufferFactory.CreateTextBuffer(replOutputContentType); _standardInputBuffer = bufferFactory.CreateTextBuffer(); var projBuffer = projectionBufferFactory.CreateProjectionBuffer( new EditResolver(this), Array.Empty<object>(), ProjectionBufferOptions.None, replContentType); // we need to set IReplPromptProvider property before TextViewHost is instantiated so that ReplPromptTaggerProvider can bind to it projBuffer.Properties.AddProperty(typeof(InteractiveWindow), this); _projectionBuffer = projBuffer; _dangerous_uiOnly.AppendNewOutputProjectionBuffer(); // Constructor runs on UI thread. projBuffer.Changed += new EventHandler<TextContentChangedEventArgs>(ProjectionBufferChanged); var roleSet = editorFactory.CreateTextViewRoleSet( PredefinedTextViewRoles.Analyzable, PredefinedTextViewRoles.Editable, PredefinedTextViewRoles.Interactive, PredefinedTextViewRoles.Zoomable, PredefinedInteractiveTextViewRoles.InteractiveTextViewRole); _textView = host.CreateTextView(this, projBuffer, roleSet); _textView.Caret.PositionChanged += CaretPositionChanged; _textView.Options.SetOptionValue(DefaultTextViewHostOptions.HorizontalScrollBarId, false); _textView.Options.SetOptionValue(DefaultTextViewHostOptions.LineNumberMarginId, false); _textView.Options.SetOptionValue(DefaultTextViewHostOptions.OutliningMarginId, false); _textView.Options.SetOptionValue(DefaultTextViewHostOptions.GlyphMarginId, false); _textView.Options.SetOptionValue(DefaultTextViewOptions.WordWrapStyleId, WordWrapStyles.WordWrap); _lineBreakString = _textView.Options.GetNewLineCharacter(); _dangerous_uiOnly.EditorOperations = editorOperationsFactory.GetEditorOperations(_textView); // Constructor runs on UI thread. _buffer = new OutputBuffer(this); _outputWriter = new InteractiveWindowWriter(this, spans: null); SortedSpans errorSpans = new SortedSpans(); _errorOutputWriter = new InteractiveWindowWriter(this, errorSpans); OutputClassifierProvider.AttachToBuffer(_outputBuffer, errorSpans); RequiresUIThread(); evaluator.CurrentWindow = this; _evaluator = evaluator; }
public static Task <ExecutionResult> _Initialize(this IInteractiveEvaluator self, IInteractiveWindow window) { self.CurrentWindow = window; return(self.InitializeAsync()); }