Skip to content

Commit

Permalink
Update to vscode-debugadapter 1.36.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Gama11 committed Sep 7, 2019
1 parent 3c14bc5 commit 4a5fdc0
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 41 deletions.
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ haxe:

install:
- haxelib install vscode
- haxelib git vscode-debugadapter https://github.com/vshaxe/vscode-debugadapter-extern
- haxelib git hxnodejs https://github.com/HaxeFoundation/hxnodejs
- haxelib install vscode-debugadapter

script:
- haxe build.hxml
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,8 @@ Replace `/bin/application.exe` with the path to your executable file.

```hxml
npm install
haxelib install hxnodejs
haxelib install vscode
haxelib git vscode-debugadapter https://github.com/vshaxe/vscode-debugadapter-extern
haxelib install vscode-debugadapter
```
5. Do `haxe build.hxml`
Expand Down
5 changes: 3 additions & 2 deletions build.hxml
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
-lib vscode-debugadapter
-lib hxnodejs
-lib vscode
-lib vscode-debugadapter
-cp src
-cp hxcpp-debug-server
-D js-es=6
-js bin/adapter.js
-main Adapter

--next

-lib vscode
-cp src
-D js-es=6
-js bin/extension.js
Extension
30 changes: 22 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 3 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"name": "vshaxe"
},
"engines": {
"vscode": "^1.4.0"
"vscode": "^1.36.0"
},
"categories": [
"Debuggers"
Expand All @@ -32,8 +32,8 @@
"url": "https://github.com/vshaxe/hxcpp-debugger/issues"
},
"dependencies": {
"vscode-debugprotocol": "1.19.0",
"vscode-debugadapter": "1.19.0"
"vscode-debugprotocol": "1.36.0",
"vscode-debugadapter": "1.36.0"
},
"scripts": {
"vscode:prepublish": "haxe build.hxml"
Expand All @@ -54,11 +54,6 @@
{
"type": "hxcpp",
"label": "HXCPP",
"enableBreakpointsFor": {
"languageIds": [
"haxe"
]
},
"program": "./bin/adapter.js",
"runtime": "node",
"configurationAttributes": {
Expand Down
37 changes: 18 additions & 19 deletions src/Adapter.hx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import haxe.Json;
import js.node.net.Socket;
import haxe.io.Path;
import protocol.debug.Types;
import vscode.debugAdapter.DebugSession;
import vscode.debugProtocol.DebugProtocol;
import js.node.Buffer;
import js.node.Net;
import js.node.ChildProcess;
Expand All @@ -10,25 +10,24 @@ import js.node.net.Socket.SocketEvent;
import js.node.stream.Readable.ReadableEvent;
import hxcpp.debug.jsonrpc.Protocol;

typedef HxppLaunchRequestArguments = {
> protocol.debug.Types.LaunchRequestArguments,
typedef HxppLaunchRequestArguments = LaunchRequestArguments & {
var program:String;
}

@:keep
class Adapter extends adapter.DebugSession {
class Adapter extends DebugSession {
function traceToOutput(value:Dynamic, ?infos:haxe.PosInfos) {
var msg = value;
if (infos != null && infos.customParams != null) {
msg += " " + infos.customParams.join(" ");
}
msg += "\n";
sendEvent(new adapter.DebugSession.OutputEvent(msg));
sendEvent(new vscode.debugAdapter.DebugSession.OutputEvent(msg));
}

override function initializeRequest(response:InitializeResponse, args:InitializeRequestArguments) {
haxe.Log.trace = traceToOutput;
sendEvent(new adapter.DebugSession.InitializedEvent());
sendEvent(new vscode.debugAdapter.DebugSession.InitializedEvent());
response.body.supportsSetVariable = true;
response.body.supportsValueFormattingOptions = false;
response.body.supportsCompletionsRequest = true;
Expand Down Expand Up @@ -68,13 +67,13 @@ class Adapter extends adapter.DebugSession {
}

function onExit(_, _) {
sendEvent(new adapter.DebugSession.TerminatedEvent(false));
sendEvent(new vscode.debugAdapter.DebugSession.TerminatedEvent(false));
}

var server = Net.createServer(onConnected);
server.listen(6972, function() {
var args = [];
var haxeProcess = ChildProcess.spawn(executable, args, {stdio: Pipe, cwd: Path.directory(executable)});
var haxeProcess = ChildProcess.spawn(executable, args, {stdio: Pipe, cwd: haxe.io.Path.directory(executable)});
haxeProcess.stdout.on(ReadableEvent.Data, onStdout);
haxeProcess.stderr.on(ReadableEvent.Data, onStderr);
haxeProcess.on(ChildProcessEvent.Exit, onExit);
Expand All @@ -97,38 +96,38 @@ class Adapter extends adapter.DebugSession {
});

function onExit() {
sendEvent(new adapter.DebugSession.TerminatedEvent(false));
sendEvent(new vscode.debugAdapter.DebugSession.TerminatedEvent(false));
}
socket.on(SocketEvent.End, onExit);
}

function onStdout(data:Buffer) {
sendEvent(new adapter.DebugSession.OutputEvent(data.toString("utf-8"), stdout));
sendEvent(new vscode.debugAdapter.DebugSession.OutputEvent(data.toString("utf-8"), Stdout));
}

function onStderr(data:Buffer) {
sendEvent(new adapter.DebugSession.OutputEvent(data.toString("utf-8"), stderr));
sendEvent(new vscode.debugAdapter.DebugSession.OutputEvent(data.toString("utf-8"), Stderr));
}

function onEvent<P>(type:NotificationMethod<P>, data:P) {
switch (type) {
case Protocol.PauseStop:
sendEvent(new adapter.DebugSession.StoppedEvent("pause", data.threadId));
sendEvent(new vscode.debugAdapter.DebugSession.StoppedEvent("pause", data.threadId));

case Protocol.BreakpointStop:
sendEvent(new adapter.DebugSession.StoppedEvent("breakpoint", data.threadId));
sendEvent(new vscode.debugAdapter.DebugSession.StoppedEvent("breakpoint", data.threadId));

case Protocol.ExceptionStop:
var evt = new adapter.DebugSession.StoppedEvent("exception", 0);
var evt = new vscode.debugAdapter.DebugSession.StoppedEvent("exception", 0);
evt.body.text = data.text;
sendEvent(evt);

case Protocol.ThreadStart:
var evt = new adapter.DebugSession.ThreadEvent(ThreadEventReason.started, data.threadId);
var evt = new vscode.debugAdapter.DebugSession.ThreadEvent(ThreadEventReason.Started, data.threadId);
sendEvent(evt);

case Protocol.ThreadExit:
var evt = new adapter.DebugSession.ThreadEvent(ThreadEventReason.exited, data.threadId);
var evt = new vscode.debugAdapter.DebugSession.ThreadEvent(ThreadEventReason.Exited, data.threadId);
sendEvent(evt);
}
}
Expand Down Expand Up @@ -322,10 +321,10 @@ class Adapter extends adapter.DebugSession {
} else {
return null;
}
return cast new adapter.DebugSession.Source(fileName, convertDebuggerPathToClient(filePath));
return cast new vscode.debugAdapter.DebugSession.Source(fileName, convertDebuggerPathToClient(filePath));
}

static function main() {
adapter.DebugSession.run(Adapter);
DebugSession.run(Adapter);
}
}

0 comments on commit 4a5fdc0

Please sign in to comment.