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

Adjust SemanticTokensService to LSP specification #2753

Merged
merged 1 commit into from
Jan 25, 2024

Conversation

jnt0r
Copy link
Contributor

@jnt0r jnt0r commented Jul 19, 2023

TokenType is 0 based and represents the index in the list of supported token types.

0 is valid for TokenType and TokenModifiers, so we do not need to check for 0 here.

I added all supported TokenTypes and TokenModifiers from the specification to the List of possible types and modifiers.

@jnt0r jnt0r marked this pull request as ready for review July 20, 2023 10:48
@jnt0r
Copy link
Contributor Author

jnt0r commented Jul 25, 2023

fixes #2750

@jnt0r
Copy link
Contributor Author

jnt0r commented Jul 28, 2023

One thing not working yet is the "multilineTokenSupport". VS Code for example does not support multiline tokens but this implementation uses multiline tokens by default.

data.add(positionTokenType); // token type
data.add(positionTokenModifiers); // token modifiers
}
int deltaOffset = lightweightPosition.getOffset() - lastOffset;
Copy link
Contributor

Choose a reason for hiding this comment

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

After this change, I wonder how you'd indicate a position with an ID that is specifically not compatible to the LSP token types? E.g. another UI might support more token types.

I think that's why 0 was used as a return type for an ID that's semantic but not supported by the LSP protocol.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the problem is, that 0 is a valid tokenTypeIndex in LSP. I now changed it to return -1 if no valid TokenType is found. So the TokenType with index 0 can be used and still we can detect unsupported types.

// delta start relative to previous token if on the same line or to 0
data.add(deltaLine == 0 ? deltaOffset : position.getCharacter());
data.add(lightweightPosition.getLength()); // length
data.add(positionTokenType); // token type
Copy link
Contributor

Choose a reason for hiding this comment

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

I think here is where we missed a positionTokenType - 1 to compensate for the chosen communication channel 0 == not contained in list

Copy link
Contributor Author

Choose a reason for hiding this comment

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

to use 0 as an indicator for not supported tokenTypes we would need to add a placeholder tokenType in the list of supported types. Otherwise we would not be able to use the first token Type in the list of supported types. That's why I changed the indicator to -1

@cdietrich
Copy link
Member

@jnt0r @szarnekow what is the state of this pr?

@jnt0r
Copy link
Contributor Author

jnt0r commented Sep 29, 2023

I currently don't have much time. Will have to take a look at it in a week.

@jnt0r
Copy link
Contributor Author

jnt0r commented Sep 29, 2023

There are still a few adjustments needed.

@cdietrich
Copy link
Member

@jnt0r can you please rebase and sequash commits into 1

@jnt0r
Copy link
Contributor Author

jnt0r commented Nov 10, 2023

@cdietrich I don't quite understand why the build failed. Looks like some build setup and no code issue...
Can you take a look?

@cdietrich
Copy link
Member

As I said you need to rebase

@jnt0r
Copy link
Contributor Author

jnt0r commented Nov 10, 2023

Okay. Thought I already did it. Seems to work now.

@swissiety
Copy link

Thank you all for working on this problem - my research project will definitely benefit from it. I hope this can be merged soon.

@szarnekow
Copy link
Contributor

szarnekow commented Nov 16, 2023

I'll approve but probably hold off the merge until after the release since we are in the last week essentially. It will be discussed next week wether we want to merge this nevertheless or immediately after the build.

Copy link
Contributor

@szarnekow szarnekow left a comment

Choose a reason for hiding this comment

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

Thank you!

@jnt0r
Copy link
Contributor Author

jnt0r commented Dec 5, 2023

What's the state of this?

TokenType is 0 based and represents the index in the list of supported
token types.

0 is valid for TokenType and TokenModifiers so we do not need to check
for 0 here.

Signed-off-by: Jonathan Pollert <jona.pollert@gmail.com>
@jnt0r
Copy link
Contributor Author

jnt0r commented Jan 4, 2024

@szarnekow can this be merged?

@jnt0r
Copy link
Contributor Author

jnt0r commented Jan 25, 2024

ping @cdietrich @szarnekow

@szarnekow szarnekow added this to the Release_2.34 milestone Jan 25, 2024
@szarnekow szarnekow merged commit b125aa2 into eclipse:main Jan 25, 2024
2 checks passed
@szarnekow
Copy link
Contributor

Thanks again. I merged the changes @jnt0r

@jnt0r jnt0r deleted the semantic-tokens-service branch January 26, 2024 08: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.

4 participants