Provide SemanticTokensLegend#encode method to perform encoding according to standard
laeubi opened this issue · 1 comments
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.
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?