eclipselabs/eclipse-language-service

Allow using Debug Configurations for Language Servers

Closed this issue · 3 comments

It should be really fantastic to give the capability to debug a node language server like JSON, CSS which are written in TypeScript:

  • you import JSON, CSS language server written in TypeScript in your workspace.
  • you set the path of JSON, CSS language server in your launch to your workspace project.
  • you set a breakpoint for instance in the connection.onCompletion(textDocumentPosition => {

After that, you open a JSON file and you open completion. The JSON server is started in debug mode and it stops process to your breakpoint.

I have implemented this idea inside tern.java: you can debug your tern plugin written in JavaScript with any debugger (JSDT, Webclipse, Nodeclipse) and it provides a very cool mean to develop tern plugins.

In this issue we wish to debug TypeScript. typescript.java (based on JSDT) provides the capability to set breakpoints. Today you can debug TypeScript with Webclipse debugger (see angelozerr/typescript.java#2), but once https://bugs.eclipse.org/bugs/show_bug.cgi?id=487465 will be fixed, we could debug TypeScript with JSDT.

To support any debugger, we just need to delegate VSCode-JSON launch to a custom launch (not Program launch) to start nodejs in debug mode and initialize some info.

Once TypeScript language server will be implemented in this project we could even use the Generic Editor (with TypeScript) to support debugging.

I think "Debugging support for node langauge server inside Eclipse" could promote the use of this project to develop language server.

That's one advantage of using Launch Configurations: it can be easy to provide debug.

The Language Server preference page allows to associate content-type with Run Configuration. If a Run Configuration can support debug, then we could imagine showing a "debug" checkbox in the table for this association and then start the debug config rather than the run one.

However, this project has no mean to specifically integrate specific debug for Node or TypeScript. If it can use any Debug Configuration, then it will be up to the Language Server developer to set up the Debug Configuration for their server and to associate it with the content-type they target.

Fixed with 0c188ed . One can now associate a content type with a language server LaunchConfiguration in any of the provided modes (usually including debug). So one can simultaneously Use and Debug a language server in the same workspace, with the goal of providing a very fast feedback loop to developers of a language server.
cc @gorkem @bruno-medeiros

Note that with some synchronous operations happening in UI Thread, there are risks that a breakpoint during one of those operations put Eclipse IDE in a deadlock (UI waiting for debugged process to continue, debugged process on a breakpoint needing UI to be continued). See iss #14 about avoiding such synchronous LS operations in UI Thread.