Skip to content

Commit f88636a

Browse files
author
Kartik Raj
committed
Change IEnvironmentProvider interface
1 parent df3d795 commit f88636a

File tree

3 files changed

+20
-13
lines changed

3 files changed

+20
-13
lines changed

src/client/pythonEnvironments/base/locator.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,22 +70,22 @@ interface ILocatorFactoryAPI {
7070

7171
export type ProposedDetailsAPI = (env: BaseEnvInfo) => Promise<EnvironmentDetailsByProvider | undefined>;
7272
export type InternalDetailsAPI = (env: BasicEnvInfo) => Promise<PythonEnvInfo | undefined>;
73-
74-
export interface IDetailsAPI {
73+
export interface IResolverAPI {
74+
/**
75+
* Carries API to check if an environment can be recognized by the provider. Providers
76+
* which returns details about an {@link EnvSource} are expected to
77+
* provide this.
78+
*/
79+
readonly sourceIdentifier: IIdentifierAPI | undefined;
7580
/**
76-
* This is only called if the provider:
77-
* * Can identify the environment.
78-
* * Or can iterate out the environment.
7981
* Returns details or `undefined` if it was found if env is invalid.
82+
* This is only called if:
83+
* * The provider can identify the environment.
84+
* * To get more details out of an environment already iterated by the provider.
8085
*/
8186
getEnvironmentDetails: ProposedDetailsAPI;
8287
}
8388

84-
export type IResolverAPI = IDetailsAPI | (IDetailsAPI & IIdentifierAPI);
85-
86-
/**
87-
* Identifier need not be registered
88-
*/
8989
interface IIdentifierAPI {
9090
/**
9191
* Environment source the provider identifies.
@@ -98,6 +98,7 @@ interface IIdentifierAPI {
9898
}
9999

100100
export interface IInternalResolverAPI {
101+
readonly kindIdentifier: IInternalIdentifierAPI | undefined;
101102
getEnvironmentDetails: InternalDetailsAPI;
102103
}
103104

src/client/pythonEnvironments/base/locators/composite/envsResolver.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ export class PythonEnvsResolver implements IResolvingLocator {
4040
if (this.parentLocator.addNewLocator) {
4141
this.parentLocator.addNewLocator(provider.createLocator, metadata);
4242
}
43-
registerIdentifier(metadata.environments.envKinds[0], provider.canIdentifyEnvironment);
43+
if (provider.kindIdentifier) {
44+
registerIdentifier(provider.kindIdentifier.envKind, provider.kindIdentifier.canIdentifyEnvironment);
45+
}
4446
registerResolver(metadata.environments.envKinds[0], provider.getEnvironmentDetails);
4547
}
4648

src/client/pythonEnvironments/converter.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,12 @@ export function convertProviderMetaData(proposed: EnvironmentProviderMetadata):
4747

4848
function convertResolverAPI(proposed: IResolverAPI): IInternalResolverAPI {
4949
return {
50-
envKind: proposed.envSource ? convertKind(proposed.envSource) : undefined,
51-
canIdentifyEnvironment: proposed.canIdentifyEnvironment,
50+
kindIdentifier: proposed.sourceIdentifier
51+
? {
52+
envKind: convertKind(proposed.sourceIdentifier.envSource),
53+
canIdentifyEnvironment: proposed.sourceIdentifier.canIdentifyEnvironment,
54+
}
55+
: undefined,
5256
getEnvironmentDetails: convertDetailsAPI(proposed.getEnvironmentDetails),
5357
};
5458
}

0 commit comments

Comments
 (0)