syside.ide.build_range_semantic_tokens

build_range_semantic_tokens(document: syside.Document, range: syside.RangeUtf8, encoding: syside.ide.lsp.PositionEncodingKind = lsp.PositionEncodingKind.Utf8, multiline_tokens: bool = True, builder: syside.ide.SemanticTokensBuilder | None = None) syside.ide.SemanticTokensBuilder | None

Build range document semantic tokens. Returns builder if successful, and None otherwise. Generally, None is returned if the document has nothing to highlight.

The returned builder will contain tokens encompassing range. For most documents, this will be more efficient that building full semantic tokens.

Parameters:
  • document – The document to build range semantic tokens for.

  • range – Range that should have all tokens highlighted. Implementation may return also build tokens outside of this range.

  • encoding – The position encoding to use for semantic tokens. Use Utf32 if interacting with Python strings.

  • multiline_tokens – Whether to keep multiline tokens as is and not split them. Generally used for language clients that do not support multiline tokens.

  • builder – The builder to collect semantic tokens into. Note that if provided, its internal state will be reset.

Returns:

Provided builder, or new one otherwise, if there was anything to highlight.

Raises:

ValueError – If encoding != Utf8 or not multiline_tokens and document.text_document is None. Utf8 encoding and multiline_tokens does not require a text source as all the required information is already contained in the CST.