Restart the JDT LS without restarting the Spring Boot LS
I am trying to develop a java vscode extension which restarts eclipse JDT language server without reloading the vscode window. However, after some investigation, I found that there are some interactions between the Spring Boot LS and the JDT LS.
I am wondering if restarting the JDT LS without reloading the vscode window (actually without restarting the Spring Boot LS) can work correctly?
Appreciate a lot if you could provide some insights. Thank you for the great project.
Interactions between Boot LS and JDT LS are stateless except one message: add/remove classpath listener. This registers a "callback" in JDT LS to execute once projects and/or classpath of a project has changed. These listeners are registered at the initialization phase of Boot LS.
Therefore if JDT LS is restarted without Boot LS the listeners are gone. Consequently, any changes to projects classpath or addition/removal of the projects won't be tracked which would result in Boot LS features not working for newly added projects or working for projects that were removed or not working correctly for projects with changed classpath.
There is, however, a command that we've added in the past sts.vscode-spring-boot.enableClasspathListening that takes a boolean parameter to enable/disable classpath listener. The command was added to handle JDT LS standard, hybrid and syntax modes. I'd try executing this command with false parameter before re-starting JDT LS and then once JDT LS is ready executing the same command with true parameter. Hope this works :-)
@BoykoAlex Thank you for providing comments. I still have some questions I want to get clarified.
I'd try executing this command with false parameter before re-starting JDT LS and then once JDT LS is ready executing the same command with true parameter.Do you mean that theadd/remove classpath listenerwill be re-registered after restarting JDT LS by executing this command withtrueparameter?- Is there any test case where I can verify the correctness of Boot LS after restarting JDT LS?
@XiaoYuhao Sorry for the late reply - was away for a couple of days.
- Yes. Before JDT LS is shut down execute the command with
falseparameter to remove classpath listener (this is sort of optional). However, once the JDT LS is started and is in "ready" state the command needs to be executed withtrueparameter to add the classpath listener. - I'd try testing like follows:
- Create a simple spring boot project called with spring web starter (no spring cloud dependencies)
- Open src/main/resources/application.properties file. Type
loadbalancerand invoke content assist at the end of the work - no proposals - Restart JDT LS
- Add Cloud Bootstrap starter. Then in Maven section of the explorer view expand dependencies and refresh them (i found that adding a starter does not refresh maven dependencies and i had to refresh them manually). You should see
spring-cloud-starterin the dependencies - Invoke content assist again in
application.propertiesright afterloadbalancer- proposals such asspring.cloud.loadbalancer.*should be seen
If this works it means classpath listener is added successfully after restart of JDT LS.