Skip to content

Commit 9543501

Browse files
author
Kartik Raj
committed
Remove old API in favor of this
1 parent a34dbe9 commit 9543501

File tree

6 files changed

+13
-23
lines changed

6 files changed

+13
-23
lines changed

src/client/interpreter/contracts.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { CodeLensProvider, ConfigurationTarget, Disposable, Event, TextDocument,
33
import { FileChangeType } from '../common/platform/fileSystemWatcher';
44
import { Resource } from '../common/types';
55
import { PythonEnvSource } from '../pythonEnvironments/base/info';
6-
import { PythonLocatorQuery } from '../pythonEnvironments/base/locator';
6+
import { ProgressNotificationEvent, PythonLocatorQuery } from '../pythonEnvironments/base/locator';
77
import { CondaEnvironmentInfo } from '../pythonEnvironments/common/environmentManagers/conda';
88
import { EnvironmentType, PythonEnvironment } from '../pythonEnvironments/info';
99

@@ -16,7 +16,7 @@ export type PythonEnvironmentsChangedEvent = {
1616

1717
export const IComponentAdapter = Symbol('IComponentAdapter');
1818
export interface IComponentAdapter {
19-
readonly onRefreshStart: Event<void>;
19+
readonly onProgress: Event<ProgressNotificationEvent>;
2020
triggerRefresh(query?: PythonLocatorQuery & { clearCache?: boolean }, trigger?: 'auto' | 'ui'): Promise<void>;
2121
readonly refreshPromise: Promise<void> | undefined;
2222
readonly onChanged: Event<PythonEnvironmentsChangedEvent>;
@@ -63,7 +63,6 @@ export interface ICondaService {
6363

6464
export const IInterpreterService = Symbol('IInterpreterService');
6565
export interface IInterpreterService {
66-
readonly onRefreshStart: Event<void>;
6766
triggerRefresh(query?: PythonLocatorQuery & { clearCache?: boolean }, trigger?: 'auto' | 'ui'): Promise<void>;
6867
readonly refreshPromise: Promise<void> | undefined;
6968
readonly onDidChangeInterpreters: Event<PythonEnvironmentsChangedEvent>;

src/client/interpreter/display/progressDisplay.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { IDisposableRegistry } from '../../common/types';
1212
import { createDeferred, Deferred } from '../../common/utils/async';
1313
import { Interpreters } from '../../common/utils/localize';
1414
import { traceDecoratorVerbose } from '../../logging';
15+
import { ProgressReportStage } from '../../pythonEnvironments/base/locator';
1516
import { IComponentAdapter } from '../contracts';
1617

1718
// The parts of IComponentAdapter used here.
@@ -30,11 +31,13 @@ export class InterpreterLocatorProgressStatubarHandler implements IExtensionSing
3031
) {}
3132

3233
public async activate(): Promise<void> {
33-
this.pyenvs.onRefreshStart(
34-
() => {
35-
this.showProgress();
36-
if (this.pyenvs.refreshPromise) {
37-
this.pyenvs.refreshPromise.then(() => this.hideProgress());
34+
this.pyenvs.onProgress(
35+
(event) => {
36+
if (event.stage === ProgressReportStage.discoveryStarted) {
37+
this.showProgress();
38+
if (this.pyenvs.refreshPromise) {
39+
this.pyenvs.refreshPromise.then(() => this.hideProgress());
40+
}
3841
}
3942
},
4043
this,

src/client/interpreter/interpreterService.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,6 @@ export class InterpreterService implements Disposable, IInterpreterService {
4040
return this.pyenvs.hasInterpreters(filter);
4141
}
4242

43-
public get onRefreshStart(): Event<void> {
44-
return this.pyenvs.onRefreshStart;
45-
}
46-
4743
public triggerRefresh(
4844
query?: PythonLocatorQuery & { clearCache?: boolean },
4945
trigger?: 'auto' | 'ui',

src/client/pythonEnvironments/api.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,6 @@ class PythonEnvironments implements IDiscoveryAPI {
3131
return this.locator.onProgress;
3232
}
3333

34-
public get onRefreshStart() {
35-
return this.locator.onRefreshStart;
36-
}
37-
3834
public get refreshPromise() {
3935
return this.locator.refreshPromise;
4036
}

src/client/pythonEnvironments/base/locator.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -188,13 +188,9 @@ export interface IResolvingLocator<I = PythonEnvInfo> extends IResolver, ILocato
188188

189189
export interface IDiscoveryAPI {
190190
/**
191-
* Fires when the known list of environments starts refreshing, i.e when discovery starts or restarts.
191+
* Fires with details of the current discovery progress, i.e when it starts, finishes or any other relevant stage.
192192
*/
193193
readonly onProgress: Event<ProgressNotificationEvent>;
194-
/**
195-
* Fires when the known list of environments starts refreshing, i.e when discovery starts or restarts.
196-
*/
197-
readonly onRefreshStart: Event<void>;
198194
/**
199195
* Fires with details if the known list changes.
200196
*/

src/client/pythonEnvironments/legacyIOC.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ class ComponentAdapter implements IComponentAdapter {
111111
return this.api.refreshPromise;
112112
}
113113

114-
public get onRefreshStart(): vscode.Event<void> {
115-
return this.api.onRefreshStart;
114+
public get onProgress() {
115+
return this.api.onProgress;
116116
}
117117

118118
public get onChanged() {

0 commit comments

Comments
 (0)