Custom socket provider and java language server in sidecar#9616
Custom socket provider and java language server in sidecar#9616tsmaeder merged 1 commit intoeclipse-che:5730_java_ls_pocfrom
Conversation
|
Can one of the admins verify this patch? |
1 similar comment
|
Can one of the admins verify this patch? |
|
Can one of the admins verify this patch? |
| @@ -0,0 +1,129 @@ | |||
| /* | |||
| * Copyright (c) 2012-2018 Red Hat, Inc. | |||
There was a problem hiding this comment.
@JPinkney do we really need this? Maybe I am missing smth, but reading ws config and grabbing servers of a special type has been already implemented by @dkuleshov https://github.com/eclipse/che/blob/master/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/remote/SocketLsLauncherProvider.java Can't we just reuse it?
| </dependency> | ||
| <dependency> | ||
| <groupId>org.eclipse.che.multiuser</groupId> | ||
| <artifactId>che-multiuser-api-resource</artifactId> |
There was a problem hiding this comment.
why do you need this artifact?
| import org.eclipse.lsp4j.services.LanguageServer; | ||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
|
|
| import org.eclipse.lsp4j.jsonrpc.Launcher; | ||
| import org.eclipse.lsp4j.services.LanguageClient; | ||
| import org.eclipse.lsp4j.services.LanguageServer; | ||
|
|
| public LanguageServer launch(String projectPath, LanguageClient client) | ||
| throws LanguageServerException { | ||
| try { | ||
| Socket socket = new Socket(host, port); |
There was a problem hiding this comment.
are you going to close this Socket on @PreDestroy?
498d098 to
2d5af5e
Compare
|
@JPinkney can you write a short how-to with what one can do to test this PR? I have an image with jdt.ls starting in tcp mode. Also, why does the server need to have attributes - |
| } | ||
| boolean foundCustomLauncher = false; | ||
| if (serverAttributes.get("custom_launcher") != null | ||
| && serverAttributes.get("custom_launcher").equals("true")) { |
There was a problem hiding this comment.
It is better to use here equalsIgnoreCase
| public LanguageServer launch(String projectPath, LanguageClient client) | ||
| throws LanguageServerException { | ||
| try { | ||
| Socket socket = new Socket(host, port); |
There was a problem hiding this comment.
Should we close this socket later?
| } | ||
| } | ||
| ] | ||
| ] No newline at end of file |
There was a problem hiding this comment.
Don't forget to add empty line.
|
To test the instructions are almost the same as the regular sidecar instructions with a few exceptions. |
Can you share an example? Where exactly in a workspace config should I provide it? |
|
Inside the server for the java machine like this |
|
So, server attributes :) Thanks, I will give it a try, |
| try { | ||
| socket.close(); | ||
| } catch (IOException e) { | ||
|
|
There was a problem hiding this comment.
Eating exceptions should only happen if you know exactly what is happening. In this case, you eat it because you say we don't care, but someone else might care, so please log it as a warning
|
|
||
| @Override | ||
| public LanguageServer launch(String projectPath, LanguageClient client) | ||
| throws LanguageServerException { |
There was a problem hiding this comment.
If I understand the code correctly, we have to do a whole lot of work here (managing the socket, etc.), only because we cannot pass in the parameter "JavaLanguageServer.class" into the super call. Why don't we extend the launcher interface like so?
<T extends LanguageServer> T launch(String fileUri, Class<T> serverClass, LanguageClient client) throws LanguageServerException;
Then we could simply wrap the super call and the class would be much simpler.
There was a problem hiding this comment.
I've updated the PR to have this. However, instead of having Class serverClass I pass in the serverClass via the constructor of SocketLanguageServerLauncher. AFAIK launch only happens in LanguageServerRegistryImpl and we aren't able to pass in a serverClass without changing every single launch method for all the language servers and also we wouldn't necessarily know which serverClass to pass into the launch.
| fileUri); | ||
| String rootUri = launchingStrategy.getRootUri(fileUri); | ||
| InitializeParams initializeParams = prepareInitializeParams(rootUri); | ||
| InitializeParams initializeParams = prepareInitializeParams(launcher, rootUri); |
There was a problem hiding this comment.
I would just pass in a boolean "isLocal" here. It reduces the interface exposed.
9d19fa1 to
6e9e9c4
Compare
|
Can one of the admins verify this patch? |
|
@JPinkney this pr looks strange. It has too many changes. Can you rebase and squash as single commit? |
Signed-off-by: jpinkney <josh.pinkney@mail.utoronto.ca>
Signed-off-by: jpinkney <josh.pinkney@mail.utoronto.ca>
Signed-off-by: jpinkney <josh.pinkney@mail.utoronto.ca>
Signed-off-by: jpinkney <josh.pinkney@mail.utoronto.ca>
Signed-off-by: jpinkney <josh.pinkney@mail.utoronto.ca>
Signed-off-by: jpinkney <josh.pinkney@mail.utoronto.ca>
Signed-off-by: jpinkney <josh.pinkney@mail.utoronto.ca>
Signed-off-by: jpinkney <josh.pinkney@mail.utoronto.ca>
Signed-off-by: jpinkney <josh.pinkney@mail.utoronto.ca>
Signed-off-by: jpinkney <josh.pinkney@mail.utoronto.ca>
Signed-off-by: jpinkney <josh.pinkney@mail.utoronto.ca>
Signed-off-by: jpinkney <josh.pinkney@mail.utoronto.ca>
Signed-off-by: jpinkney <josh.pinkney@mail.utoronto.ca>
Signed-off-by: jpinkney <josh.pinkney@mail.utoronto.ca>
Signed-off-by: jpinkney <josh.pinkney@mail.utoronto.ca>
Signed-off-by: jpinkney <josh.pinkney@mail.utoronto.ca>
Signed-off-by: jpinkney <josh.pinkney@mail.utoronto.ca>
Signed-off-by: jpinkney <josh.pinkney@mail.utoronto.ca>
Signed-off-by: jpinkney <josh.pinkney@mail.utoronto.ca>
Signed-off-by: jpinkney josh.pinkney@mail.utoronto.ca
What does this PR do?
Adds the ability to run jdt.ls in a sidecar and allows custom socket launchers.
What issues does this PR fix or reference?
#8874