internal static IVsInteractiveWindow /*!*/ EnsureReplWindow(IServiceProvider serviceProvider, InterpreterConfiguration config, PythonProjectNode project) { var compModel = serviceProvider.GetComponentModel(); var provider = compModel.GetService <InteractiveWindowProvider>(); var vsProjectContext = compModel.GetService <VsProjectContextProvider>(); var projectId = project != null?PythonReplEvaluatorProvider.GetEvaluatorId(project) : null; var configId = config != null?PythonReplEvaluatorProvider.GetEvaluatorId(config) : null; if (config?.IsRunnable() == false) { throw new MissingInterpreterException( Strings.MissingEnvironment.FormatUI(config.Description, config.Version) ); } IVsInteractiveWindow window; // If we find an open window for the project, prefer that to a per-config one if (!string.IsNullOrEmpty(projectId)) { window = provider.Open( projectId, e => ((e as SelectableReplEvaluator)?.Evaluator as PythonCommonInteractiveEvaluator)?.AssociatedProjectHasChanged != true ); if (window != null) { return(window); } } // If we find an open window for the configuration, return that if (!string.IsNullOrEmpty(configId)) { window = provider.Open(configId); if (window != null) { return(window); } } // No window found, so let's create one if (!string.IsNullOrEmpty(projectId)) { window = provider.Create(projectId); project.AddActionOnClose(window, w => InteractiveWindowProvider.CloseIfEvaluatorMatches(w, projectId)); } else if (!string.IsNullOrEmpty(configId)) { window = provider.Create(configId); } else { var interpService = compModel.GetService <IInterpreterOptionsService>(); window = provider.Create(PythonReplEvaluatorProvider.GetEvaluatorId(interpService.DefaultInterpreter.Configuration)); } return(window); }
internal static IVsInteractiveWindow /*!*/ EnsureReplWindow(IServiceProvider serviceProvider, InterpreterConfiguration config, PythonProjectNode project) { var compModel = serviceProvider.GetComponentModel(); var provider = compModel.GetService <InteractiveWindowProvider>(); var vsProjectContext = compModel.GetService <VsProjectContextProvider>(); var projectId = project != null?PythonReplEvaluatorProvider.GetEvaluatorId(project) : null; var configId = config != null?PythonReplEvaluatorProvider.GetEvaluatorId(config) : null; IVsInteractiveWindow window; // If we find an open window for the project, prefer that to a per-config one if (!string.IsNullOrEmpty(projectId)) { window = provider.Open(projectId); if (window != null) { if (window.InteractiveWindow.GetPythonEvaluator()?.AssociatedProjectHasChanged == true) { // We have an existing window, but it needs to be reset. // Let's create a new one window = provider.Create(projectId); project.AddActionOnClose(window, w => InteractiveWindowProvider.CloseIfEvaluatorMatches(w, projectId)); } return(window); } } // If we find an open window for the configuration, return that if (!string.IsNullOrEmpty(configId)) { window = provider.Open(configId); if (window != null) { return(window); } } // No window found, so let's create one if (!string.IsNullOrEmpty(projectId)) { window = provider.Create(projectId); project.AddActionOnClose(window, w => InteractiveWindowProvider.CloseIfEvaluatorMatches(w, projectId)); } else if (!string.IsNullOrEmpty(configId)) { window = provider.Create(configId); } else { var interpService = compModel.GetService <IInterpreterOptionsService>(); window = provider.Create(PythonReplEvaluatorProvider.GetEvaluatorId(interpService.DefaultInterpreter.Configuration)); } return(window); }