forked from DonJayamanne/pythonVSCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRemoteDebugClient.ts
More file actions
40 lines (36 loc) · 1.57 KB
/
Copy pathRemoteDebugClient.ts
File metadata and controls
40 lines (36 loc) · 1.57 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
31
32
33
34
35
36
37
38
39
40
import { DebugSession } from 'vscode-debugadapter';
import { AttachRequestArgumentsV1, BaseAttachRequestArguments, IPythonProcess } from '../Common/Contracts';
import { BaseDebugServer } from '../DebugServers/BaseDebugServer';
import { RemoteDebugServer } from '../DebugServers/RemoteDebugServer';
import { RemoteDebugServerV2 } from '../DebugServers/RemoteDebugServerv2';
import { DebugClient, DebugType } from './DebugClient';
export class RemoteDebugClient<T extends BaseAttachRequestArguments> extends DebugClient<T> {
private pythonProcess?: IPythonProcess;
private debugServer?: BaseDebugServer;
// tslint:disable-next-line:no-any
constructor(args: T, debugSession: DebugSession) {
super(args, debugSession);
}
public CreateDebugServer(pythonProcess?: IPythonProcess): BaseDebugServer {
if (this.args.type === 'pythonExperimental') {
// tslint:disable-next-line:no-any
this.debugServer = new RemoteDebugServerV2(this.debugSession, undefined as any, this.args);
} else {
this.pythonProcess = pythonProcess!;
this.debugServer = new RemoteDebugServer(this.debugSession, this.pythonProcess!, this.args as {} as AttachRequestArgumentsV1);
}
return this.debugServer!;
}
public get DebugType(): DebugType {
return DebugType.Remote;
}
public Stop() {
if (this.pythonProcess) {
this.pythonProcess.Detach();
}
if (this.debugServer) {
this.debugServer.Stop();
this.debugServer = undefined;
}
}
}