swiftlang / sourcekit-lsp

Language Server Protocol implementation for Swift and C-based languages
Apache License 2.0
3.32k stars 276 forks source link

Better jump to definition for implementations of a protocol #809

Closed MahdiBM closed 11 months ago

MahdiBM commented 1 year ago

Consider this code:

protocol TestProtocol {
    func doThing()
}

struct TestImpl: TestProtocol { 
    func doThing() { }
}

func anyTestProtocol(value: any TestProtocol) {
    value.doThing()
}

Using VSCode with SSWG Swift extension, in value.doThing(), when you right click on doThing() to jump to definition, it'll just automatically jump to the protocol. This seems to be a SourceKit-LSP limitation.

Xcode/sourcekitd though is more smart about it and lets you choose between the protocol or one of the implementations:

Screenshot 2023-09-01 at 6 04 36 PM

ahoppen commented 1 year ago

Tracked in Apple’s issue tracker as rdar://114864256

ahoppen commented 1 year ago

sourcekit-lsp should report the secondary symbols returned by the sourcekitd cursor info response.

MahdiBM commented 1 year ago

@ahoppen I assume that's just a note tracking the progress of the issue? Or do I need to do something? 🙂

ahoppen commented 1 year ago

Oh, no, that’s just a note of what we should do to fix this.