Skip to content

Conversation

@ahoppen
Copy link
Member

@ahoppen ahoppen commented Jun 23, 2024

clangd uses a completely different semantic token legend than SourceKit-LSP (it doesn’t even adhere to the ordering of the pre-defined token types) but we were passing index offsets from clangd through assuming that clangd uses the same legend, which was incorrect.

When retrieving semantic tokens from clangd, translate the semantic tokens from clangd’s legend to SourceKit-LSP’s legend.

rdar://129895062

@ahoppen ahoppen requested review from bnbarham and hamishknight June 23, 2024 07:32
@ahoppen ahoppen requested a review from benlangmuir as a code owner June 23, 2024 07:32
@ahoppen ahoppen changed the title Translate the semantic token legend used by clangd to the semantic token legend used by SourceKit-LSP Translate the semantic token legend used by clangd to the semantic token legend used by SourceKit-LSP 🚥#1509 Jun 23, 2024
private let tokenTypeTranslations: [UInt32: Translation]

/// For all token modifiers whose representation in clang differs from the representation in SourceKit-LSP, maps the
/// index of that token type in clangd’s token type legend to the corresponding representation in SourceKit-LSP.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/// index of that token type in clangd’s token type legend to the corresponding representation in SourceKit-LSP.
/// index of that token type in clangd’s token modifier legend to the corresponding representation in SourceKit-LSP.

…ken legend used by SourceKit-LSP

clangd uses a completely different semantic token legend than SourceKit-LSP (it doesn’t even adhere to the ordering of the pre-defined token types) but we were passing index offsets from clangd through assuming that clangd uses the same legend, which was incorrect.

When retrieving semantic tokens from clangd, translate the semantic tokens from clangd’s legend to SourceKit-LSP’s legend.

rdar://129895062
@ahoppen ahoppen force-pushed the translate-clangd-semantic-token-map branch from cb6c995 to 80a35aa Compare June 26, 2024 07:34
@ahoppen ahoppen changed the title Translate the semantic token legend used by clangd to the semantic token legend used by SourceKit-LSP 🚥#1509 Translate the semantic token legend used by clangd to the semantic token legend used by SourceKit-LSP Jun 26, 2024
@ahoppen
Copy link
Member Author

ahoppen commented Jun 26, 2024

@swift-ci Please test

@ahoppen ahoppen merged commit 46cc2e6 into swiftlang:main Jun 26, 2024
@ahoppen ahoppen deleted the translate-clangd-semantic-token-map branch June 27, 2024 03:29
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.

3 participants