google / go-jsonnet

Apache License 2.0
1.61k stars 231 forks source link

feat: add debugger support #739

Closed theSuess closed 3 months ago

theSuess commented 9 months ago

This PR adds an extension point for future debugger implementations.

We first investigated having the entire debugger codebase only use go-jsonnet as a dependency, but many of the fields and types needed to implement this are not exposed to external packages.

To solve this, we added a new Debugger type, which allows debugging frontends to control the evaluation of a specific file.

The API type is heavily inspired by the Debug Adapter Protocol and can be used to implement basic debugging functionality like:

Example implementations of clients using this interface can be found in the example-clients branch of our fork.

The following recording shows the basic capabilities in action by using the DAP example client with VSCode:

https://github.com/google/go-jsonnet/assets/1364576/f2f6c2a4-32c1-468b-bc93-1d9c18f2a665

theSuess commented 6 months ago

We have released an implementation of the example client as a standalone package at grafana/jsonnet-debugger.

It is also integrated into the latest version of our vscode-jsonnet extension.

The debugger uses the grafana/go-jsonnet-debugger fork to implement the functionality until the PR is merged

sbarzowski commented 3 months ago

Really cool stuff.

Added some comments for potential follow-up, but merging as it is.