@@ -5,19 +5,19 @@ import { CancellationToken, Event, Uri, WorkspaceFolder } from 'vscode';
55
66// https://github.com/microsoft/vscode-python/wiki/Proposed-Environment-APIs
77
8- export interface IProposedExtensionAPI {
9- environment : IEnvironmentAPI ;
8+ export interface ProposedExtensionAPI {
9+ environment : EnvironmentAPI ;
1010}
1111
12- interface IEnvironmentAPI {
12+ interface EnvironmentAPI {
1313 /**
1414 * Carries the API to track the selected environment by the user for a workspace.
1515 */
16- activeEnvironment : IActiveEnvironmentAPI ;
16+ activeEnvironment : ActiveEnvironmentAPI ;
1717 /**
1818 * Carries the API necessary for locating environments.
1919 */
20- locator : IEnvironmentLocatorAPI ;
20+ locator : EnvironmentLocatorAPI ;
2121 /**
2222 * Returns details for the given environment, or `undefined` if the env is invalid.
2323 * @param environment : Environment whose details you need. Can also pass the full path to environment folder
@@ -26,7 +26,7 @@ interface IEnvironmentAPI {
2626 resolveEnvironment ( environment : Environment | UniquePath ) : Promise < ResolvedEnvironment | undefined > ;
2727}
2828
29- interface IActiveEnvironmentAPI {
29+ interface ActiveEnvironmentAPI {
3030 /**
3131 * Returns the environment selected. Uses the cache by default, otherwise fetches full information about the
3232 * environment.
@@ -45,10 +45,10 @@ interface IActiveEnvironmentAPI {
4545 /**
4646 * This event is triggered when the active environment changes.
4747 */
48- onDidChange : Event < ActiveEnvironmentChangedParams > ;
48+ onDidChange : Event < ActiveEnvironmentChangeEvent > ;
4949}
5050
51- interface IEnvironmentLocatorAPI {
51+ interface EnvironmentLocatorAPI {
5252 /**
5353 * Carries environments found by the extension at the time of fetching the property. Note a refresh might be
5454 * 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 {
5959 * This event is triggered when the known environment list changes, like when a environment
6060 * is found, existing environment is removed, or some details changed on an environment.
6161 */
62- onDidChangeEnvironments : Event < EnvironmentsChangedParams > ;
62+ onDidChangeEnvironments : Event < EnvironmentsChangedEvent > ;
6363 /**
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.
6565 */
6666 refreshState : RefreshState ;
6767 /**
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 .
7070 */
7171 readonly onDidChangeRefreshState : Event < RefreshState > ;
7272 /**
@@ -115,7 +115,7 @@ export type Environment = {
115115 /**
116116 * Type of the environment.
117117 */
118- type : EnvType ;
118+ type : EnvironmentType ;
119119 /**
120120 * Name to the environment if any.
121121 */
@@ -132,7 +132,7 @@ export type Environment = {
132132 * Tools/plugins which created the environment or where it came from. First value in array corresponds
133133 * to the primary source, which never changes over time.
134134 */
135- source : EnvSource [ ] ;
135+ source : EnvironmentSource [ ] ;
136136 }
137137 | undefined ;
138138 /**
@@ -146,23 +146,43 @@ export type Environment = {
146146 } ;
147147} ;
148148
149+ /**
150+ * A new form of object `T` where no property can have the value of `undefined`.
151+ */
149152type MakeAllPropertiesNonNullable < T > = {
150153 [ P in keyof T ] : NonNullable < T [ P ] > ;
151154} ;
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 > > ;
155160
156- type EnvironmentInfo = NonNullable < Pick < Environment , 'environment' > [ 'environment' ] > ;
161+ type ExecutableInfo = MakePropertyNonNullable < Environment [ 'executable' ] , 'sysPrefix' > &
162+ MakePropertyNonNullable < Environment [ 'executable' ] , 'bitness' > ;
157163export type PythonVersionInfo = MakeAllPropertiesNonNullable < Environment [ 'version' ] > ;
158164
159165/**
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.
161168 */
162169export interface ResolvedEnvironment {
170+ /**
171+ * See {@link UniquePath} for description.
172+ */
163173 pathID : UniquePath ;
174+ /**
175+ * New form of {@link Environment.executable} object where properties `sysPrefix` and `bitness` cannot be
176+ * `undefined`.
177+ */
164178 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+ */
166186 version : PythonVersionInfo ;
167187}
168188
@@ -171,7 +191,7 @@ export type RefreshState = {
171191} ;
172192
173193/**
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 .
175195 */
176196export enum RefreshStateValue {
177197 /**
@@ -199,7 +219,7 @@ export type Resource = Uri | WorkspaceFolder;
199219 */
200220export type UniquePath = string ;
201221
202- export type EnvironmentsChangedParams = {
222+ export type EnvironmentsChangedEvent = {
203223 env : Environment ;
204224 /**
205225 * * "add": New environment is added.
@@ -209,7 +229,7 @@ export type EnvironmentsChangedParams = {
209229 type : 'add' | 'remove' | 'update' ;
210230} ;
211231
212- export type ActiveEnvironmentChangedParams = {
232+ export type ActiveEnvironmentChangeEvent = {
213233 /**
214234 * See {@link UniquePath} for description.
215235 */
@@ -231,28 +251,36 @@ export type RefreshOptions = {
231251} ;
232252
233253/**
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.
236256 */
237- export type EnvSource = KnownEnvSources | string ;
257+ export type EnvironmentSource = KnownEnvironmentSources | string ;
238258/**
239259 * Tools or plugins the Python extension is aware of.
240260 */
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' ;
242269
243270/**
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.
245272 */
246- export type EnvType = KnownEnvTypes | string ;
273+ export type EnvironmentType = KnownEnvironmentTypes | string ;
247274/**
248275 * Environment types the Python extension is aware of.
249276 */
250- export type KnownEnvTypes = 'VirtualEnv' | 'Conda' | 'Unknown' ;
277+ export type KnownEnvironmentTypes = 'VirtualEnv' | 'Conda' | 'Unknown' ;
251278
252279/**
253280 * Carries bitness for an environment.
254281 */
255282export type Architecture = 'x86' | 'x64' | 'Unknown' ;
283+
256284/**
257285 * The possible Python release levels.
258286 */
0 commit comments