Skip to content
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

SemanticTokensService does not corretly implement LSP specification #2750

Closed
jnt0r opened this issue Jul 18, 2023 · 0 comments
Closed

SemanticTokensService does not corretly implement LSP specification #2750

jnt0r opened this issue Jul 18, 2023 · 0 comments
Milestone

Comments

@jnt0r
Copy link
Contributor

jnt0r commented Jul 18, 2023

The SemanticTokensService implementation does not correctly implement the LSP specification in two points.

  1. It only supports the three TokenTypes: KEYWORD_ID, DEFAULT_ID, NUMBER_ID. In the specification there are way more TokenTypes.
  2. When converting the TokenType from String to index there is always an offset of 1 added which is not correct.
private int getTokenType(final String[] ids) {
    for (String id : ids) {
	Integer index = tokenTypes.indexOf(id);
	if (index != -1) {
		return index + 1;
	}
    }
    return 0;
}
...
Integer positionTokenType = getTokenType(lightweightPosition.getIds());
Integer positionTokenModifiers = getTokenModifiers(lightweightPosition.getIds());

if (positionTokenType != 0 || positionTokenModifiers != 0) {
    int deltaOffset = lightweightPosition.getOffset() - lastOffset;
    ...

The specification says:
Token types are looked up by index, so a tokenType value of 1 means tokenTypes[1].
https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_semanticTokens

I will open a PR to fix these issues, but I wanted to address them as a problem first.

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

No branches or pull requests

2 participants