SemanticTokensBuilder
- class SemanticTokensBuilder
Helper for building LSP compatible semantic tokens.
This is typically used used to build semantic tokens for a single document that may be edited as the builder additionally retains the previous build state to build a delta for reduced message sizes in LSP.
Note that the builder itself is position encoding agnostic - encoding is implied through
appendedtokens.Members defined in
SemanticTokensBuilder(10 members)
RGet all collected absolute semantic tokens.
RReturns
trueifbuild_editswould return delta to the previous result.
RGet all collected delta semantic tokens.
RRandomly generated ID of this builder.
RGet previously built tokens as delta tokens.
Append a new semantic token.
Build currently collected semantic tokens into LSP compatible format.
Build currently collected semantic tokens into LSP compatible format.
Move the contents of this builder to previous result and reset the state.
Attributes
- property absolute_tokens: syside.ContainerView[syside.ide.AbsoluteSemanticToken]
Get all collected absolute semantic tokens.
Note that this may require decoding delta tokens first.
- property can_build_edits: bool
Returns
trueifbuild_editswould return delta to the previous result.
- property delta_tokens: syside.ContainerView[syside.ide.DeltaSemanticToken]
Get all collected delta semantic tokens.
Note that in case tokens were appended out of order, an encoding may take place.
- property id: int
Randomly generated ID of this builder.
- property previous_tokens: syside.ContainerView[syside.ide.DeltaSemanticToken]
Get previously built tokens as delta tokens.
Must call
previous_resultto make this available.
Methods
- __init__() None
- append(arg: syside.ide.AbsoluteSemanticToken, /) None
Append a new semantic token.
- build() syside.ide.lsp.SemanticTokens
Build currently collected semantic tokens into LSP compatible format.
- build_edits() syside.ide.lsp.SemanticTokens | syside.ide.lsp.SemanticTokensDelta
Build currently collected semantic tokens into LSP compatible format.
If
can_build_edits, a delta to theprevious_tokenswill be returned which will usually be smaller than the full tokens.
- previous_result(arg: int, /) None
Move the contents of this builder to previous result and reset the state.
If id does not match
id, current tokens are discarded instead. This must be called before building edits.
- previous_result(arg: str, /) None
Overload of
previous_resultthat will parse the provided id to int.