forked from microsoft/vscode-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserviceRegistry.ts
More file actions
281 lines (268 loc) · 12.7 KB
/
serviceRegistry.ts
File metadata and controls
281 lines (268 loc) · 12.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
'use strict';
import { IExtensionActivationService, IExtensionSingleActivationService } from '../activation/types';
import { IServiceManager } from '../ioc/types';
import { PreWarmActivatedEnvironmentVariables } from './activation/preWarmVariables';
import { EnvironmentActivationService } from './activation/service';
import { TerminalEnvironmentActivationService } from './activation/terminalEnvironmentActivationService';
import { IEnvironmentActivationService } from './activation/types';
import { InterpreterAutoSelectionService } from './autoSelection/index';
import { InterpreterAutoSeletionProxyService } from './autoSelection/proxy';
import { CachedInterpretersAutoSelectionRule } from './autoSelection/rules/cached';
import { CurrentPathInterpretersAutoSelectionRule } from './autoSelection/rules/currentPath';
import { SettingsInterpretersAutoSelectionRule } from './autoSelection/rules/settings';
import { SystemWideInterpretersAutoSelectionRule } from './autoSelection/rules/system';
import { WindowsRegistryInterpretersAutoSelectionRule } from './autoSelection/rules/winRegistry';
import { WorkspaceVirtualEnvInterpretersAutoSelectionRule } from './autoSelection/rules/workspaceEnv';
import {
AutoSelectionRule,
IInterpreterAutoSelectionRule,
IInterpreterAutoSelectionService,
IInterpreterAutoSeletionProxyService
} from './autoSelection/types';
import { InterpreterComparer } from './configuration/interpreterComparer';
import { InterpreterSelector } from './configuration/interpreterSelector';
import { PythonPathUpdaterService } from './configuration/pythonPathUpdaterService';
import { PythonPathUpdaterServiceFactory } from './configuration/pythonPathUpdaterServiceFactory';
import {
IInterpreterComparer,
IInterpreterSelector,
IPythonPathUpdaterServiceFactory,
IPythonPathUpdaterServiceManager
} from './configuration/types';
import {
CONDA_ENV_FILE_SERVICE,
CONDA_ENV_SERVICE,
CURRENT_PATH_SERVICE,
GLOBAL_VIRTUAL_ENV_SERVICE,
ICondaService,
IInterpreterDisplay,
IInterpreterHelper,
IInterpreterLocatorHelper,
IInterpreterLocatorProgressHandler,
IInterpreterLocatorProgressService,
IInterpreterLocatorService,
IInterpreterService,
IInterpreterVersionService,
IInterpreterWatcher,
IInterpreterWatcherBuilder,
IKnownSearchPathsForInterpreters,
INTERPRETER_LOCATOR_SERVICE,
IPipEnvService,
IShebangCodeLensProvider,
IVirtualEnvironmentsSearchPathProvider,
KNOWN_PATH_SERVICE,
PIPENV_SERVICE,
WINDOWS_REGISTRY_SERVICE,
WORKSPACE_VIRTUAL_ENV_SERVICE
} from './contracts';
import { InterpreterDisplay } from './display';
import { InterpreterSelectionTip } from './display/interpreterSelectionTip';
import { InterpreterLocatorProgressStatubarHandler } from './display/progressDisplay';
import { ShebangCodeLensProvider } from './display/shebangCodeLensProvider';
import { InterpreterHelper } from './helpers';
import { InterpreterService } from './interpreterService';
import { InterpreterVersionService } from './interpreterVersion';
import { InterpreterLocatorHelper } from './locators/helpers';
import { PythonInterpreterLocatorService } from './locators/index';
import { InterpreterLocatorProgressService } from './locators/progressService';
import { CondaEnvFileService } from './locators/services/condaEnvFileService';
import { CondaEnvService } from './locators/services/condaEnvService';
import { CondaService } from './locators/services/condaService';
import { CurrentPathService, PythonInPathCommandProvider } from './locators/services/currentPathService';
import {
GlobalVirtualEnvironmentsSearchPathProvider,
GlobalVirtualEnvService
} from './locators/services/globalVirtualEnvService';
import { InterpreterHashProvider } from './locators/services/hashProvider';
import { InterpeterHashProviderFactory } from './locators/services/hashProviderFactory';
import { InterpreterFilter } from './locators/services/interpreterFilter';
import { InterpreterWatcherBuilder } from './locators/services/interpreterWatcherBuilder';
import { KnownPathsService, KnownSearchPathsForInterpreters } from './locators/services/KnownPathsService';
import { PipEnvService } from './locators/services/pipEnvService';
import { PipEnvServiceHelper } from './locators/services/pipEnvServiceHelper';
import { WindowsRegistryService } from './locators/services/windowsRegistryService';
import { WindowsStoreInterpreter } from './locators/services/windowsStoreInterpreter';
import {
WorkspaceVirtualEnvironmentsSearchPathProvider,
WorkspaceVirtualEnvService
} from './locators/services/workspaceVirtualEnvService';
import { WorkspaceVirtualEnvWatcherService } from './locators/services/workspaceVirtualEnvWatcherService';
import { IPipEnvServiceHelper, IPythonInPathCommandProvider } from './locators/types';
import { CondaInheritEnvPrompt } from './virtualEnvs/condaInheritEnvPrompt';
import { VirtualEnvironmentManager } from './virtualEnvs/index';
import { IVirtualEnvironmentManager } from './virtualEnvs/types';
import { VirtualEnvironmentPrompt } from './virtualEnvs/virtualEnvPrompt';
/**
* Register all the new types inside this method.
* This method is created for testing purposes. Registers all interpreter types except `IInterpreterAutoSeletionProxyService`, `IEnvironmentActivationService`.
* See use case in `src\test\serviceRegistry.ts` for details
* @param serviceManager
*/
// tslint:disable-next-line: max-func-body-length
export function registerInterpreterTypes(serviceManager: IServiceManager) {
serviceManager.addSingleton<IKnownSearchPathsForInterpreters>(
IKnownSearchPathsForInterpreters,
KnownSearchPathsForInterpreters
);
serviceManager.addSingleton<IVirtualEnvironmentsSearchPathProvider>(
IVirtualEnvironmentsSearchPathProvider,
GlobalVirtualEnvironmentsSearchPathProvider,
'global'
);
serviceManager.addSingleton<IVirtualEnvironmentsSearchPathProvider>(
IVirtualEnvironmentsSearchPathProvider,
WorkspaceVirtualEnvironmentsSearchPathProvider,
'workspace'
);
serviceManager.addSingleton<ICondaService>(ICondaService, CondaService);
serviceManager.addSingleton<IPipEnvServiceHelper>(IPipEnvServiceHelper, PipEnvServiceHelper);
serviceManager.addSingleton<IVirtualEnvironmentManager>(IVirtualEnvironmentManager, VirtualEnvironmentManager);
serviceManager.addSingleton<IExtensionActivationService>(IExtensionActivationService, VirtualEnvironmentPrompt);
serviceManager.addSingleton<IExtensionSingleActivationService>(
IExtensionSingleActivationService,
InterpreterSelectionTip
);
serviceManager.addSingleton<IPythonInPathCommandProvider>(
IPythonInPathCommandProvider,
PythonInPathCommandProvider
);
serviceManager.add<IInterpreterWatcher>(
IInterpreterWatcher,
WorkspaceVirtualEnvWatcherService,
WORKSPACE_VIRTUAL_ENV_SERVICE
);
serviceManager.addSingleton<IInterpreterWatcherBuilder>(IInterpreterWatcherBuilder, InterpreterWatcherBuilder);
serviceManager.addSingleton<IInterpreterVersionService>(IInterpreterVersionService, InterpreterVersionService);
serviceManager.addSingleton<IInterpreterLocatorService>(
IInterpreterLocatorService,
PythonInterpreterLocatorService,
INTERPRETER_LOCATOR_SERVICE
);
serviceManager.addSingleton<IInterpreterLocatorService>(
IInterpreterLocatorService,
CondaEnvFileService,
CONDA_ENV_FILE_SERVICE
);
serviceManager.addSingleton<IInterpreterLocatorService>(
IInterpreterLocatorService,
CondaEnvService,
CONDA_ENV_SERVICE
);
serviceManager.addSingleton<IInterpreterLocatorService>(
IInterpreterLocatorService,
CurrentPathService,
CURRENT_PATH_SERVICE
);
serviceManager.addSingleton<IInterpreterLocatorService>(
IInterpreterLocatorService,
GlobalVirtualEnvService,
GLOBAL_VIRTUAL_ENV_SERVICE
);
serviceManager.addSingleton<IInterpreterLocatorService>(
IInterpreterLocatorService,
WorkspaceVirtualEnvService,
WORKSPACE_VIRTUAL_ENV_SERVICE
);
serviceManager.addSingleton<IInterpreterLocatorService>(IInterpreterLocatorService, PipEnvService, PIPENV_SERVICE);
serviceManager.addSingleton<IInterpreterLocatorService>(IPipEnvService, PipEnvService);
serviceManager.addSingleton<IInterpreterLocatorService>(
IInterpreterLocatorService,
WindowsRegistryService,
WINDOWS_REGISTRY_SERVICE
);
serviceManager.addSingleton<IInterpreterLocatorService>(
IInterpreterLocatorService,
KnownPathsService,
KNOWN_PATH_SERVICE
);
serviceManager.addSingleton<IInterpreterService>(IInterpreterService, InterpreterService);
serviceManager.addSingleton<IInterpreterDisplay>(IInterpreterDisplay, InterpreterDisplay);
serviceManager.addSingleton<IPythonPathUpdaterServiceFactory>(
IPythonPathUpdaterServiceFactory,
PythonPathUpdaterServiceFactory
);
serviceManager.addSingleton<IPythonPathUpdaterServiceManager>(
IPythonPathUpdaterServiceManager,
PythonPathUpdaterService
);
serviceManager.addSingleton<IInterpreterSelector>(IInterpreterSelector, InterpreterSelector);
serviceManager.addSingleton<IShebangCodeLensProvider>(IShebangCodeLensProvider, ShebangCodeLensProvider);
serviceManager.addSingleton<IInterpreterHelper>(IInterpreterHelper, InterpreterHelper);
serviceManager.addSingleton<IInterpreterLocatorHelper>(IInterpreterLocatorHelper, InterpreterLocatorHelper);
serviceManager.addSingleton<IInterpreterComparer>(IInterpreterComparer, InterpreterComparer);
serviceManager.addSingleton<IInterpreterLocatorProgressHandler>(
IInterpreterLocatorProgressHandler,
InterpreterLocatorProgressStatubarHandler
);
serviceManager.addSingleton<IInterpreterLocatorProgressService>(
IInterpreterLocatorProgressService,
InterpreterLocatorProgressService
);
serviceManager.addSingleton<IInterpreterAutoSelectionRule>(
IInterpreterAutoSelectionRule,
CurrentPathInterpretersAutoSelectionRule,
AutoSelectionRule.currentPath
);
serviceManager.addSingleton<IInterpreterAutoSelectionRule>(
IInterpreterAutoSelectionRule,
SystemWideInterpretersAutoSelectionRule,
AutoSelectionRule.systemWide
);
serviceManager.addSingleton<IInterpreterAutoSelectionRule>(
IInterpreterAutoSelectionRule,
WindowsRegistryInterpretersAutoSelectionRule,
AutoSelectionRule.windowsRegistry
);
serviceManager.addSingleton<IInterpreterAutoSelectionRule>(
IInterpreterAutoSelectionRule,
WorkspaceVirtualEnvInterpretersAutoSelectionRule,
AutoSelectionRule.workspaceVirtualEnvs
);
serviceManager.addSingleton<IInterpreterAutoSelectionRule>(
IInterpreterAutoSelectionRule,
CachedInterpretersAutoSelectionRule,
AutoSelectionRule.cachedInterpreters
);
serviceManager.addSingleton<IInterpreterAutoSelectionRule>(
IInterpreterAutoSelectionRule,
SettingsInterpretersAutoSelectionRule,
AutoSelectionRule.settings
);
serviceManager.addSingleton<IInterpreterAutoSelectionService>(
IInterpreterAutoSelectionService,
InterpreterAutoSelectionService
);
serviceManager.addSingleton<IExtensionActivationService>(IExtensionActivationService, CondaInheritEnvPrompt);
serviceManager.addSingleton<WindowsStoreInterpreter>(WindowsStoreInterpreter, WindowsStoreInterpreter);
serviceManager.addSingleton<InterpreterHashProvider>(InterpreterHashProvider, InterpreterHashProvider);
serviceManager.addSingleton<InterpeterHashProviderFactory>(
InterpeterHashProviderFactory,
InterpeterHashProviderFactory
);
serviceManager.addSingleton<InterpreterFilter>(InterpreterFilter, InterpreterFilter);
serviceManager.addSingleton<IExtensionSingleActivationService>(
IExtensionSingleActivationService,
PreWarmActivatedEnvironmentVariables
);
}
export function registerTypes(serviceManager: IServiceManager) {
registerInterpreterTypes(serviceManager);
serviceManager.addSingleton<IInterpreterAutoSeletionProxyService>(
IInterpreterAutoSeletionProxyService,
InterpreterAutoSeletionProxyService
);
serviceManager.addSingleton<IEnvironmentActivationService>(
EnvironmentActivationService,
EnvironmentActivationService
);
serviceManager.addSingleton<IEnvironmentActivationService>(
TerminalEnvironmentActivationService,
TerminalEnvironmentActivationService
);
serviceManager.addSingleton<IEnvironmentActivationService>(
IEnvironmentActivationService,
EnvironmentActivationService
);
}