[SourceKit] Add type declaration location to cursorInfo response#86381
[SourceKit] Add type declaration location to cursorInfo response#86381loveucifer wants to merge 1 commit into
Conversation
this extends the cursorInfo request to include complete type declaration location information, enabling proper go-to-definition for inlay type hints. new response keys: - key.typedecl_usr: Declaration USR of the type (suitable for index lookup) - key.typedecl_filepath: Path to the file containing the type declaration - key.typedecl_line: Line number of the declaration - key.typedecl_column: Column number of the declaration - key.typedecl_modulename: Module containing the type the existing key.typeusr is a type-mangled representation (e.g., $sSiD) which cannot be used for definition lookup. this new key.typedecl_usr is a proper declaration USR (e.g., s:Si) that works with the index. this enables SourceKit-LSP to implement go-to-definition for inlay hints without requiring the index to be available or up-to-date.
|
Thanks for the PR! Rather than adding more things to the cursor info request I think it would be worth seeing if we could add a new request for this that takes the type USR as an input and returns the declaration USR + location info. We already have |
| public: | ||
| AnnotatedDeclarationPrinter(raw_ostream &OS) | ||
| :XMLEscapingPrinter(OS) { } | ||
| AnnotatedDeclarationPrinter(raw_ostream &OS) : XMLEscapingPrinter(OS) {} |
There was a problem hiding this comment.
When formatting changes please use git clang-format instead to ensure only the bits of code you changed get formatted
hey @hamishknight I am implementing the new source.request.typedecl.info request that takes the mangled type as input (key.mangled_type) and uses Demangle::getTypeDeclForMangling to resolve it, returning the declaration USR + location info. |
|
Oh sorry I just noticed it looks like cursor info already has an option to take a type USR (using |
Should I also update cursorInfo to return key.typeusr as a proper USR instead of a mangled name, or leave that for a separate PR due to the client audit needed? |
|
Let's leave that as a separate PR for now, just make the logic in LSP conditional i.e if we have a |
wait but wouldnt that mean this pr is now not neeeded at all :0 or am i missing something , should i just close this then and update the pr on swiftlang/sourcekit-lsp ? or is there any sort of addition needed here |
|
Yup, assuming it works fine on the LSP side you can close this :) |
following the pr in swift/sourcekitlsp swiftlang/sourcekit-lsp#2436 i made an attempt to fix this issue swiftlang/sourcekit-lsp#2318. ( a new commit will be added once im done with this )
Changes
extends the
cursorInforequest to return complete type declaration location information, enabling proper go-to-definition functionality for inlay type hints in SourceKit-LSP.Problem
the existing
key.typeusrfield returns a type-mangled USR (e.g.,$sSiDforInt) rather than a declaration USR (e.g.,s:Si). type-mangled USRs cannot be used to look up definitions in the index.Fixes I Made
add new fields to the cursorInfo response:
key.typedecl_usr- Declaration USR for index lookupkey.typedecl_filepath- Direct path to declarationkey.typedecl_line/key.typedecl_column- Line and columnkey.typedecl_modulename- Containing moduleShort Summary Of File Changes I made
LangSupport.h: AddedTypeDeclUSR,TypeDeclLocation,TypeDeclModuleNametoCursorSymbolInfoSwiftSourceDocInfo.cpp: Extract nominal type declaration from variable's typeRequests.cpp: Output new fields in responseUIDs.py: Define new key identifiersalso i might have missed something , i started reading the repo only like 2 days ago , but the fix for that led me here so we do what we gotta do :D