Skip to content

Commit

Permalink
Remove old API in favor of this
Browse files Browse the repository at this point in the history
  • Loading branch information
Kartik Raj committed May 11, 2022
1 parent a34dbe9 commit 9543501
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 23 deletions.
5 changes: 2 additions & 3 deletions src/client/interpreter/contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { CodeLensProvider, ConfigurationTarget, Disposable, Event, TextDocument,
import { FileChangeType } from '../common/platform/fileSystemWatcher';
import { Resource } from '../common/types';
import { PythonEnvSource } from '../pythonEnvironments/base/info';
import { PythonLocatorQuery } from '../pythonEnvironments/base/locator';
import { ProgressNotificationEvent, PythonLocatorQuery } from '../pythonEnvironments/base/locator';
import { CondaEnvironmentInfo } from '../pythonEnvironments/common/environmentManagers/conda';
import { EnvironmentType, PythonEnvironment } from '../pythonEnvironments/info';

Expand All @@ -16,7 +16,7 @@ export type PythonEnvironmentsChangedEvent = {

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

export const IInterpreterService = Symbol('IInterpreterService');
export interface IInterpreterService {
readonly onRefreshStart: Event<void>;
triggerRefresh(query?: PythonLocatorQuery & { clearCache?: boolean }, trigger?: 'auto' | 'ui'): Promise<void>;
readonly refreshPromise: Promise<void> | undefined;
readonly onDidChangeInterpreters: Event<PythonEnvironmentsChangedEvent>;
Expand Down
13 changes: 8 additions & 5 deletions src/client/interpreter/display/progressDisplay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { IDisposableRegistry } from '../../common/types';
import { createDeferred, Deferred } from '../../common/utils/async';
import { Interpreters } from '../../common/utils/localize';
import { traceDecoratorVerbose } from '../../logging';
import { ProgressReportStage } from '../../pythonEnvironments/base/locator';
import { IComponentAdapter } from '../contracts';

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

public async activate(): Promise<void> {
this.pyenvs.onRefreshStart(
() => {
this.showProgress();
if (this.pyenvs.refreshPromise) {
this.pyenvs.refreshPromise.then(() => this.hideProgress());
this.pyenvs.onProgress(
(event) => {
if (event.stage === ProgressReportStage.discoveryStarted) {
this.showProgress();
if (this.pyenvs.refreshPromise) {
this.pyenvs.refreshPromise.then(() => this.hideProgress());
}
}
},
this,
Expand Down
4 changes: 0 additions & 4 deletions src/client/interpreter/interpreterService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@ export class InterpreterService implements Disposable, IInterpreterService {
return this.pyenvs.hasInterpreters(filter);
}

public get onRefreshStart(): Event<void> {
return this.pyenvs.onRefreshStart;
}

public triggerRefresh(
query?: PythonLocatorQuery & { clearCache?: boolean },
trigger?: 'auto' | 'ui',
Expand Down
4 changes: 0 additions & 4 deletions src/client/pythonEnvironments/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ class PythonEnvironments implements IDiscoveryAPI {
return this.locator.onProgress;
}

public get onRefreshStart() {
return this.locator.onRefreshStart;
}

public get refreshPromise() {
return this.locator.refreshPromise;
}
Expand Down
6 changes: 1 addition & 5 deletions src/client/pythonEnvironments/base/locator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,13 +188,9 @@ export interface IResolvingLocator<I = PythonEnvInfo> extends IResolver, ILocato

export interface IDiscoveryAPI {
/**
* Fires when the known list of environments starts refreshing, i.e when discovery starts or restarts.
* Fires with details of the current discovery progress, i.e when it starts, finishes or any other relevant stage.
*/
readonly onProgress: Event<ProgressNotificationEvent>;
/**
* Fires when the known list of environments starts refreshing, i.e when discovery starts or restarts.
*/
readonly onRefreshStart: Event<void>;
/**
* Fires with details if the known list changes.
*/
Expand Down
4 changes: 2 additions & 2 deletions src/client/pythonEnvironments/legacyIOC.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ class ComponentAdapter implements IComponentAdapter {
return this.api.refreshPromise;
}

public get onRefreshStart(): vscode.Event<void> {
return this.api.onRefreshStart;
public get onProgress() {
return this.api.onProgress;
}

public get onChanged() {
Expand Down

0 comments on commit 9543501

Please sign in to comment.