Skip to content

Add DocCSymbolLinkDefinition request - #76

Open
Padmashree06 wants to merge 1 commit into
swiftlang:mainfrom
Padmashree06:Add-DocCSymbolLinkDefinitionRequest
Open

Add DocCSymbolLinkDefinition request#76
Padmashree06 wants to merge 1 commit into
swiftlang:mainfrom
Padmashree06:Add-DocCSymbolLinkDefinitionRequest

Conversation

@Padmashree06

Copy link
Copy Markdown

Summary

Adds DocCSymbolLinkDefinitionRequest, a new LSP extension request that resolves a DocC symbol link string to the location of the symbol it refers to.

Motivation

Currently, symbol links in the DocC Live Preview are not clickable. To enable this, we need a new request that adds the functionality of navigating to the symbol's definition if it exists, or showing an error when it doesn't - making the preview interactive.

Details

DocCSymbolLinkDefinitionRequest takes the symbol link string and the document's URI as arguments and returns the Location of where the symbol is defined.

@Padmashree06
Padmashree06 force-pushed the Add-DocCSymbolLinkDefinitionRequest branch from 4789cd1 to 0c7eed9 Compare August 10, 2026 06:03

@ahoppen ahoppen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two high-level questions:

  • Where does the editor get the symbol link from?
  • Depending on how the editor extracts the symbol name, can’t SourceKit-LSP do it and thus can’t this be implemented using a textDocument/definition request?

@Padmashree06

Copy link
Copy Markdown
Author
  • The editor gets the symbol link from the href attribute in the rendered documentation.

  • This can't be done with a textDocument/definition request, because that request requires a cursor position, and when the user clicks a symbol link inside the Documentation Preview, we don't have a cursor position.

@ahoppen ahoppen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds reasonable to me then, just two small comments.


public struct DocCSymbolLinkDefinitionRequest: TextDocumentRequest, Hashable {
public static let method: String = "sourcekit/textDocument/doccSymbolLinkDefinition"
public typealias Response = Location?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be LocationsOrLocationLinksResponse? to match textDocument/definition? It would also allow us to return multiple locations in case the symbol link is ambiguous.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes!

/// This request is an extension to LSP supported by SourceKit-LSP.
/// The client is expected to navigate to the returned location, or display an appropriate error
/// message to the user if the response is `nil`.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Superfluous newlin

@Padmashree06
Padmashree06 force-pushed the Add-DocCSymbolLinkDefinitionRequest branch from 0c7eed9 to 03b2b27 Compare August 10, 2026 12:41
@Padmashree06

Copy link
Copy Markdown
Author

I have made the changes!

Thanks for the review!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants