Closed linguiqi closed 3 years ago
The language server should support go-to-definition for classes from jars, this seems to be a regression.
Should a language server also support go-to-definition for functions from jars as well?
This one does have a mechanism, where it returns special kls://...
-URIs for classes in jars, which, through a non-standard-request, can be decompiled on the server-side and then displayed by the client (which is analogous to the Java language server's jdt://...
-URIs).
Not quite sure why it doesn't work anymore though.
I'm using kls /w coc-nvim and see similar behaviour (can't look up some Spring Framework definitions). What can I provide to help debug this?
:CocCommand workspace.showOutput
after setting trace.server
to verbose
shows:
[Trace - 3:11:21 PM] Received notification 'window/logMessage'.
Params: {
"type": 3,
"message": "async1 Go-to-definition at .../domain/KubernetesFetcher.kt 30:35"
}
[Info - 3:11:21 PM] async1 Go-to-definition at .../domain/KubernetesFetcher.kt 30:35
[Trace - 3:11:21 PM] Received notification 'window/logMessage'.
Params: {
"type": 3,
"message": "async2 Updating symbol index..."
}
[Info - 3:11:21 PM] async2 Updating symbol index...
[Trace - 3:11:21 PM] Received notification 'textDocument/publishDiagnostics'.
Params: {
"uri": "file:///home/medwards/forks/pex-router/src/main/java/com/signavio/pex/router/domain/KubernetesFetcher.kt",
"diagnostics": []
}
[Trace - 3:11:21 PM] Received request 'window/workDoneProgress/create - (1)'.
Params: {
"token": "bd375418-22af-4e27-a472-27b333ffc107"
}
[Trace - 3:11:21 PM] Sending response 'window/workDoneProgress/create - (1)'. Processing request took 1ms
No result returned.
[Trace - 3:11:21 PM] Received notification 'window/logMessage'.
Params: {
"type": 3,
"message": "debounce0 No diagnostics in file:///home/medwards/forks/pex-router/src/main/java/com/signavio/pex/router/domain/KubernetesFetcher.kt"
}
[Info - 3:11:21 PM] debounce0 No diagnostics in file:///home/medwards/forks/pex-router/src/main/java/com/signavio/pex/router/domain/KubernetesFetcher.kt
[Trace - 3:11:21 PM] Received notification '$/progress'.
Params: {
"token": "bd375418-22af-4e27-a472-27b333ffc107",
"value": {
"kind": "begin",
"title": "Kotlin: Indexing",
"percentage": 0
}
}
[Trace - 3:11:22 PM] Received notification 'window/logMessage'.
Params: {
"type": 3,
"message": "async1 Re-parsing KubernetesFetcher.kt 29:5-30:57"
}
[Info - 3:11:22 PM] async1 Re-parsing KubernetesFetcher.kt 29:5-30:57
[Trace - 3:11:22 PM] Received notification 'window/logMessage'.
Params: {
"type": 3,
"message": "async1 Hovering REFERENCE_EXPRESSION"
}
[Info - 3:11:22 PM] async1 Hovering REFERENCE_EXPRESSION
[Trace - 3:11:22 PM] Received notification 'window/logMessage'.
Params: {
"type": 3,
"message": "async1 Found declaration descriptor @java.lang.FunctionalInterface public fun ApplicationEventPublisher(function: ((kotlin.Any..kotlin.Any?)) -> kotlin.Unit): org.springframework.context.ApplicationEventPublisher defined in org.springframework.context[SamConstructorDescriptorImpl@731b346c]"
}
[Info - 3:11:22 PM] async1 Found declaration descriptor @java.lang.FunctionalInterface public fun ApplicationEventPublisher(function: ((kotlin.Any..kotlin.Any?)) -> kotlin.Unit): org.springframework.context.ApplicationEventPublisher defined in org.springframework.context[SamConstructorDescriptorImpl@731b346c]
[Trace - 3:11:22 PM] Received notification 'window/logMessage'.
Params: {
"type": 3,
"message": "async1 Couldn't find definition at .../domain/KubernetesFetcher.kt 30:35"
}
[Info - 3:11:22 PM] async1 Couldn't find definition at .../domain/KubernetesFetcher.kt 30:35
[Trace - 3:11:22 PM] Received notification 'window/logMessage'.
Params: {
"type": 3,
"message": "async1 Finished in 1199 ms"
}
[Info - 3:11:22 PM] async1 Finished in 1199 ms
[Trace - 3:11:22 PM] Received response 'textDocument/definition - (1)' in 1207ms.
Result: []
[Trace - 3:11:40 PM] Received notification 'window/logMessage'.
Params: {
"type": 3,
"message": "client Updated symbol index in 19020 ms! (38459 symbol(s))"
}
[Info - 3:11:40 PM] client Updated symbol index in 19020 ms! (38459 symbol(s))
[Trace - 3:11:40 PM] Received notification '$/progress'.
Params: {
"token": "bd375418-22af-4e27-a472-27b333ffc107",
"value": {
"kind": "end"
}
}
Added some more logs, when this occurs:
destination
is nulllocation
returns nulllocation
sourceFile
is equal to SourceFile.NO_SOURCE_FILE
Neither GoToDefinition.kt
or Position.kt
have been touched since 2019 so I'm not sure when this worked before.
Is #117 related? Seems not, looks like the related code has been uncommented and evolved since then.
I tried doing some naive changes with no luck:
kotlin-scripting-jvm-host-unshaded
to kotlin-scripting-jvm-host
and kotlin-scripting-jsr223
(per the alternatives outlined in the Kotlin 1.4 release notes)gradle.properties
a bit (specifying the KotlinBuildType like in the referenced commit).Neither change seems to change the bug behaviour. There might be a subtle difference in CompilerMessageSourceLocation
vs CompilerMessageLocation
but I'm just guessing.
I tried similar things to no avail. However, I just tried using earlier kotlin versions. It seems the problem started with version 1.3.70. With version 1.3.61 it still works. Don't know which dependency broke it though, but maybe we can find the build that broke it.
I think I fixed it. Opened a PR: https://github.com/fwcd/kotlin-language-server/pull/291
Works on my machine 🤷
I use this in vscode and open an Android project. For the 'Go to Definition' option, it works for the symbols in kotlin source code. However, it does not work for the symbols in jars or java files. For example, when I want to go to the definition of the class 'Application', it shows ‘No definition found for “Application” ’. Does this language server support 'Go to Definition' Completely?