forked from DonJayamanne/pythonVSCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproxy.ts
More file actions
30 lines (27 loc) · 1.56 KB
/
proxy.ts
File metadata and controls
30 lines (27 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
'use strict';
import { inject, injectable } from 'inversify';
import { Event, EventEmitter, Uri } from 'vscode';
import { IAsyncDisposableRegistry, IDisposableRegistry, Resource } from '../../common/types';
import { PythonInterpreter } from '../contracts';
import { IInterpreterAutoSeletionProxyService } from './types';
@injectable()
export class InterpreterAutoSeletionProxyService implements IInterpreterAutoSeletionProxyService {
private readonly didAutoSelectedInterpreterEmitter = new EventEmitter<void>();
private instance?: IInterpreterAutoSeletionProxyService;
constructor(@inject(IDisposableRegistry) private readonly disposables: IAsyncDisposableRegistry) { }
public registerInstance(instance: IInterpreterAutoSeletionProxyService): void {
this.instance = instance;
this.disposables.push(this.instance.onDidChangeAutoSelectedInterpreter(() => this.didAutoSelectedInterpreterEmitter.fire()));
}
public get onDidChangeAutoSelectedInterpreter(): Event<void> {
return this.didAutoSelectedInterpreterEmitter.event;
}
public getAutoSelectedInterpreter(resource: Resource): PythonInterpreter | undefined {
return this.instance ? this.instance.getAutoSelectedInterpreter(resource) : undefined;
}
public async setWorkspaceInterpreter(resource: Uri, interpreter: PythonInterpreter | undefined): Promise<void>{
return this.instance ? this.instance.setWorkspaceInterpreter(resource, interpreter) : undefined;
}
}