@@ -6,56 +6,57 @@ import { CancellationToken, Event, Uri, WorkspaceFolder } from 'vscode';
6
6
// https://github.com/microsoft/vscode-python/wiki/Proposed-Environment-APIs
7
7
8
8
export interface ProposedExtensionAPI {
9
- environment : EnvironmentAPI ;
10
- }
11
-
12
- interface EnvironmentAPI {
13
- /**
14
- * Returns the environment configured by user in settings.
15
- * @param resource : Uri of a file or workspace folder. This is used to determine the env in a multi-root
16
- * scenario. If `undefined`, then the API returns what ever is set for the workspace.
17
- */
18
- getActiveEnvironmentId ( resource ?: Resource ) : EnvironmentId ;
19
- /**
20
- * Sets the active environment path for the python extension for the resource. Configuration target will always
21
- * be the workspace folder.
22
- * @param environment : Full path to environment folder or python executable for the environment. Can also pass
23
- * the environment itself.
24
- * @param resource : [optional] File or workspace to scope to a particular workspace folder.
25
- */
26
- updateActiveEnvironmentId ( environment : Environment | EnvironmentId | string , resource ?: Resource ) : Promise < void > ;
27
- /**
28
- * This event is triggered when the active environment setting changes.
29
- */
30
- readonly onDidChangeActiveEnvironmentId : Event < ActiveEnvironmentIdChangeEvent > ;
31
- /**
32
- * Carries environments found by the extension at the time of fetching the property. Note a refresh might be
33
- * going on so this may not be the complete list.
34
- */
35
- readonly all : readonly Environment [ ] ;
36
- /**
37
- * This event is triggered when the known environment list changes, like when a environment
38
- * is found, existing environment is removed, or some details changed on an environment.
39
- */
40
- readonly onDidChangeEnvironments : Event < EnvironmentsChangeEvent > ;
41
- /**
42
- * This API will trigger environment discovery, but only if it has not already happened in this VSCode session.
43
- * Useful for making sure env list is up-to-date when the caller needs it for the first time.
44
- *
45
- * To force trigger a refresh regardless of whether a refresh was already triggered, see option
46
- * {@link RefreshOptions.forceRefresh}.
47
- *
48
- * Note that if there is a refresh already going on then this returns the promise for that refresh.
49
- * @param options Additional options for refresh.
50
- * @param token A cancellation token that indicates a refresh is no longer needed.
51
- */
52
- refreshEnvironments ( options ?: RefreshOptions , token ?: CancellationToken ) : Promise < void > ;
53
- /**
54
- * Returns details for the given environment, or `undefined` if the env is invalid.
55
- * @param environment : Full path to environment folder or python executable for the environment. Can also pass
56
- * the environment id or the environment itself.
57
- */
58
- resolveEnvironment ( environment : Environment | EnvironmentId | string ) : Promise < ResolvedEnvironment | undefined > ;
9
+ readonly environment : {
10
+ /**
11
+ * Returns the environment configured by user in settings.
12
+ * @param resource : Uri of a file or workspace folder. This is used to determine the env in a multi-root
13
+ * scenario. If `undefined`, then the API returns what ever is set for the workspace.
14
+ */
15
+ getActiveEnvironmentId ( resource ?: Resource ) : EnvironmentId ;
16
+ /**
17
+ * Sets the active environment path for the python extension for the resource. Configuration target will always
18
+ * be the workspace folder.
19
+ * @param environment : Full path to environment folder or python executable for the environment. Can also pass
20
+ * the environment itself.
21
+ * @param resource : [optional] File or workspace to scope to a particular workspace folder.
22
+ */
23
+ updateActiveEnvironmentId (
24
+ environment : Environment | EnvironmentId | string ,
25
+ resource ?: Resource ,
26
+ ) : Promise < void > ;
27
+ /**
28
+ * This event is triggered when the active environment setting changes.
29
+ */
30
+ readonly onDidChangeActiveEnvironmentId : Event < ActiveEnvironmentIdChangeEvent > ;
31
+ /**
32
+ * Carries environments found by the extension at the time of fetching the property. Note this may not
33
+ * contain all environments in the system as a refresh might be going on.
34
+ */
35
+ readonly all : readonly Environment [ ] ;
36
+ /**
37
+ * This event is triggered when the known environment list changes, like when a environment
38
+ * is found, existing environment is removed, or some details changed on an environment.
39
+ */
40
+ readonly onDidChangeEnvironments : Event < EnvironmentsChangeEvent > ;
41
+ /**
42
+ * This API will trigger environment discovery, but only if it has not already happened in this VSCode session.
43
+ * Useful for making sure env list is up-to-date when the caller needs it for the first time.
44
+ *
45
+ * To force trigger a refresh regardless of whether a refresh was already triggered, see option
46
+ * {@link RefreshOptions.forceRefresh}.
47
+ *
48
+ * Note that if there is a refresh already going on then this returns the promise for that refresh.
49
+ * @param options Additional options for refresh.
50
+ * @param token A cancellation token that indicates a refresh is no longer needed.
51
+ */
52
+ refreshEnvironments ( options ?: RefreshOptions , token ?: CancellationToken ) : Promise < void > ;
53
+ /**
54
+ * Returns details for the given environment, or `undefined` if the env is invalid.
55
+ * @param environment : Full path to environment folder or python executable for the environment. Can also pass
56
+ * the environment id or the environment itself.
57
+ */
58
+ resolveEnvironment ( environment : Environment | EnvironmentId | string ) : Promise < ResolvedEnvironment | undefined > ;
59
+ } ;
59
60
}
60
61
61
62
export type RefreshOptions = {
0 commit comments