Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run with remote Java LS #250

Merged
merged 5 commits into from
Jul 4, 2017

Conversation

aeschli
Copy link
Collaborator

@aeschli aeschli commented Jun 28, 2017

Lets the vscode-java extension run with a Java LS server that is started separately, e.g. out of Eclipse. That speeds up development as the LS server doesn't need to be built every time for trying out changes. When the server is run out of Eclipse, hot code replace lets you make fixes without restarting the server

  • run the new launch configuation 'Launch Extension - Remote Server'
  • The extension will open a socket at given port (3333 is used by default) and wait for the JavaLS to connect
  • In Eclipse run the JavaLS as an Eclipse application
    • in the main tab set the product to org.eclipse.jdt.ls.core.product
    • in the environment tab, set CLIENT_PORT to 3333
    • in the plug-ins tab make sure that 'org.eclipse.jdt.ui' is not part of the plugins. Otherwise the the java.ui will be loaded through some extension points and will replace the primary buffer provider
  • In the debug cosole of VSCode you will see if the connection was sucessful

@fbricon
Copy link
Collaborator

fbricon commented Jun 28, 2017

Can you add these new instructions to https://github.com/redhat-developer/vscode-java/blob/master/CONTRIBUTING.md please?

@fbricon
Copy link
Collaborator

fbricon commented Jun 28, 2017

Seems I got a chicken/egg kind of problem. When I launch the vscode extension - remote server, it fails with

Error: ENOENT: no such file or directory, unlink '/tmp/javals.sock'
    at Object.fs.unlinkSync (fs.js:1007:18)
    at attachServer (/Users/fbricon/Dev/projects/vscode-java/out/src/javaServerStarter.js:19:12)
    at LanguageClient.createConnection (/Users/fbricon/Dev/projects/vscode-java/node_modules/vscode-languageclient/lib/main.js:1002:20)

Then when launching the server, I get:

org.newsclub.net.unix.AFUNIXSocketException: No such file or directory (socket: /private/tmp/javals.sock)
	at org.newsclub.net.unix.NativeUnixSocket.connect(Native Method)
	at org.newsclub.net.unix.AFUNIXSocketImpl.connect(AFUNIXSocketImpl.java:136)
	at org.newsclub.net.unix.AFUNIXSocket.connect(AFUNIXSocket.java:107)
	at org.newsclub.net.unix.AFUNIXSocket.connect(AFUNIXSocket.java:98)
	at org.eclipse.jdt.ls.core.internal.ConnectionStreamFactory$DuplexPipeStreamProvider.initializeConnection(ConnectionStreamFactory.java:98)
	at org.eclipse.jdt.ls.core.internal.ConnectionStreamFactory$DuplexPipeStreamProvider.getInputStream(ConnectionStreamFactory.java:107)
	at org.eclipse.jdt.ls.core.internal.ConnectionStreamFactory.getInputStream(ConnectionStreamFactory.java:205)
	at org.eclipse.jdt.ls.core.internal.JavaLanguageServerPlugin.startConnection(JavaLanguageServerPlugin.java:213)

@aeschli
Copy link
Collaborator Author

aeschli commented Jun 28, 2017

@fbricon Please try again, there was a bug with deleting the socket file

CONTRIBUTING.md Outdated

While developping the language server and the extension, you don't need to deploy the server every time to try out a change. Instead you can run the language server out of its Eclipse workspace:

- Open VSCOde on the vscode-java folder
Copy link
Collaborator

Choose a reason for hiding this comment

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

VS Code

CONTRIBUTING.md Outdated
While developping the language server and the extension, you don't need to deploy the server every time to try out a change. Instead you can run the language server out of its Eclipse workspace:

- Open VSCOde on the vscode-java folder
- In the debug viewlet, tun the launch 'Launch Extension - Remote Server'
Copy link
Collaborator

Choose a reason for hiding this comment

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

s/tun/run

CONTRIBUTING.md Outdated
- in the main tab set the product to `org.eclipse.jdt.ls.core.product`
- in the environment, define a variable `INOUT_PIPE_NAME` with value `javals`
- in the plug-ins tab make sure that 'org.eclipse.jdt.ui' is not part of the plugins. Otherwise the the java.ui will be loaded throigh some extension points and will replace the primary buffer provider
- In the debug cosole of VSCode you will see if the connection was sucessful
Copy link
Collaborator

Choose a reason for hiding this comment

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

console of VS Code
successful

@fbricon
Copy link
Collaborator

fbricon commented Jun 28, 2017

Works fine on macOS, would like confirmation everything is ok on Windows/Linux before merging.

@fbricon
Copy link
Collaborator

fbricon commented Jun 28, 2017

Since STDIN_PIPE_NAME and STDOUT_PIPE_NAME are being removed server side, matching changes should be done in this PR

@fbricon fbricon closed this Jun 28, 2017
@fbricon fbricon reopened this Jun 28, 2017
@aeschli
Copy link
Collaborator Author

aeschli commented Jun 29, 2017

I tested on Windows had has some strange hangs. I added socket support as well, and this seems to run reliably on Windows and Linux. If you can have a try on the Mac that would be great.
Check out the new instructions in CONTRIBUTING.md, as well as the corresponding changes in eclipse-jdtls/eclipse.jdt.ls#282.

I reverted the changes to the pipes as I realized that they are used for the regular launch. For connecting a remote server, only socket is supported for now. It's now a single socket and I hope I didn't break any clients (otherwise I can bringe the dual socket back as well).

let serverOptions = runServer.bind(null, workspacePath, getJavaConfiguration());
let serverOptions;
let port = process.env['SERVER_PORT'];
if (!port) {
Copy link
Collaborator

@fbricon fbricon Jun 29, 2017

Choose a reason for hiding this comment

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

if it works well, maybe we could switch default mode to using sockets too. That'd allow running on linux 32b (See #201).
So logic would be: if no defined port, then find an open port and initiate socket.

@fbricon fbricon added this to the End July 2017 milestone Jul 4, 2017
@fbricon fbricon merged commit 694a29b into redhat-developer:master Jul 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants