Open jansorg opened 11 months ago
Tracked in Apple’s issue tracker as rdar://113327487
The textDocument/definition
request is backed by the cursorInfo
request in sourcekitd, so I’ll move the issue to the compiler repo, where sourcekitd lives. It’s still fine for you to report it here.
Attaching reduced cursor info test case
func foo(arg: Int) {}
// RUN: %sourcekitd-test -req=cursor -pos=%(line + 1):5 %s -- %s
foo(arg: 1)
@ahoppen I can write a fix for this if no one is working on it yet
I don’t think anyone is working on it at the moment.
As discussed in https://github.com/apple/swift/pull/68341, I'm going to mark this as NTBF - the argument label is really part of the call and I would expect that to give back the function definition itself for cursor info and search for references to that function for find references.
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 (viatextDocument/references
) doesn't include the usages located insidemyFunction
, as far as I can tell. I‘m not certain about this.I verified this with the current 5.9 snapshot:
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.