Skip to content

Add CollectDeclarationUSRs batch request to sourcekitd #88018

@Tabonx

Description

@Tabonx

Motivation

Sourcekit-lsp needs to retrieve USRs and metadata for all declarations in a file to implement the references CodeLens feature.

Currently, the only way to get this information is by calling cursorInfo for each declaration individually. In a file with 100+ declarations, this requires 100+ round trips to sourcekitd. This is slow and creates excessive overhead.

Context: swiftlang/sourcekit-lsp#2552 (comment)

Proposed solution

Add a new batch request source.request.declaration.usrs to sourcekitd that returns USRs and declaration metadata for all declarations in a file in a single call. Similar to CollectVariableType source.request.variable.type

Input:

  • key.filepath
  • key.compilerargs
  • (Optional) key.offset and key.length - If specified, only return declarations in this range

Output:
Array of declaration info objects with:

  • key.offset
  • key.length
  • key.usr
  • key.kind

Alternatives considered

No response

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    triage neededThis issue needs more specific labels
    No fields configured for Feature.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions