Skip to content

Implement textDocument/declaration #647

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

Merged
merged 1 commit into from
Oct 10, 2022

Conversation

CodaFi
Copy link
Contributor

@CodaFi CodaFi commented Oct 10, 2022

A declaration request is similar to a definition request, except that it is expected to return (potentially) many results across the workspace for a given reference. For example, an inline function or macro may have many declarations in the workspace, but only one "good" or canonical definition. For now, this is only implemented by forwarding the request on to clangd since I'm unfamiliar with a SourceKit query for this.

For languages like Swift that lack such a sharp declaration/definition split, we could potentially use this request to provide navigable metadata on linked definitions. For example, the declaration for a type reference would include all extensions of that type in the workspace.

@CodaFi
Copy link
Contributor Author

CodaFi commented Oct 10, 2022

@swift-ci test

Copy link
Member

@ahoppen ahoppen left a comment

Choose a reason for hiding this comment

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

Thanks. Mostly looks good to me.

@CodaFi CodaFi force-pushed the i-declare-bankruptcy! branch 2 times, most recently from 4509236 to 90ee7e0 Compare October 10, 2022 15:47
@CodaFi
Copy link
Contributor Author

CodaFi commented Oct 10, 2022

@swift-ci test

A declaration request is similar to a definition request, except that it is expected to return (potentially) many results across the workspace for a given reference. For example, an inline function or macro may have many declarations in the workspace, but only one "good" or canonical definition. For now, this is only implemented by forwarding the request on to clangd since I'm unfamiliar with a SourceKit query for this.

For languages like Swift that lack such a sharp declaration/definition split, we could potentially use this request to provide navigable metadata on linked definitions. For example, the declaration for a type reference would include all extensions of that type in the workspace.
@CodaFi CodaFi force-pushed the i-declare-bankruptcy! branch from 90ee7e0 to 0b89da4 Compare October 10, 2022 18:29
@CodaFi
Copy link
Contributor Author

CodaFi commented Oct 10, 2022

@swift-ci test

@CodaFi CodaFi merged commit 6081a2e into swiftlang:main Oct 10, 2022
@CodaFi CodaFi deleted the i-declare-bankruptcy! branch October 10, 2022 21:01
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