eclipse.jdt.ls
eclipse.jdt.ls copied to clipboard
jdt.ls cli is actually running but not working.no function suggestion,no effects.
How do I determined its working but no effect.
after setting up the lsp client properly,refer.https://github.com/Alexey-T/CudaText/issues/4335
in the client side it has this log: Python 3.6.8 LSP: starting server - Java; root: None Startup: 1070ms, plugins: 580ms (lsp 563ms, tabs_list 15ms)
So i tried to type in it>
public class OK{ public static void main(String[] args) { java.util.List<String> avar=new java.util.ArrayList<String>(2);
}
}
Then,I typed these to check if there is suggestion. avar. avar.a
To my surprise
absolutely no suggestion poped up. As most Java programmer should know,In java.util.ArrayList has a popular and useful function called add
If that doesnt gets suggested,then there is something wrong. So is there anyway for me to fix my lsp server?
When you start up the language server, there should be some argument passed to it like -data /path/to/workspace
, which represents the data location for the language server. If you look at /path/to/workspace/.metadata/.log
you should see some logging regarding its state. A successful start should have a log file that looks something like this :
log
!SESSION 2022-09-19 14:16:17.295 -----------------------------------------------
eclipse.buildId=unknown
java.version=17.0.4.1
java.vendor=Eclipse Adoptium
BootLoader constants: OS=linux, ARCH=x86_64, WS=gtk, NL=en_CA
Command-line arguments: -data /home/rgrunber/.config/Code/User/workspaceStorage/79325a8e52a1a0928c8f091a32ed0a0d/redhat.java/jdt_ws
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-19 14:16:19.028
!MESSAGE class org.eclipse.jdt.ls.core.internal.JavaLanguageServerPlugin is started
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-19 14:16:19.231
!MESSAGE Main thread is waiting
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-19 14:16:19.273
!MESSAGE >> initialize
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-19 14:16:19.275
!MESSAGE Initializing Java Language Server 1.16.0.202209170805
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-19 14:16:20.681
!MESSAGE Setting /usr/lib/jvm/java-1.8.0-openjdk as 'JavaSE-1.8' environment (id:1663611380112)
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-19 14:16:20.696
!MESSAGE Setting /usr/lib/jvm/java-11-openjdk as 'JavaSE-11' environment (id:1663611380684)
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-19 14:16:20.705
!MESSAGE Setting runtime JavaSE-18-/usr/lib/jvm/java-18-openjdk as default global VM
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-19 14:16:20.712
!MESSAGE Default VM Install changed from 1663611380093-/home/rgrunber/.vscode/extensions/redhat.java-1.11.2022091704-linux-x64/jre/17.0.4.1-linux-x86_64 to 1663611380698-/usr/lib/jvm/java-18-openjdk
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-19 14:16:20.721
!MESSAGE Setting /usr/lib/jvm/java-18-openjdk as 'JavaSE-18' environment (id:1663611380698)
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-19 14:16:20.723
!MESSAGE JVM Runtimes changed, saving new configuration
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-19 14:16:20.859
!MESSAGE Refresh the bundles
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-19 14:16:20.990
!MESSAGE Finished Refreshing bundles
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-19 14:16:20.996
!MESSAGE Static Commands: []
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-19 14:16:20.996
!MESSAGE Non-Static 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.resolveWorkspaceSymbol, java.project.upgradeGradle, java.protobuf.generateSources, java.project.resolveSourceAttachment, java.project.addToSourcePath]
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-19 14:16:20.997
!MESSAGE Static Commands: []
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-19 14:16:20.997
!MESSAGE Non-Static Commands: [vscode.java.checkProjectSettings, vscode.java.isOnClasspath, vscode.java.fetchUsageData, vscode.java.validateLaunchConfig, vscode.java.resolveInlineVariables, vscode.java.resolveClassFilters, vscode.java.resolveMainMethod, vscode.java.resolveClasspath, vscode.java.resolveBuildFiles, vscode.java.resolveMainClass, vscode.java.updateDebugSettings, vscode.java.resolveSourceUri, vscode.java.fetchPlatformSettings, vscode.java.buildWorkspace, vscode.java.startDebugSession, vscode.java.inferLaunchCommandLength, vscode.java.resolveElementAtSelection, vscode.java.resolveJavaExecutable]
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-19 14:16:20.998
!MESSAGE Static Commands: []
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-19 14:16:20.998
!MESSAGE Non-Static Commands: []
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-19 14:16:20.999
!MESSAGE Static Commands: []
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-19 14:16:21.000
!MESSAGE Non-Static Commands: [vscode.java.test.findJavaProjects, vscode.java.test.findTestPackagesAndTypes, vscode.java.test.findTestTypesAndMethods, vscode.java.test.resolvePath, vscode.java.test.findTestLocation, vscode.java.test.get.testpath, vscode.java.test.findDirectTestChildrenForClass, vscode.java.test.navigateToTestOrTarget, vscode.java.test.junit.argument, vscode.java.test.generateTests]
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-19 14:16:21.009
!MESSAGE Wait for AutoBuildOffJob start
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-19 14:16:21.011
!MESSAGE Wait for AutoBuildOffJob end 1ms
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-19 14:16:21.011
!MESSAGE Starting org.eclipse.m2e.core
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-19 14:16:21.011
!MESSAGE Started org.eclipse.m2e.core 0ms
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-19 14:16:21.012
!MESSAGE ProjectRegistryRefreshJob finished 1ms
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-19 14:16:21.012
!MESSAGE Starting org.eclipse.buildship.core
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-19 14:16:21.037
!MESSAGE Started org.eclipse.buildship.core 25ms
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-19 14:16:21.059
!MESSAGE LoadingGradleVersionJob finished 21ms
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-19 14:16:21.077
!MESSAGE Creating the Java project jdt.ls-java-project
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-19 14:16:21.085
!MESSAGE >> initialized
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-19 14:16:21.159
!MESSAGE Finished creating the Java project jdt.ls-java-project
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-19 14:16:22.416
!MESSAGE Try to create an invisible project for the workspace /tmp/foo
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-19 14:16:22.419
!MESSAGE Creating the Java project foo_caeb84bf
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-19 14:16:22.464
!MESSAGE Finished creating the Java project foo_caeb84bf
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-19 14:16:22.471
!MESSAGE Successfully created a workspace invisible project foo_caeb84bf
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-19 14:16:22.514
!MESSAGE Workspace initialized in 1451ms
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-19 14:16:22.610
!MESSAGE >> initialization job finished
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-19 14:16:22.611
!MESSAGE >> workspace/didChangeConfiguration
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-19 14:16:22.621
!MESSAGE >> New configuration: {...}
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-19 14:16:22.624
!MESSAGE >> document/didOpen
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-19 14:16:22.687
!MESSAGE >> Updating classpath for project foo_caeb84bf
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-19 14:16:23.260
!MESSAGE >> textDocument/inlayHint
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-19 14:16:23.263
!MESSAGE Reconciled 1. Took 0 ms
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-19 14:16:23.632
!MESSAGE begin problem for /Test.java
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-19 14:16:23.633
!MESSAGE 0 problems reported for /Test.java
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-19 14:16:23.638
!MESSAGE Validated 1. Took 183 ms
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-19 14:16:23.660
!MESSAGE >> build jobs finished
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-19 14:16:23.663
!MESSAGE >> registerWatchers'
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-19 14:16:23.666
!MESSAGE >> registerFeature 'workspace/didChangeWatchedFiles'
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-19 14:16:23.669
!MESSAGE >> watchers registered
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-19 14:16:23.740
!MESSAGE >> document/codeAction
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-19 14:16:23.783
!MESSAGE >> workspace/executeCommand java.project.getAll
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-19 14:16:23.796
!MESSAGE >> workspace/executeCommand java.project.getAll
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-19 14:16:23.798
!MESSAGE >> workspace/executeCommand java.project.getAll
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-19 14:16:23.799
!MESSAGE >> workspace/executeCommand vscode.java.test.get.testpath
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-19 14:16:23.801
!MESSAGE >> workspace/executeCommand vscode.java.test.get.testpath
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-19 14:16:23.895
!MESSAGE >> document/codeAction
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-19 14:16:23.918
!MESSAGE >> workspace/executeCommand java.project.getSettings
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-19 14:16:23.926
!MESSAGE >> workspace/executeCommand java.project.getClasspaths
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-19 14:16:23.929
!MESSAGE >> workspace/executeCommand vscode.java.test.findTestTypesAndMethods
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-19 14:16:24.041
!MESSAGE >> workspace/executeCommand vscode.java.resolveMainMethod
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-19 14:16:24.153
!MESSAGE >> document/codeLens
!ENTRY java-debug 1 0 2022-09-19 14:16:24.176
!MESSAGE Starting com.microsoft.java.debug.plugin
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-19 14:16:24.233
!MESSAGE >> workspace/executeCommand vscode.java.test.resolvePath
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-19 14:16:24.606
!MESSAGE >> textDocument/inlayHint
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-19 14:16:24.723
!MESSAGE >> workspace/executeCommand microprofile/java/fileInfo
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-19 14:16:24.724
!MESSAGE >> document/codeAction
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-19 14:16:24.725
!MESSAGE >> document/documentSymbol
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-19 14:16:24.726
!MESSAGE >> workspace/executeCommand microprofile/java/projectLabels
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-19 14:16:24.726
!MESSAGE >> workspace/executeCommand microprofile/java/projectLabels
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-19 14:16:24.753
!MESSAGE >> document/foldingRange
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-19 14:16:24.901
!MESSAGE >> workspace/executeCommand vscode.java.resolveMainMethod
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-19 14:16:24.901
!MESSAGE >> document/codeLens
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-19 14:16:25.279
!MESSAGE >> textDocument/inlayHint
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-19 14:16:25.627
!MESSAGE >> textDocument/semanticTokens/full
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-19 14:16:25.642
!MESSAGE >> codeLens/resolve
you are right there is actually a log.but it seems to be running.sadly there is nothing in client.is there a way to differentiate client or server fault.
log !ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-02 13:20:53.480 !MESSAGE Main thread is waiting !SESSION 2022-09-03 13:13:53.251 ----------------------------------------------- eclipse.buildId=unknown java.version=18 java.vendor=Oracle Corporation BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_GB Command-line arguments: -data D:\testlsp\jdt\defaultsharedworkspace
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-03 13:14:29.036 !MESSAGE class org.eclipse.jdt.ls.core.internal.JavaLanguageServerPlugin is started
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-03 13:14:34.025 !MESSAGE Main thread is waiting
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-03 13:14:34.663 !MESSAGE >> initialize
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-03 13:14:34.683 !MESSAGE Initializing Java Language Server 1.16.0.202209010336
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-03 13:14:34.686 !MESSAGE No workspace folders or root uri was defined. Falling back on D:/testlsp/jdt/defaultsharedworkspace
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-03 13:14:34.758 !MESSAGE Static Commands: []
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-03 13:14:34.759 !MESSAGE Non-Static 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.resolveWorkspaceSymbol, java.project.upgradeGradle, java.protobuf.generateSources, java.project.resolveSourceAttachment, java.project.addToSourcePath]
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-03 13:14:34.812 !MESSAGE Wait for AutoBuildOffJob start
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-03 13:14:34.815 !MESSAGE Wait for AutoBuildOffJob end 2ms
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-03 13:14:34.816 !MESSAGE Starting org.eclipse.m2e.core
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-03 13:14:34.818 !MESSAGE Started org.eclipse.m2e.core 1ms
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-03 13:14:34.819 !MESSAGE ProjectRegistryRefreshJob finished 1ms
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-03 13:14:34.820 !MESSAGE Starting org.eclipse.buildship.core
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-03 13:14:35.153 !MESSAGE Started org.eclipse.buildship.core 333ms
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-03 13:14:36.868 !MESSAGE LoadingGradleVersionJob finished 1714ms
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-03 13:14:36.948 !MESSAGE Creating the Java project jdt.ls-java-project
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-03 13:14:38.020 !MESSAGE Finished creating the Java project jdt.ls-java-project
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-03 13:14:40.653 !MESSAGE Importing Eclipse project(s)
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-03 13:14:40.727 !MESSAGE Workspace initialized in 3856ms
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-03 14:19:44.771 !MESSAGE Parent process stopped running, forcing server exit
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-03 14:19:44.772 !MESSAGE Shutdown received... waking up main thread
It looks like you may need to set workspaceFolders
or rootUri
/rootPaths
:
!ENTRY org.eclipse.jdt.ls.core 1 0 2022-09-03 13:14:34.686
!MESSAGE No workspace folders or root uri was defined. Falling back on D:/testlsp/jdt/defaultsharedworkspace
[Trace - 1:22:56 p.m.] Sending request 'initialize - (0)'.
Params: {
"processId": 43485,
"clientInfo": {
"name": "Visual Studio Code",
"version": "1.71.2"
},
"locale": "en-gb",
"rootPath": "/home/rgrunber/sample-projects/json-example",
"rootUri": "file:///home/rgrunber/sample-projects/json-example",
"capabilities": {
...
...
},
"initializationOptions": {
"bundles": [
"/home/rgrunber/.vscode/extensions/vscjava.vscode-java-debug-0.44.0/server/com.microsoft.java.debug.plugin-0.40.0.jar",
...
...
],
"workspaceFolders": [
"file:///home/rgrunber/sample-projects/json-example"
],
"settings": {
"java": {
...
...
}
},
"extendedClientCapabilities": {
...
...
},
"triggerFiles": [
"file:///home/rgrunber/sample-projects/json-example/src/org/example/Main.java"
]
},
"trace": "verbose",
"workspaceFolders": [
{
"uri": "file:///home/rgrunber/sample-projects/json-example",
"name": "json-example"
}
]
}
I would try that and see if there's any difference.
sorry not sure how to set that workspacefolder and rooturi is that client side setting?
Looking at the JDT-LS sources, yes these need to be defined by the client and sent over as part of initializiation. The preferred approach is to use, workspaceFolders
but rootUri
, or rootPath
should also work. There are 2 instances of workspaceFolders
. I think it wouldn't hurt to define both (as a child of initializationOptions
& Params
).
See https://github.com/eclipse/eclipse.jdt.ls/blob/dbd035c6aa036b6ee7dd7ea503de548f33fe641c/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/handlers/BaseInitHandler.java#L81-L109
so i guess i can call this function with a map {"workspaceFolders":"someemptypath/"}
something like that?
The initialize
call takes a JSON object from the client side. See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#initialize . JDT-LS converts certain portions to a map (or flattens it to a map) for ease of access on its end. For example, https://github.com/eclipse/eclipse.jdt.ls/blob/7ff257d1dbcbda9c8cfdea07cb992ba15fef791e/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/handlers/BaseInitHandler.java#L180-L182
Ahhh ok so it means i need to somehow set this json in the client side (aka.CudaText) Then call this function /(let the jdt run and it should call this function automatically in some other code)? Then wala it should work?
Yes, as soon as the language server (JDT-LS) has started, you would send a request whose method is initialize
and whose content is a JSON object (or String?). I think this is made easier if you use some library that supports the JSON-RPC specification.
https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#lifeCycleMessages describes some basic lifecycle messages.
i think Cuda text almost supports all JSON-RPC functionality will try setting it up and retest when i have more time.Thanks. Will close this issue for now,since we confirmed that the server is probably ok. Just need to setup the client with more infos.