1
- import haxe .Json ;
2
1
import js .node .net .Socket ;
3
2
import haxe .io .Path ;
4
- import protocol .debug .Types ;
3
+ import vscode .debugAdapter .DebugSession ;
4
+ import vscode .debugProtocol .DebugProtocol ;
5
5
import js .node .Buffer ;
6
6
import js .node .Net ;
7
7
import js .node .ChildProcess ;
@@ -10,25 +10,24 @@ import js.node.net.Socket.SocketEvent;
10
10
import js .node .stream .Readable .ReadableEvent ;
11
11
import hxcpp .debug .jsonrpc .Protocol ;
12
12
13
- typedef HxppLaunchRequestArguments = {
14
- > protocol.debug. Types . LaunchRequestArguments ,
13
+ typedef HxppLaunchRequestArguments = LaunchRequestArguments & {
15
14
var program : String ;
16
15
}
17
16
18
17
@:keep
19
- class Adapter extends adapter. DebugSession {
18
+ class Adapter extends DebugSession {
20
19
function traceToOutput (value : Dynamic , ? infos : haxe. PosInfos ) {
21
20
var msg = value ;
22
21
if (infos != null && infos .customParams != null ) {
23
22
msg + = " " + infos .customParams .join (" " );
24
23
}
25
24
msg + = " \n " ;
26
- sendEvent (new adapter .DebugSession . OutputEvent (msg ));
25
+ sendEvent (new vscode.debugAdapter .DebugSession . OutputEvent (msg ));
27
26
}
28
27
29
28
override function initializeRequest (response : InitializeResponse , args : InitializeRequestArguments ) {
30
29
haxe. Log .trace = traceToOutput ;
31
- sendEvent (new adapter .DebugSession . InitializedEvent ());
30
+ sendEvent (new vscode.debugAdapter .DebugSession . InitializedEvent ());
32
31
response .body .supportsSetVariable = true ;
33
32
response .body .supportsValueFormattingOptions = false ;
34
33
response .body .supportsCompletionsRequest = true ;
@@ -68,13 +67,13 @@ class Adapter extends adapter.DebugSession {
68
67
}
69
68
70
69
function onExit (_ , _ ) {
71
- sendEvent (new adapter .DebugSession . TerminatedEvent (false ));
70
+ sendEvent (new vscode.debugAdapter .DebugSession . TerminatedEvent (false ));
72
71
}
73
72
74
73
var server = Net .createServer (onConnected );
75
74
server .listen (6972 , function () {
76
75
var args = [];
77
- var haxeProcess = ChildProcess .spawn (executable , args , {stdio : Pipe , cwd : Path .directory (executable )});
76
+ var haxeProcess = ChildProcess .spawn (executable , args , {stdio : Pipe , cwd : haxe.io. Path .directory (executable )});
78
77
haxeProcess .stdout .on (ReadableEvent . Data , onStdout );
79
78
haxeProcess .stderr .on (ReadableEvent . Data , onStderr );
80
79
haxeProcess .on (ChildProcessEvent . Exit , onExit );
@@ -97,38 +96,38 @@ class Adapter extends adapter.DebugSession {
97
96
});
98
97
99
98
function onExit () {
100
- sendEvent (new adapter .DebugSession . TerminatedEvent (false ));
99
+ sendEvent (new vscode.debugAdapter .DebugSession . TerminatedEvent (false ));
101
100
}
102
101
socket .on (SocketEvent . End , onExit );
103
102
}
104
103
105
104
function onStdout (data : Buffer ) {
106
- sendEvent (new adapter. DebugSession . OutputEvent (data .toString (" utf-8" ), stdout ));
105
+ sendEvent (new vscode.debugAdapter. DebugSession . OutputEvent (data .toString (" utf-8" ), Stdout ));
107
106
}
108
107
109
108
function onStderr (data : Buffer ) {
110
- sendEvent (new adapter. DebugSession . OutputEvent (data .toString (" utf-8" ), stderr ));
109
+ sendEvent (new vscode.debugAdapter. DebugSession . OutputEvent (data .toString (" utf-8" ), Stderr ));
111
110
}
112
111
113
112
function onEvent <P >(type : NotificationMethod <P >, data : P ) {
114
113
switch (type ) {
115
114
case Protocol . PauseStop :
116
- sendEvent (new adapter .DebugSession . StoppedEvent (" pause" , data .threadId ));
115
+ sendEvent (new vscode.debugAdapter .DebugSession . StoppedEvent (" pause" , data .threadId ));
117
116
118
117
case Protocol . BreakpointStop :
119
- sendEvent (new adapter .DebugSession . StoppedEvent (" breakpoint" , data .threadId ));
118
+ sendEvent (new vscode.debugAdapter .DebugSession . StoppedEvent (" breakpoint" , data .threadId ));
120
119
121
120
case Protocol . ExceptionStop :
122
- var evt = new adapter .DebugSession . StoppedEvent (" exception" , 0 );
121
+ var evt = new vscode.debugAdapter .DebugSession . StoppedEvent (" exception" , 0 );
123
122
evt .body .text = data .text ;
124
123
sendEvent (evt );
125
124
126
125
case Protocol . ThreadStart :
127
- var evt = new adapter. DebugSession . ThreadEvent (ThreadEventReason .started , data .threadId );
126
+ var evt = new vscode.debugAdapter. DebugSession . ThreadEvent (ThreadEventReason . Started , data .threadId );
128
127
sendEvent (evt );
129
128
130
129
case Protocol . ThreadExit :
131
- var evt = new adapter. DebugSession . ThreadEvent (ThreadEventReason .exited , data .threadId );
130
+ var evt = new vscode.debugAdapter. DebugSession . ThreadEvent (ThreadEventReason . Exited , data .threadId );
132
131
sendEvent (evt );
133
132
}
134
133
}
@@ -322,10 +321,10 @@ class Adapter extends adapter.DebugSession {
322
321
} else {
323
322
return null ;
324
323
}
325
- return cast new adapter .DebugSession . Source (fileName , convertDebuggerPathToClient (filePath ));
324
+ return cast new vscode.debugAdapter .DebugSession . Source (fileName , convertDebuggerPathToClient (filePath ));
326
325
}
327
326
328
327
static function main () {
329
- adapter. DebugSession .run (Adapter );
328
+ DebugSession .run (Adapter );
330
329
}
331
330
}
0 commit comments