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

Provide SemanticTokensLegend#encode method to perform encoding according to standard #769

Open
laeubi opened this issue Oct 26, 2023 · 1 comment

Comments

@laeubi
Copy link

laeubi commented Oct 26, 2023

I'm currently try to use getting some basic syntax highlights with SemanticTokensLegend / org.eclipse.lsp4j.services.TextDocumentService.semanticTokensFull(SemanticTokensParams) due to the specification this requires a non trivial transformation of types/modifiers/locations into a stream of ints.

To ease implementation (and add validation) I think it would be usefull to have a method in SemanticTokensLegend that helps in encoding things for example returning an IntStream and taking the keyword, the modifier and a location as input.

This method can the for example fail if invalid token types are send and so on.

@pisv
Copy link
Contributor

pisv commented Oct 26, 2023

Sounds like a good idea to me. However, from the API point of view, I would rather suggest adding the following methods to the SemanticTokensLegend:

	int encodeTokenType(String tokenType)
	int encodeTokenModifiers(Set<String> tokenModifiers)
	String decodeTokenType(int tokenType)
	Set<String> decodeTokenModifiers(int tokenModifiers)

@laeubi Would you like to submit a PR for that?

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

No branches or pull requests

3 participants