internal PythonToolsService(IServiceContainer container, bool forTests = false) { _forTests = forTests; _container = container; _langPrefs = new Lazy <LanguagePreferences>(() => new LanguagePreferences(Site, typeof(PythonLanguageInfo).GUID)); _interpreterOptionsService = new Lazy <IInterpreterOptionsService>(Site.GetComponentModel().GetService <IInterpreterOptionsService>); _interpreterRegistryService = new Lazy <IInterpreterRegistryService>(Site.GetComponentModel().GetService <IInterpreterRegistryService>); _optionsService = (IPythonToolsOptionsService)container.GetService(typeof(IPythonToolsOptionsService)); _idleManager = !forTests ? new IdleManager(container) : null; _formattingOptions = new Lazy <PythonFormattingOptions>(CreateFormattingOptions); _advancedEditorOptions = new Lazy <PythonAdvancedEditorOptions>(CreateAdvancedEditorOptions); _debuggerOptions = new Lazy <PythonDebuggingOptions>(CreateDebuggerOptions); _condaOptions = new Lazy <PythonCondaOptions>(CreateCondaOptions); _analysisOptions = new Lazy <PythonAnalysisOptions>(CreateAnalysisOptions); _generalOptions = new Lazy <PythonGeneralOptions>(CreateGeneralOptions); _suppressDialogOptions = new Lazy <SuppressDialogOptions>(() => new SuppressDialogOptions(this)); _interactiveOptions = new Lazy <PythonInteractiveOptions>(() => CreateInteractiveOptions("Interactive")); _debugInteractiveOptions = new Lazy <PythonInteractiveOptions>(() => CreateInteractiveOptions("Debug Interactive Window")); _diagnosticsProvider = new DiagnosticsProvider(container); Logger = (IPythonToolsLogger)container.GetService(typeof(IPythonToolsLogger)); EnvironmentSwitcherManager = new EnvironmentSwitcherManager(container); WorkspaceInfoBarManager = new WorkspaceInfoBarManager(container); if (_idleManager != null) { _idleManager.OnIdle += OnIdleInitialization; } }
internal PythonToolsService(IServiceContainer container) { _container = container; _analyzers = new ConcurrentDictionary <string, VsProjectAnalyzer>(); _langPrefs = new Lazy <LanguagePreferences>(() => new LanguagePreferences(this, typeof(PythonLanguageInfo).GUID)); _interpreterOptionsService = new Lazy <IInterpreterOptionsService>(Site.GetComponentModel().GetService <IInterpreterOptionsService>); _interpreterRegistryService = new Lazy <IInterpreterRegistryService>(Site.GetComponentModel().GetService <IInterpreterRegistryService>); _optionsService = (IPythonToolsOptionsService)container.GetService(typeof(IPythonToolsOptionsService)); _idleManager = new IdleManager(container); _advancedOptions = new Lazy <AdvancedEditorOptions>(CreateAdvancedEditorOptions); _debuggerOptions = new Lazy <DebuggerOptions>(CreateDebuggerOptions); _condaOptions = new Lazy <CondaOptions>(CreateCondaOptions); _diagnosticsOptions = new Lazy <DiagnosticsOptions>(CreateDiagnosticsOptions); _generalOptions = new Lazy <GeneralOptions>(CreateGeneralOptions); _languageServerOptions = new Lazy <LanguageServerOptions>(CreateLanguageServerOptions); _suppressDialogOptions = new Lazy <SuppressDialogOptions>(() => new SuppressDialogOptions(this)); _interactiveOptions = new Lazy <PythonInteractiveOptions>(() => CreateInteractiveOptions("Interactive")); _debugInteractiveOptions = new Lazy <PythonInteractiveOptions>(() => CreateInteractiveOptions("Debug Interactive Window")); _diagnosticsProvider = new DiagnosticsProvider(container); Logger = (IPythonToolsLogger)container.GetService(typeof(IPythonToolsLogger)); EnvironmentSwitcherManager = new EnvironmentSwitcherManager(container); _idleManager.OnIdle += OnIdleInitialization; EditorServices = ComponentModel.GetService <PythonEditorServices>(); EditorServices.SetPythonToolsService(this); }
public CurrentEnvironmentCommand(IServiceProvider serviceProvider) : base(null, null, QueryStatus, new CommandID(GuidList.guidPythonToolsCmdSet, (int)PkgCmdIDList.comboIdCurrentEnvironment)) { _serviceProvider = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider)); _envSwitchMgr = serviceProvider.GetPythonToolsService().EnvironmentSwitcherManager; _logger = serviceProvider.GetService(typeof(IPythonToolsLogger)) as IPythonToolsLogger; }
private void OnIdleInitialization(object sender, ComponentManagerEventArgs e) { Site.AssertShellIsInitialized(); _idleManager.OnIdle -= OnIdleInitialization; _expansionCompletions = new ExpansionCompletionSource(Site); InitializeLogging(); EnvironmentSwitcherManager.Initialize(); }
public void Dispose() { if (_langPrefs.IsValueCreated) { _langPrefs.Value.Dispose(); } _idleManager.Dispose(); EnvironmentSwitcherManager.Dispose(); WorkspaceInfoBarManager.Dispose(); }
private void OnIdleInitialization(object sender, ComponentManagerEventArgs e) { Site.AssertShellIsInitialized(); if (_idleManager != null) { _idleManager.OnIdle -= OnIdleInitialization; } InitializeLogging(); EnvironmentSwitcherManager.Initialize(); }
public static Task AddEnvironmentAsync(EnvironmentSwitcherManager envSwitchMgr, IServiceProvider serviceProvider, AddEnvironmentDialog.PageKind page) { var workspace = (envSwitchMgr.Context as EnvironmentSwitcherWorkspaceContext)?.Workspace; var project = (envSwitchMgr.Context as EnvironmentSwitcherProjectContext)?.Project; if (workspace == null && project == null) { var sln = (IVsSolution)serviceProvider.GetService(typeof(SVsSolution)); project = sln?.EnumerateLoadedPythonProjects().FirstOrDefault(); } return(AddEnvironmentDialog.ShowDialogAsync( page, serviceProvider, project, workspace, null, null, null )); }
public void Dispose() { if (_langPrefs.IsValueCreated) { _langPrefs.Value.Dispose(); } _idleManager.Dispose(); foreach (var window in _codeWindowManagers.Values.ToArray()) { window.RemoveAdornments(); } _codeWindowManagers.Clear(); foreach (var kv in GetActiveSharedAnalyzers()) { kv.Value.Dispose(); } EnvironmentSwitcherManager.Dispose(); WorkspaceInfoBarManager.Dispose(); }
public SwitchToEnvironmentCommand(IServiceProvider serviceProvider) { _serviceProvider = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider)); _envSwitchMgr = serviceProvider.GetPythonToolsService().EnvironmentSwitcherManager; }
public ManagePackagesCommand(IServiceProvider serviceProvider) { _serviceProvider = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider)); _envSwitchMgr = serviceProvider.GetPythonToolsService().EnvironmentSwitcherManager; _optionsService = serviceProvider.GetComponentModel().GetService <IInterpreterOptionsService>(); }
public AddEnvironmentCommand(IServiceProvider serviceProvider, AddEnvironmentDialog.PageKind page) { _serviceProvider = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider)); _page = page; _envSwitchMgr = serviceProvider.GetPythonToolsService().EnvironmentSwitcherManager; }