Description
When textDocument/definition
is invoked on the argument name of a function invocation, then the resolved definition points to the function name. If I'm not mistaken, resolving to the parameter name identifier inside the function declaration would be better.
I've tested this with the current VSCode Swift plugin and latest sourcekit-lsp and also with my own wip LSP client implementation for JetBrains IDEs.
The reverse search on name
of a function declaration (via textDocument/references
) doesn't include the usages located inside myFunction
, as far as I can tell. I‘m not certain about this.
public class MyClass {
public init(_ first: String = "default", name: String? = nil) {
}
public func myFunction(_ first: String = "default", name: String? = nil) {
}
}
func myFunction() {
// definition of "name" points to init name identifier "init" on line 2, but should point to "name" on line 5
let myValue = MyClass(name: "my value")
// definition of "name" points to function name identifier "myFunction on line 5", but should point to "name" on line 5
myValue.myFunction(name: "value")
}
I verified this with the current 5.9 snapshot:
# swift --version
Swift version 5.9-dev (LLVM 8250a14f5d3ef6a, Swift 73c7ebb20f64b96)
Target: x86_64-unknown-linux-gnu
I hope that this is the right place to report this. I wasn't sure if the cause would be inside sourcekit-lsp or one of its dependencies.