Class SemanticTokensData

java.lang.Object
org.eclipse.lemminx.services.extensions.semantictokens.SemanticTokensData

public class SemanticTokensData extends Object
Builder for LSP semantic tokens encoded data.

Tokens are collected by offset and sorted before encoding. This allows multiple participants to add tokens in any order.

Each token is encoded as 5 integers: deltaLine, deltaStartChar, length, tokenType, tokenModifiers.

  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addToken(int offset, int length, int tokenType, int tokenModifiers)
    Add a semantic token at the given offset with the given length, token type index, and token modifiers bitmask.
    org.eclipse.lsp4j.SemanticTokens
    Build the SemanticTokens result.
    boolean
    Returns true if no tokens have been added.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • SemanticTokensData

      public SemanticTokensData(DOMDocument document)
  • Method Details

    • addToken

      public void addToken(int offset, int length, int tokenType, int tokenModifiers)
      Add a semantic token at the given offset with the given length, token type index, and token modifiers bitmask.
      Parameters:
      offset - the offset in the document.
      length - the length of the token.
      tokenType - the token type index (from the legend).
      tokenModifiers - the token modifiers bitmask.
    • build

      public org.eclipse.lsp4j.SemanticTokens build()
      Build the SemanticTokens result.
      Returns:
      the semantic tokens result.
    • isEmpty

      public boolean isEmpty()
      Returns true if no tokens have been added.
      Returns:
      true if no tokens have been added.