TypeFox / monaco-languageclient

Repo hosts npm packages for monaco-languageclient, vscode-ws-jsonrpc, monaco-editor-wrapper, @typefox/monaco-editor-react and monaco-languageclient-examples
https://www.npmjs.com/package/monaco-languageclient
MIT License
1.06k stars 178 forks source link

Integrating eclipse.jdt.ls with monaco-languageclient #384

Closed pasiasty closed 2 years ago

pasiasty commented 2 years ago

Hi,

I'm trying to integrate Java LSP with monaco-languageclient and I'm struggling to do that. It seems that my project (https://cocoder.org) is talking to the LSP correctly, but the communication hangs up at the point when LSP announces that it's ready. Regardless of further interactions within the editor I don't see any requests going out - I was able to integrate so far three other LSPs and they work without any issues. Here's the log that I gathered:

Req: {"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":null,"clientInfo":{"name":"Monaco"},"locale":"en-US","rootPath":null,"rootUri":null,"capabilities":{"workspace":{"applyEdit":true,"workspaceEdit":{"documentChanges":true,"resourceOperations":["create","rename","delete"],"failureHandling":"textOnlyTransactional","normalizesLineEndings":true,"changeAnnotationSupport":{"groupsOnLabel":true}},"codeLens":{"refreshSupport":true},"executeCommand":{"dynamicRegistration":true},"workspaceFolders":true,"semanticTokens":{"refreshSupport":true},"inlayHint":{"refreshSupport":true},"diagnostics":{"refreshSupport":true}},"textDocument":{"publishDiagnostics":{"relatedInformation":true,"versionSupport":false,"tagSupport":{"valueSet":[1,2]},"codeDescriptionSupport":true,"dataSupport":true},"synchronization":{"dynamicRegistration":true},"completion":{"dynamicRegistration":true,"contextSupport":true,"completionItem":{"snippetSupport":true,"commitCharactersSupport":true,"documentationFormat":["markdown","plaintext"],"deprecatedSupport":true,"preselectSupport":true,"tagSupport":{"valueSet":[1]},"insertReplaceSupport":true,"resolveSupport":{"properties":["documentation","detail","additionalTextEdits"]},"insertTextModeSupport":{"valueSet":[1,2]},"labelDetailsSupport":true},"insertTextMode":2,"completionItemKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]},"completionList":{"itemDefaults":["commitCharacters","editRange","insertTextFormat","insertTextMode"]}},"hover":{"dynamicRegistration":true,"contentFormat":["markdown","plaintext"]},"signatureHelp":{"dynamicRegistration":true,"signatureInformation":{"documentationFormat":["markdown","plaintext"],"parameterInformation":{"labelOffsetSupport":true},"activeParameterSupport":true},"contextSupport":true},"definition":{"dynamicRegistration":true,"linkSupport":true},"references":{"dynamicRegistration":true},"documentHighlight":{"dynamicRegistration":true},"documentSymbol":{"dynamicRegistration":true,"symbolKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]},"hierarchicalDocumentSymbolSupport":true,"tagSupport":{"valueSet":[1]},"labelSupport":true},"codeAction":{"dynamicRegistration":true,"isPreferredSupport":true,"disabledSupport":true,"dataSupport":true,"resolveSupport":{"properties":["edit"]},"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["","quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.organizeImports"]}},"honorsChangeAnnotations":false},"codeLens":{"dynamicRegistration":true},"formatting":{"dynamicRegistration":true},"rangeFormatting":{"dynamicRegistration":true},"onTypeFormatting":{"dynamicRegistration":true},"rename":{"dynamicRegistration":true,"prepareSupport":true,"prepareSupportDefaultBehavior":1,"honorsChangeAnnotations":true},"documentLink":{"dynamicRegistration":true,"tooltipSupport":true},"typeDefinition":{"dynamicRegistration":true,"linkSupport":true},"implementation":{"dynamicRegistration":true,"linkSupport":true},"colorProvider":{"dynamicRegistration":true},"foldingRange":{"dynamicRegistration":true,"rangeLimit":5000,"lineFoldingOnly":true,"foldingRangeKind":{"valueSet":["comment","imports","region"]},"foldingRange":{"collapsedText":false}},"declaration":{"dynamicRegistration":true,"linkSupport":true},"selectionRange":{"dynamicRegistration":true},"semanticTokens":{"dynamicRegistration":true,"tokenTypes":["namespace","type","class","enum","interface","struct","typeParameter","parameter","variable","property","enumMember","event","function","method","macro","keyword","modifier","comment","string","number","regexp","operator","decorator"],"tokenModifiers":["declaration","definition","readonly","static","deprecated","abstract","async","modification","documentation","defaultLibrary"],"formats":["relative"],"requests":{"range":true,"full":{"delta":true}},"multilineTokenSupport":false,"overlappingTokenSupport":false,"serverCancelSupport":true,"augmentsSyntaxTokens":true},"linkedEditingRange":{"dynamicRegistration":true},"inlayHint":{"dynamicRegistration":true,"resolveSupport":{"properties":["tooltip","textEdits","label.tooltip","label.location","label.command"]}},"diagnostic":{"dynamicRegistration":true,"relatedDocumentSupport":false}},"window":{"showMessage":{"messageActionItem":{"additionalPropertiesSupport":true}},"showDocument":{"support":true}},"general":{"staleRequestSupport":{"cancel":true,"retryOnContentModified":["textDocument/semanticTokens/full","textDocument/semanticTokens/range","textDocument/semanticTokens/full/delta"]},"regularExpressions":{"engine":"ECMAScript","version":"ES2020"},"markdown":{"parser":"marked","version":"1.1.0"},"positionEncodings":["utf-16"]}},"trace":"off","workspaceFolders":null}}

OpenJDK 64-Bit Server VM warning: Options -Xverify:none and -noverify were deprecated in JDK 13 and will likely be removed in a future release.
WARNING: Using incubator modules: jdk.incubator.vector, jdk.incubator.foreign
Resp: {"jsonrpc":"2.0","method":"language/status","params":{"type":"Starting","message":"Init..."}}

Resp: {"jsonrpc":"2.0","method":"language/status","params":{"type":"Starting","message":"0% Starting Java Language Server"}}

Resp: {"jsonrpc":"2.0","id":0,"result":{"capabilities":{"textDocumentSync":{"openClose":true,"change":2,"save":{"includeText":true}},"workspaceSymbolProvider":true,"workspace":{"workspaceFolders":{"supported":true,"changeNotifications":true}},"callHierarchyProvider":true,"semanticTokensProvider":{"legend":{"tokenTypes":["namespace","class","interface","enum","enumMember","type","typeParameter","method","property","variable","parameter","modifier","keyword","annotation","annotationMember","record","recordComponent"],"tokenModifiers":["abstract","static","readonly","deprecated","declaration","documentation","public","private","protected","native","generic","typeArgument","importDeclaration","constructor"]},"range":false,"full":{"delta":false},"documentSelector":[{"language":"java","scheme":"file"},{"language":"java","scheme":"jdt"}]}}}}

Req: {"jsonrpc":"2.0","method":"initialized","params":{}}

Resp: {"jsonrpc":"2.0","method":"language/status","params":{"type":"Starting","message":"30% Starting Java Language Server"}}

Resp: {"jsonrpc":"2.0","method":"language/status","params":{"type":"ProjectStatus","message":"OK"}}

Resp: {"jsonrpc":"2.0","method":"language/status","params":{"type":"Starting","message":"100% Starting Java Language Server"}}

Resp: {"jsonrpc":"2.0","method":"language/status","params":{"type":"Started","message":"Ready"}}

Resp: {"jsonrpc":"2.0","method":"language/status","params":{"type":"Starting","message":"100% Starting Java Language Server"}}

Resp: {"jsonrpc":"2.0","id":"1","method":"client/registerCapability","params":{"registrations":[{"id":"dfa7a4c3-6b9c-4965-8d8c-ba9976b6d234","method":"textDocument/completion","registerOptions":{"resolveProvider":true,"triggerCharacters":[".","@","#","*"," "]}}]}}

Req: {"jsonrpc":"2.0","id":"1","result":null}

Resp: {"jsonrpc":"2.0","id":"2","method":"client/registerCapability","params":{"registrations":[{"id":"0fe6e60f-76bd-4e77-8495-200ecc9ffa47","method":"textDocument/documentSymbol"}]}}

Req: {"jsonrpc":"2.0","id":"2","result":null}

Resp: {"jsonrpc":"2.0","id":"3","method":"client/registerCapability","params":{"registrations":[{"id":"29a62fc0-017b-4a03-baa9-a6ff63e19fcb","method":"textDocument/codeAction","registerOptions":{"codeActionKinds":["quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.organizeImports"],"resolveProvider":true}}]}}

Req: {"jsonrpc":"2.0","id":"3","result":null}

Resp: {"jsonrpc":"2.0","id":"4","method":"client/registerCapability","params":{"registrations":[{"id":"212773df-3902-4821-9cbd-c844ebc45a39","method":"textDocument/definition"}]}}

Req: {"jsonrpc":"2.0","id":"4","result":null}

Resp: {"jsonrpc":"2.0","id":"5","method":"client/registerCapability","params":{"registrations":[{"id":"09ff3bf0-90f7-4d6b-8f76-61e30f2da550","method":"textDocument/typeDefinition"}]}}

Req: {"jsonrpc":"2.0","id":"5","result":null}

Resp: {"jsonrpc":"2.0","id":"6","method":"client/registerCapability","params":{"registrations":[{"id":"15a55736-4a48-4baf-ae9a-66fb6a4fde58","method":"textDocument/hover"}]}}

Req: {"jsonrpc":"2.0","id":"6","result":null}

Resp: {"jsonrpc":"2.0","id":"7","method":"client/registerCapability","params":{"registrations":[{"id":"8defe46b-5564-4628-a2ce-514ff3cc6ff1","method":"textDocument/references"}]}}

Req: {"jsonrpc":"2.0","id":"7","result":null}

Resp: {"jsonrpc":"2.0","id":"8","method":"client/registerCapability","params":{"registrations":[{"id":"0c3cc49f-e6fd-49cf-9629-66e155e4720b","method":"textDocument/documentHighlight"}]}}

Req: {"jsonrpc":"2.0","id":"8","result":null}

Resp: {"jsonrpc":"2.0","id":"9","method":"client/registerCapability","params":{"registrations":[{"id":"f626aa98-5a66-413a-ac39-3f25e91a11d0","method":"textDocument/foldingRange"}]}}

Req: {"jsonrpc":"2.0","id":"9","result":null}

Resp: {"jsonrpc":"2.0","id":"10","method":"client/registerCapability","params":{"registrations":[{"id":"0d9715b9-e25b-4385-91d8-eda9c72779dc","method":"workspace/didChangeWorkspaceFolders"}]}}

Req: {"jsonrpc":"2.0","id":"10","result":null}

Resp: {"jsonrpc":"2.0","id":"11","method":"client/registerCapability","params":{"registrations":[{"id":"5480b8e3-19dd-4e78-83aa-0bfc87f9b469","method":"textDocument/implementation"}]}}

Req: {"jsonrpc":"2.0","id":"11","result":null}

Resp: {"jsonrpc":"2.0","id":"12","method":"client/registerCapability","params":{"registrations":[{"id":"0108ae6a-18bb-487b-9db1-2c3e11009a96","method":"textDocument/selectionRange"}]}}

Req: {"jsonrpc":"2.0","id":"12","result":null}

Resp: {"jsonrpc":"2.0","id":"13","method":"client/registerCapability","params":{"registrations":[{"id":"cdc89b33-a11f-4258-a924-2338915dc2de","method":"textDocument/formatting"}]}}

Req: {"jsonrpc":"2.0","id":"13","result":null}

Resp: {"jsonrpc":"2.0","id":"14","method":"client/registerCapability","params":{"registrations":[{"id":"5d8c2394-4bf1-44ec-9360-fb8bdb3645fc","method":"textDocument/rangeFormatting"}]}}

Req: {"jsonrpc":"2.0","id":"14","result":null}

Resp: {"jsonrpc":"2.0","id":"15","method":"client/registerCapability","params":{"registrations":[{"id":"7a04b020-48fe-4b3b-9757-b217f32a29ec","method":"textDocument/codeLens","registerOptions":{"resolveProvider":true}}]}}

Req: {"jsonrpc":"2.0","id":"15","result":null}

Resp: {"jsonrpc":"2.0","id":"16","method":"client/registerCapability","params":{"registrations":[{"id":"02f844d4-83ea-4aa4-a698-59b3f2ce33b2","method":"textDocument/rename","registerOptions":{"prepareProvider":true}}]}}

Req: {"jsonrpc":"2.0","id":"16","result":null}

Resp: {"jsonrpc":"2.0","id":"17","method":"client/registerCapability","params":{"registrations":[{"id":"00e14909-7a24-4d40-abcf-04fe22a26df5","method":"workspace/executeCommand","registerOptions":{"commands":["java.edit.organizeImports","java.project.refreshDiagnostics","java.project.import","java.navigate.openTypeHierarchy","java.project.removeFromSourcePath","java.project.listSourcePaths","java.project.resolveStackTraceLocation","java.project.getAll","java.project.isTestFile","java.project.getClasspaths","java.navigate.resolveTypeHierarchy","java.edit.stringFormatting","java.project.getSettings","java.project.updateSourceAttachment","java.project.upgradeGradle","java.project.resolveSourceAttachment","java.project.addToSourcePath"]}}]}}

Req: {"jsonrpc":"2.0","id":"17","result":null}

Resp: {"jsonrpc":"2.0","method":"language/status","params":{"type":"ServiceReady","message":"ServiceReady"}}

I'm running the LSP as suggested in the readme of the project:

./org.eclipse.jdt.ls.product/target/repository/bin/jdtls \
    -configuration ~/.cache/jdtls \
    -data /path/to/data
pasiasty commented 2 years ago

Hi,

Is there any update on this problem?

kaisalmen commented 2 years ago

Hi @pasiasty did you do some debugging on the MonacoLanguageClient side to find out what messages come back from the LS? Are you aware of this issue? https://github.com/TypeFox/monaco-languageclient/issues/299 I currently have no good advice apart that. If you could link your code/post instructions for reproduction we might be able to help you further. Thanks.

pasiasty commented 2 years ago

Thanks for the hint! Indeed, it turned out that I had to create the file at first and then the analysis worked without any problems (I assumed that LSP would create the file on my behalf).

NightMingGit commented 1 year ago

did you solve it