@@ -5,19 +5,19 @@ import { CancellationToken, Event, Uri, WorkspaceFolder } from 'vscode';
5
5
6
6
// https://github.com/microsoft/vscode-python/wiki/Proposed-Environment-APIs
7
7
8
- export interface IProposedExtensionAPI {
9
- environment : IEnvironmentAPI ;
8
+ export interface ProposedExtensionAPI {
9
+ environment : EnvironmentAPI ;
10
10
}
11
11
12
- interface IEnvironmentAPI {
12
+ interface EnvironmentAPI {
13
13
/**
14
14
* Carries the API to track the selected environment by the user for a workspace.
15
15
*/
16
- activeEnvironment : IActiveEnvironmentAPI ;
16
+ activeEnvironment : ActiveEnvironmentAPI ;
17
17
/**
18
18
* Carries the API necessary for locating environments.
19
19
*/
20
- locator : IEnvironmentLocatorAPI ;
20
+ locator : EnvironmentLocatorAPI ;
21
21
/**
22
22
* Returns details for the given environment, or `undefined` if the env is invalid.
23
23
* @param environment : Environment whose details you need. Can also pass the full path to environment folder
@@ -26,7 +26,7 @@ interface IEnvironmentAPI {
26
26
resolveEnvironment ( environment : Environment | UniquePath ) : Promise < ResolvedEnvironment | undefined > ;
27
27
}
28
28
29
- interface IActiveEnvironmentAPI {
29
+ interface ActiveEnvironmentAPI {
30
30
/**
31
31
* Returns the environment selected. Uses the cache by default, otherwise fetches full information about the
32
32
* environment.
@@ -45,10 +45,10 @@ interface IActiveEnvironmentAPI {
45
45
/**
46
46
* This event is triggered when the active environment changes.
47
47
*/
48
- onDidChange : Event < ActiveEnvironmentChangedParams > ;
48
+ onDidChange : Event < ActiveEnvironmentChangeEvent > ;
49
49
}
50
50
51
- interface IEnvironmentLocatorAPI {
51
+ interface EnvironmentLocatorAPI {
52
52
/**
53
53
* Carries environments found by the extension at the time of fetching the property. Note a refresh might be
54
54
* going on so this may not be the complete list. To wait on complete list use {@link refreshState()} and
@@ -59,14 +59,14 @@ interface IEnvironmentLocatorAPI {
59
59
* This event is triggered when the known environment list changes, like when a environment
60
60
* is found, existing environment is removed, or some details changed on an environment.
61
61
*/
62
- onDidChangeEnvironments : Event < EnvironmentsChangedParams > ;
62
+ onDidChangeEnvironments : Event < EnvironmentsChangedEvent > ;
63
63
/**
64
- * Returns the last known state in the refresh, i.e whether it started, finished, or any other relevant state.
64
+ * Carries the current state in the refresh, i.e whether it started, finished, or any other relevant state.
65
65
*/
66
66
refreshState : RefreshState ;
67
67
/**
68
- * Tracks refresh progress for current list of known environments , i.e when it starts, finishes or any other
69
- * relevant state .
68
+ * Fires when a refresh state has been reached , i.e when it starts, finishes or any other relevant state.
69
+ * Tracks refresh progress for current list of known environments .
70
70
*/
71
71
readonly onDidChangeRefreshState : Event < RefreshState > ;
72
72
/**
@@ -115,7 +115,7 @@ export type Environment = {
115
115
/**
116
116
* Type of the environment.
117
117
*/
118
- type : EnvType ;
118
+ type : EnvironmentType ;
119
119
/**
120
120
* Name to the environment if any.
121
121
*/
@@ -132,7 +132,7 @@ export type Environment = {
132
132
* Tools/plugins which created the environment or where it came from. First value in array corresponds
133
133
* to the primary source, which never changes over time.
134
134
*/
135
- source : EnvSource [ ] ;
135
+ source : EnvironmentSource [ ] ;
136
136
}
137
137
| undefined ;
138
138
/**
@@ -146,23 +146,43 @@ export type Environment = {
146
146
} ;
147
147
} ;
148
148
149
+ /**
150
+ * A new form of object `T` where no property can have the value of `undefined`.
151
+ */
149
152
type MakeAllPropertiesNonNullable < T > = {
150
153
[ P in keyof T ] : NonNullable < T [ P ] > ;
151
154
} ;
152
- type MakeNonNullable < Type , Key extends keyof Type > = Omit < Type , Key > & MakeAllPropertiesNonNullable < Pick < Type , Key > > ;
153
- type ExecutableInfo = MakeNonNullable < Environment [ 'executable' ] , 'sysPrefix' > &
154
- MakeNonNullable < Environment [ 'executable' ] , 'bitness' > ;
155
+ /**
156
+ * A new form of object `Type` where a property represented by `Key` cannot be `undefined`.
157
+ */
158
+ type MakePropertyNonNullable < Type , Key extends keyof Type > = Omit < Type , Key > &
159
+ MakeAllPropertiesNonNullable < Pick < Type , Key > > ;
155
160
156
- type EnvironmentInfo = NonNullable < Pick < Environment , 'environment' > [ 'environment' ] > ;
161
+ type ExecutableInfo = MakePropertyNonNullable < Environment [ 'executable' ] , 'sysPrefix' > &
162
+ MakePropertyNonNullable < Environment [ 'executable' ] , 'bitness' > ;
157
163
export type PythonVersionInfo = MakeAllPropertiesNonNullable < Environment [ 'version' ] > ;
158
164
159
165
/**
160
- * Derived form of {@link Environment} with complete information, which means certain properties can no longer be `undefined`.
166
+ * Derived form of {@link Environment} where certain properties can no longer be `undefined`. Meant to represent an
167
+ * {@link Environment} with complete information.
161
168
*/
162
169
export interface ResolvedEnvironment {
170
+ /**
171
+ * See {@link UniquePath} for description.
172
+ */
163
173
pathID : UniquePath ;
174
+ /**
175
+ * New form of {@link Environment.executable} object where properties `sysPrefix` and `bitness` cannot be
176
+ * `undefined`.
177
+ */
164
178
executable : ExecutableInfo ;
165
- environment : EnvironmentInfo | undefined ;
179
+ /**
180
+ * See {@link Environment.environment} for description.
181
+ */
182
+ environment : Environment [ 'environment' ] ;
183
+ /**
184
+ * New form of {@link Environment.version} object where no properties can be `undefined`.
185
+ */
166
186
version : PythonVersionInfo ;
167
187
}
168
188
@@ -171,7 +191,7 @@ export type RefreshState = {
171
191
} ;
172
192
173
193
/**
174
- * Value of the enum indicates which states comes before when a refresh takes place .
194
+ * Contains state values in the order they finish during a refresh cycle .
175
195
*/
176
196
export enum RefreshStateValue {
177
197
/**
@@ -199,7 +219,7 @@ export type Resource = Uri | WorkspaceFolder;
199
219
*/
200
220
export type UniquePath = string ;
201
221
202
- export type EnvironmentsChangedParams = {
222
+ export type EnvironmentsChangedEvent = {
203
223
env : Environment ;
204
224
/**
205
225
* * "add": New environment is added.
@@ -209,7 +229,7 @@ export type EnvironmentsChangedParams = {
209
229
type : 'add' | 'remove' | 'update' ;
210
230
} ;
211
231
212
- export type ActiveEnvironmentChangedParams = {
232
+ export type ActiveEnvironmentChangeEvent = {
213
233
/**
214
234
* See {@link UniquePath} for description.
215
235
*/
@@ -231,28 +251,36 @@ export type RefreshOptions = {
231
251
} ;
232
252
233
253
/**
234
- * Tool/plugin where the environment came from. It could be {@link KnownEnvSources } or custom string which was
235
- * contributed.
254
+ * Tool/plugin where the environment came from. It can be {@link KnownEnvironmentSources } or custom string which
255
+ * was contributed.
236
256
*/
237
- export type EnvSource = KnownEnvSources | string ;
257
+ export type EnvironmentSource = KnownEnvironmentSources | string ;
238
258
/**
239
259
* Tools or plugins the Python extension is aware of.
240
260
*/
241
- export type KnownEnvSources = 'Conda' | 'Pipenv' | 'Poetry' | 'VirtualEnv' | 'Venv' | 'VirtualEnvWrapper' | 'Pyenv' ;
261
+ export type KnownEnvironmentSources =
262
+ | 'Conda'
263
+ | 'Pipenv'
264
+ | 'Poetry'
265
+ | 'VirtualEnv'
266
+ | 'Venv'
267
+ | 'VirtualEnvWrapper'
268
+ | 'Pyenv' ;
242
269
243
270
/**
244
- * Type of the environment. It could be {@link KnownEnvTypes } or custom string which was contributed.
271
+ * Type of the environment. It can be {@link KnownEnvironmentTypes } or custom string which was contributed.
245
272
*/
246
- export type EnvType = KnownEnvTypes | string ;
273
+ export type EnvironmentType = KnownEnvironmentTypes | string ;
247
274
/**
248
275
* Environment types the Python extension is aware of.
249
276
*/
250
- export type KnownEnvTypes = 'VirtualEnv' | 'Conda' | 'Unknown' ;
277
+ export type KnownEnvironmentTypes = 'VirtualEnv' | 'Conda' | 'Unknown' ;
251
278
252
279
/**
253
280
* Carries bitness for an environment.
254
281
*/
255
282
export type Architecture = 'x86' | 'x64' | 'Unknown' ;
283
+
256
284
/**
257
285
* The possible Python release levels.
258
286
*/
0 commit comments