forked from microsoft/vscode-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreplProvider.ts
More file actions
30 lines (29 loc) · 1.42 KB
/
replProvider.ts
File metadata and controls
30 lines (29 loc) · 1.42 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
import { Disposable } from 'vscode';
import { IActiveResourceService, ICommandManager } from '../common/application/types';
import { Commands } from '../common/constants';
import { IServiceContainer } from '../ioc/types';
import { captureTelemetry } from '../telemetry';
import { EventName } from '../telemetry/constants';
import { ICodeExecutionService } from '../terminals/types';
export class ReplProvider implements Disposable {
private readonly disposables: Disposable[] = [];
private activeResourceService: IActiveResourceService;
constructor(private serviceContainer: IServiceContainer) {
this.activeResourceService = this.serviceContainer.get<IActiveResourceService>(IActiveResourceService);
this.registerCommand();
}
public dispose() {
this.disposables.forEach(disposable => disposable.dispose());
}
private registerCommand() {
const commandManager = this.serviceContainer.get<ICommandManager>(ICommandManager);
const disposable = commandManager.registerCommand(Commands.Start_REPL, this.commandHandler, this);
this.disposables.push(disposable);
}
@captureTelemetry(EventName.REPL)
private async commandHandler() {
const resource = this.activeResourceService.getActiveResource();
const replProvider = this.serviceContainer.get<ICodeExecutionService>(ICodeExecutionService, 'repl');
await replProvider.initializeRepl(resource);
}
}