@@ -7,7 +7,6 @@ import { Event, Uri } from 'vscode';
7
7
import { IAsyncIterableIterator , iterEmpty } from '../../common/utils/async' ;
8
8
import { PythonEnvInfo , PythonEnvKind , PythonEnvSource } from './info' ;
9
9
import {
10
- BasicPythonEnvsChangedEvent ,
11
10
IPythonEnvsWatcher ,
12
11
PythonEnvCollectionChangedEvent ,
13
12
PythonEnvsChangedEvent ,
@@ -128,6 +127,14 @@ export type PythonLocatorQuery = BasicPythonLocatorQuery & {
128
127
* If provided, results should be limited to within these locations.
129
128
*/
130
129
searchLocations ?: SearchLocations ;
130
+ /**
131
+ * If provided, results should be limited envs provided by these locators.
132
+ */
133
+ providerId ?: string ;
134
+ /**
135
+ * If provided, results area limited to this env.
136
+ */
137
+ envPath ?: string ;
131
138
} ;
132
139
133
140
type QueryForEvent < E > = E extends PythonEnvsChangedEvent ? PythonLocatorQuery : BasicPythonLocatorQuery ;
@@ -153,8 +160,8 @@ export type BasicEnvInfo = {
153
160
* events emitted via `onChanged` do not need to provide information
154
161
* for the specific environments that changed.
155
162
*/
156
- export interface ILocator < I = PythonEnvInfo , E extends BasicPythonEnvsChangedEvent = PythonEnvsChangedEvent >
157
- extends IPythonEnvsWatcher < E > {
163
+ export interface ILocator < I = PythonEnvInfo , E = PythonEnvsChangedEvent > extends IPythonEnvsWatcher < E > {
164
+ readonly providerId : string ;
158
165
/**
159
166
* Iterate over the enviroments known tos this locator.
160
167
*
@@ -174,6 +181,8 @@ export interface ILocator<I = PythonEnvInfo, E extends BasicPythonEnvsChangedEve
174
181
iterEnvs ( query ?: QueryForEvent < E > ) : IPythonEnvsIterator < I > ;
175
182
}
176
183
184
+ export type ICompositeLocator < I = PythonEnvInfo , E = PythonEnvsChangedEvent > = Omit < ILocator < I , E > , 'providerId' > ;
185
+
177
186
interface IResolver {
178
187
/**
179
188
* Find as much info about the given Python environment as possible.
@@ -184,7 +193,7 @@ interface IResolver {
184
193
resolveEnv ( path : string ) : Promise < PythonEnvInfo | undefined > ;
185
194
}
186
195
187
- export interface IResolvingLocator < I = PythonEnvInfo > extends IResolver , ILocator < I > { }
196
+ export interface IResolvingLocator < I = PythonEnvInfo > extends IResolver , ICompositeLocator < I > { }
188
197
189
198
export interface GetRefreshEnvironmentsOptions {
190
199
/**
@@ -234,7 +243,7 @@ export interface IDiscoveryAPI {
234
243
resolveEnv ( path : string ) : Promise < PythonEnvInfo | undefined > ;
235
244
}
236
245
237
- interface IEmitter < E extends PythonEnvsChangedEvent > {
246
+ interface IEmitter < E > {
238
247
fire ( e : E ) : void ;
239
248
}
240
249
@@ -250,10 +259,11 @@ interface IEmitter<E extends PythonEnvsChangedEvent> {
250
259
* should be used. Only in low-level cases should you consider using
251
260
* `BasicPythonEnvsChangedEvent`.
252
261
*/
253
- abstract class LocatorBase < I = PythonEnvInfo , E extends BasicPythonEnvsChangedEvent = PythonEnvsChangedEvent >
254
- implements ILocator < I , E > {
262
+ abstract class LocatorBase < I = PythonEnvInfo , E = PythonEnvsChangedEvent > implements ILocator < I , E > {
255
263
public readonly onChanged : Event < E > ;
256
264
265
+ public abstract readonly providerId : string ;
266
+
257
267
protected readonly emitter : IEmitter < E > ;
258
268
259
269
constructor ( watcher : IPythonEnvsWatcher < E > & IEmitter < E > ) {
0 commit comments