SublimeDebugger icon indicating copy to clipboard operation
SublimeDebugger copied to clipboard

How to start a debugging session via API ?

Open ayoub-benali opened this issue 4 years ago • 1 comments

I am trying to integrate in https://github.com/scalameta/metals-sublime with this package. It is a helper package for Metals and already takes care of the installation. The debug workflow get started via code lenses, so as far as I understand there isn't a need to implement the adapter class.

I already have a host, port and the other debug parameters but I couldn't find a way to pass this info to the debugger and start it. Can you point me to which API command with its argument I should use ?

ayoub-benali avatar Dec 12 '21 14:12 ayoub-benali

This package is not designed to be used externally like LSP there is no API for other packages to consume right now. All of the adapters live here https://github.com/daveleroy/sublime_debugger/tree/master/modules/adapters

The AdapterConfiguration is how every debug adapter is registered with the system there is no way to do what you want which is basically to give this package an already running debug adapter and a configuration to use with it.

This is the flow I think you should start with https://scalameta.org/metals/docs/editors/vscode/#via-a-launchjson-configuration

AdapterConfiguration does basically two main things

  1. It handles installing an adapter (install(...), installed_status(...), installed_version(...))
  2. Starting a debug adapter (start(...)) when a user tries to run a configuration for that adapter (specified via the type field)

For 1. You can probably check that https://github.com/scalameta/metals-sublime is installed or something.

For 2. You probably need to ask the metals LSP to start the debug adapter because I guess it is part of the LSP client and it gives you a host/port which you would return with SocketTransport. This seems to be the LSP command https://github.com/scalameta/metals-languageclient/blob/87425244724013a92ac5f442fc8e199eb89212d1/src/interfaces/ServerCommands.ts#L64

After that is working code lenses probably just give a configuration to run so something like the following command could be added

window.run_command('debugger', {
	'action': 'start',
	'configuration': {
		...
	}
})

That command would work just like if the user has that configuration in their .sublime-project

daveleroy avatar Dec 12 '21 21:12 daveleroy

The debugger now supports starting via a configuration with both start and open_and_start commands. Still need an adapter to handle the configuration type.

window.run_command('debugger', {
	'action': 'open_and_start'/'start',
	'configuration': {
		...
	}
})```

daveleroy avatar Oct 09 '22 04:10 daveleroy