Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-10807] Implement textDocument/typeDefinition request #548

Open
benlangmuir opened this issue May 30, 2019 · 0 comments
Open

[SR-10807] Implement textDocument/typeDefinition request #548

benlangmuir opened this issue May 30, 2019 · 0 comments
Labels
good first issue Good for newcomers new feature Request for a new feature

Comments

@benlangmuir
Copy link
Member

benlangmuir commented May 30, 2019

Previous ID SR-10807
Radar None
Original Reporter @benlangmuir
Type New Feature
Additional Detail from JIRA
Votes 0
Component/s SourceKit-LSP
Labels New Feature, StarterBug
Assignee None
Priority Medium

md5: 48898578051a40902ab5b8e1104d1a38

Issue Description:

Implement the textDocument/typeDefinition request, which given a source location finds the type of the symbol at that position and then returns the location of that type's definition.

https://microsoft.github.io/language-server-protocol/specification#textDocument_typeDefinition

To implement this, you can look at how the existing jump to defintiion request works (textDocument/definition), but instead of using the key.usr field to get the declaration's USR, you can use the key.typeusr field.

Edit: it turns out typeusr is not suitable for this (https://forums.swift.org/t/usr-vs-typeusr-in-sourcekit/27759). It looks like to implement this we'll need to add a new field to sourcekitd's cursor_info. We want the USR of the type decl when that is available. For example,

var a =1 // a-> Int
var b = [1] // b -> Array
var c = (1, 2) // c -> nil
func test<T>(d: [T]) {} // d-> Array

So for a bound generic type like `Dictionary<Foo, Bar>`, we want to get the Dictionary decl's USR. When the type is non-nominal, such as a tuple or function type, we can just return null.

rdar://95597953

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 9, 2022
@ahoppen ahoppen added good first issue Good for newcomers and removed StarterBug labels Aug 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers new feature Request for a new feature
Projects
None yet
Development

No branches or pull requests

3 participants