intellij-lsp icon indicating copy to clipboard operation
intellij-lsp copied to clipboard

Trip report: polymer-editor-server

Open rictic opened this issue 7 years ago • 8 comments

I'm trying out intellij-lsp with my language server. It works well with vscode, atom, and sublime text's LSP plugin, and intellij support is a very common request from our users.

I downloaded IntelliJ IDEA CE 2017.3, installed intellij-lsp, and configured my LSP server as a raw command, with a file extension of html, and the command polymer-editor-service. From my logs I can see that polymer-editor-service is started and initialized, and I get onDidChangeWatchedFiles requests, but that's pretty much it. I don't get notifications when files are opened, closed, changed in memory, or any requests for features like hover or completions.

Reproducing this is pretty straightforward if you have NodeJS v6 or higher installed. npm install -g polymer-editor-service will get you the LSP server, and the simplest way to check if it's working is to put something like this in an HTML file:

<link rel="import" href="./does-not-exist.html">

It should report an error diagnostic on the url.

rictic avatar Dec 06 '17 23:12 rictic

Okay, I made the plugin more resistant to null responses, and the communication is "working". The problem now is the uris. Here are some of the publishDiagnostics requests : 2017-12-07_21h37_10 (Also note that polymer.json doesn't exist, does the server expect a polymer.json to be at the root of the project?) 2017-12-07_21h37_21 The diagnostics for the correct uri are empty, 2017-12-07_21h37_48 but there are some for the wrong uri. The d%3A should obviously be D:

I tested Hover and it also always return a null/empty response, which I guess is due to these uris. If you want to test with the updated sources, you could use sbt intellij-lsp/run, or you could wait a few days for the new release of the plugin.

gtache avatar Dec 07 '17 20:12 gtache

I have the same issue with our (still private) language server. I had the same URI issue (windows drive letter URL encoded - this is the way the vscode-language-server wrapper does). I fixed this. But still, all textDocument requests are never sent. Only thing that works is workspace/symbol I changed the server's capabilites.textDocumentSync to plain number (1=FULL) as I had the impression your client is LSPv2. But no success.

manwithafox avatar Dec 11 '17 13:12 manwithafox

Update: after building the latest repo from today: Working:

  • workspace/symbol
  • textDocument/didChange
  • textDocument/documentHighlight
  • textDocument/publishDiagnostics -> error markers in editor content and right gutter

Broken:

  • textDocument/completion is send to server but client does not consume response

Not sent to server:

  • textDocument/definition
  • textDocument/references

manwithafox avatar Dec 11 '17 14:12 manwithafox

That's strange for the URI, all examples I've seen don't percent-encode the colon after the drive letter.

For the rest it's hard to tell without having the server, but what do you use for the completion ? The label, insertText, a textEdit ? For definition and references, that's a dumb question, but do you have them enabled in your serverCapabilities? I don't see why some requests would be sent but others not otherwise. Did you try Ctrl+Click as well as Shift+Alt+F7 ?

gtache avatar Dec 15 '17 17:12 gtache

Update on my end:

  • looks like some windows file URI handling bugs had snuck back into our code base. fix + more principled testing on windows is in progress at https://github.com/Polymer/polymer-analyzer/pull/792 and https://github.com/Polymer/polymer-editor-service/pull/107

I did the above trip report on a posix box though, where I believe our url handling is correct in the current release.

rictic avatar Dec 15 '17 19:12 rictic

For the completion: (Updated to latest WebStorm, removed a long time ago defined File Type - for cheap highlighting) Popup comes up, but the suggested item list is behaving strange. I only get 1-3 suggestions even my sent response contains a lot more. Before I removed the File Type, likely WebStorm added the defined keywords. This is no longer the case. Now I never see kind:14 (keyword). Sometimes I don't get any suggestion at a place between two blanks, adding a blank and triggering again show 1 suggestion. (The response from server is always the same.) I'm using a textEdit(replace). I set label (of course), sortKind, kind and textEdit. Of the 3 suggestions I see at some place after the only letter 'E' , it shows: E2 and EntityName (already defined entity names) and Integer (an internal type), highlighting the first 'e'. So it looks like some kind of filtering on client side. Strange: it does not show 'Boolean'. Triggering again doesn't show anything. Moving cursor back and forth and it works again. My suspicion is that there is a cache because when I move the cursor forward when the popup is open, the suggested list shrinks to e.g. only E2, moving back it shows the initial 3. Maybe that helps a little to track it down

manwithafox avatar Dec 18 '17 11:12 manwithafox

I'm working on a new release of our editor server, should be pretty soon. Our integration tests are passing on windows now. We're still sending over urls like file///d%3A/path/to/file.html as that's what Microsoft's own vscode-uri encodes, so I think that's correct, but we had a bunch of other issues with our URIs on Windows so I wouldn't rule out that bad URIs were still an issue. Will update this thread once our improved URI handling is released.

Currently with the latest version of intellij-lsp on MacOS (where our URIs should be correct) it looks like something's failing before initialization completes. Stack trace:

java.io.IOException: Stream closed
java.lang.RuntimeException: java.io.IOException: Stream closed
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageConsumer.consume(StreamMessageConsumer.java:68)
	at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.request(RemoteEndpoint.java:129)
	at org.eclipse.lsp4j.jsonrpc.services.EndpointProxy.invoke(EndpointProxy.java:77)
	at com.sun.proxy.$Proxy94.initialize(Unknown Source)
	at com.github.gtache.lsp.client.languageserver.wrapper.LanguageServerWrapperImpl.start(LanguageServerWrapperImpl.scala:276)
	at com.github.gtache.lsp.client.languageserver.wrapper.LanguageServerWrapperImpl.connect(LanguageServerWrapperImpl.scala:163)
	at com.github.gtache.lsp.PluginMain$.$anonfun$editorOpened$4(PluginMain.scala:127)
	at com.github.gtache.lsp.PluginMain$.$anonfun$editorOpened$4$adapted(PluginMain.scala:109)
	at scala.Option.foreach(Option.scala:257)
	at com.github.gtache.lsp.PluginMain$.$anonfun$editorOpened$3(PluginMain.scala:109)
	at com.intellij.openapi.application.impl.ApplicationImpl$1.run(ApplicationImpl.java:315)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.IOException: Stream closed
	at java.lang.ProcessBuilder$NullOutputStream.write(ProcessBuilder.java:433)
	at java.io.OutputStream.write(OutputStream.java:116)
	at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82)
	at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:140)
	at org.eclipse.lsp4j.jsonrpc.json.StreamMessageConsumer.consume(StreamMessageConsumer.java:65)
	... 15 more

rictic avatar Dec 20 '17 20:12 rictic

polymer-editor-service v2.1.0 is out now, and should handle windows URIs correctly now.

rictic avatar Dec 22 '17 02:12 rictic