Skip to content

Custom socket provider and java language server in sidecar#9616

Merged
tsmaeder merged 1 commit intoeclipse-che:5730_java_ls_pocfrom
JPinkney:jdt.ls_sidecar
Jul 6, 2018
Merged

Custom socket provider and java language server in sidecar#9616
tsmaeder merged 1 commit intoeclipse-che:5730_java_ls_pocfrom
JPinkney:jdt.ls_sidecar

Conversation

@JPinkney
Copy link
Copy Markdown
Contributor

@JPinkney JPinkney commented May 4, 2018

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

@codenvy-ci
Copy link
Copy Markdown

Can one of the admins verify this patch?

1 similar comment
@codenvy-ci
Copy link
Copy Markdown

Can one of the admins verify this patch?

@benoitf benoitf added status/code-review This issue has a pull request posted for it and is awaiting code review completion by the community. target/branch Indicates that a PR will be merged into a branch other than master. kind/bug Outline of a bug - must adhere to the bug report template. labels May 4, 2018
@codenvy-ci
Copy link
Copy Markdown

Can one of the admins verify this patch?

@tolusha tolusha force-pushed the 5730_java_ls_poc branch from d1c3957 to 8fbf0e6 Compare May 4, 2018 14:28
@JPinkney JPinkney requested a review from vparfonov as a code owner May 4, 2018 15:29
@@ -0,0 +1,129 @@
/*
* Copyright (c) 2012-2018 Red Hat, Inc.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do you need this artifact?

import org.eclipse.lsp4j.services.LanguageServer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

javadoc

import org.eclipse.lsp4j.jsonrpc.Launcher;
import org.eclipse.lsp4j.services.LanguageClient;
import org.eclipse.lsp4j.services.LanguageServer;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

javadoc

public LanguageServer launch(String projectPath, LanguageClient client)
throws LanguageServerException {
try {
Socket socket = new Socket(host, port);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are you going to close this Socket on @PreDestroy?

@JPinkney JPinkney force-pushed the jdt.ls_sidecar branch 2 times, most recently from 498d098 to 2d5af5e Compare May 7, 2018 17:22
@ghost
Copy link
Copy Markdown

ghost commented May 8, 2018

@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 - serverAttributes.get("custom_launcher").equals("true"))? Right now, it is enought to have "type": "lsp" in server attributes in order for this server to be counted as a remote language server.

}
boolean foundCustomLauncher = false;
if (serverAttributes.get("custom_launcher") != null
&& serverAttributes.get("custom_launcher").equals("true")) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is better to use here equalsIgnoreCase

public LanguageServer launch(String projectPath, LanguageClient client)
throws LanguageServerException {
try {
Socket socket = new Socket(host, port);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we close this socket later?

}
}
]
] No newline at end of file
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't forget to add empty line.

@JPinkney
Copy link
Copy Markdown
Contributor Author

JPinkney commented May 8, 2018

To test the instructions are almost the same as the regular sidecar instructions with a few exceptions.

1. Change the custom recipe to include che-jdt-ls/java-ls as the image (or your own image)
2. Inside the servers object in the java machine set the id in the workspace config as "org.eclipse.che.plugin.java.languageserver",  port as 5555, and languageID as java
3. Mount /home/user/jdtls as a volume for the java-machine-ls

@ghost
Copy link
Copy Markdown

ghost commented May 8, 2018

  1. Set the id in the workspace config as "org.eclipse.che.plugin.java.languageserver", port as 5555, and languageID as java

Can you share an example? Where exactly in a workspace config should I provide it?

@JPinkney
Copy link
Copy Markdown
Contributor Author

JPinkney commented May 8, 2018

Inside the server for the java machine like this

"servers": {
  "ls": {
    "attributes": {
      "internal": "true",
      "type": "ls",
      "config": "{\"id\":\"org.eclipse.che.plugin.java.languageserver\", \"languageIds\":[java]}"
    },
    "protocol": "tcp",
    "port": "5555"
  }
}

@ghost
Copy link
Copy Markdown

ghost commented May 8, 2018

So, server attributes :)

Thanks, I will give it a try,

try {
socket.close();
} catch (IOException e) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would just pass in a boolean "isLocal" here. It reduces the interface exposed.

@tolusha tolusha force-pushed the 5730_java_ls_poc branch from 245c161 to 62ecb10 Compare May 12, 2018 19:47
@tsmaeder tsmaeder mentioned this pull request Jun 18, 2018
26 tasks
@codenvy-ci
Copy link
Copy Markdown

Can one of the admins verify this patch?

@skabashnyuk
Copy link
Copy Markdown
Contributor

@JPinkney this pr looks strange. It has too many changes. Can you rebase and squash as single commit?

@tsmaeder tsmaeder mentioned this pull request Jul 5, 2018
17 tasks
Signed-off-by: jpinkney <josh.pinkney@mail.utoronto.ca>
@tsmaeder tsmaeder merged commit f31ff0e into eclipse-che:5730_java_ls_poc Jul 6, 2018
@benoitf benoitf removed the status/code-review This issue has a pull request posted for it and is awaiting code review completion by the community. label Jul 6, 2018
tsmaeder pushed a commit that referenced this pull request Jul 13, 2018
Signed-off-by: jpinkney <josh.pinkney@mail.utoronto.ca>
tsmaeder pushed a commit that referenced this pull request Jul 27, 2018
Signed-off-by: jpinkney <josh.pinkney@mail.utoronto.ca>
tolusha pushed a commit that referenced this pull request Aug 7, 2018
Signed-off-by: jpinkney <josh.pinkney@mail.utoronto.ca>
tsmaeder pushed a commit that referenced this pull request Aug 22, 2018
Signed-off-by: jpinkney <josh.pinkney@mail.utoronto.ca>
tsmaeder pushed a commit that referenced this pull request Aug 29, 2018
Signed-off-by: jpinkney <josh.pinkney@mail.utoronto.ca>
tolusha pushed a commit that referenced this pull request Sep 5, 2018
Signed-off-by: jpinkney <josh.pinkney@mail.utoronto.ca>
tsmaeder pushed a commit that referenced this pull request Sep 13, 2018
Signed-off-by: jpinkney <josh.pinkney@mail.utoronto.ca>
tsmaeder pushed a commit that referenced this pull request Sep 20, 2018
Signed-off-by: jpinkney <josh.pinkney@mail.utoronto.ca>
tsmaeder pushed a commit that referenced this pull request Sep 26, 2018
Signed-off-by: jpinkney <josh.pinkney@mail.utoronto.ca>
tsmaeder pushed a commit that referenced this pull request Oct 1, 2018
Signed-off-by: jpinkney <josh.pinkney@mail.utoronto.ca>
tsmaeder pushed a commit that referenced this pull request Oct 5, 2018
Signed-off-by: jpinkney <josh.pinkney@mail.utoronto.ca>
tsmaeder pushed a commit that referenced this pull request Oct 12, 2018
Signed-off-by: jpinkney <josh.pinkney@mail.utoronto.ca>
tsmaeder pushed a commit that referenced this pull request Oct 16, 2018
Signed-off-by: jpinkney <josh.pinkney@mail.utoronto.ca>
tsmaeder pushed a commit that referenced this pull request Oct 17, 2018
Signed-off-by: jpinkney <josh.pinkney@mail.utoronto.ca>
tsmaeder pushed a commit that referenced this pull request Oct 17, 2018
Signed-off-by: jpinkney <josh.pinkney@mail.utoronto.ca>
tsmaeder pushed a commit that referenced this pull request Oct 17, 2018
Signed-off-by: jpinkney <josh.pinkney@mail.utoronto.ca>
tsmaeder pushed a commit that referenced this pull request Oct 17, 2018
Signed-off-by: jpinkney <josh.pinkney@mail.utoronto.ca>
tsmaeder pushed a commit that referenced this pull request Oct 17, 2018
Signed-off-by: jpinkney <josh.pinkney@mail.utoronto.ca>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Outline of a bug - must adhere to the bug report template. target/branch Indicates that a PR will be merged into a branch other than master.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants