ide
Submodule for IDE related functions.
Index
Classes ¶
Fixed-size bitset of |
||
Semantic token using absolute positions. |
||
Semantic token using delta encoded positions. |
||
Helper for building LSP compatible semantic tokens. |
Functions ¶
Build full document semantic tokens. |
||
Build full document semantic tokens for edits. |
||
Build range document semantic tokens. |
||
Resolve relatives paths and file URLs in Markdown links of the form |
Functions
- build_full_semantic_tokens(document: syside.Document, encoding: syside.ide.lsp.PositionEncodingKind = lsp.PositionEncodingKind.Utf8, multiline_tokens: bool = True, builder: syside.ide.SemanticTokensBuilder | None = None) syside.ide.SemanticTokensBuilder | None
Build full document semantic tokens.
Returns
builderif successful, andNoneotherwise. Generally,Noneis returned if thedocumenthas nothing to highlight.- Parameters:
document – The document to build full semantic tokens for.
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_tokensanddocument.text_document is None. Utf8 encoding andmultiline_tokensdoes not require a text source as all the required information is already contained in the CST.
- build_delta_semantic_tokens(document: syside.Document, id: int | str, encoding: syside.ide.lsp.PositionEncodingKind = lsp.PositionEncodingKind.Utf8, multiline_tokens: bool = True, builder: syside.ide.SemanticTokensBuilder | None = None) syside.ide.SemanticTokensBuilder | None
Build full document semantic tokens for edits.
Returns
builderif successful, andNoneotherwise. Generally,Noneis returned if thedocumenthas nothing to highlight.Internally calls
SemanticTokensBuilder.previous_resultbefore building tokens.- Parameters:
document – The document to build full semantic tokens for.
id – Previous result id.
previous_resultis called first, and if theidmatchesbuilderid the returnedbuildercan be used to build edits.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_tokensanddocument.text_document is None. Utf8 encoding andmultiline_tokensdoes not require a text source as all the required information is already contained in the CST.
- 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
builderif successful, andNoneotherwise. Generally,Noneis returned if thedocumenthas nothing to highlight.The returned
builderwill contain tokens encompassingrange. 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_tokensanddocument.text_document is None. Utf8 encoding andmultiline_tokensdoes not require a text source as all the required information is already contained in the CST.
- resolve_relative_md_links(source: str, cwd: str, root: str = '', predicate: Callable[[str], bool] | None = None) str
Resolve relatives paths and file URLs in Markdown links of the form
[<text>](<link>)insourceby prefixing them withcwdor optionallyroot.As links in Markdown should be valid URLs, only
/can be used as valid path separator, even on Windows. Links containing double backslashes will be ignored, and single backslashes will be assumed to be escapes.If provided,
predicateis always called before attempting to replace a path, returningFalsewill skip the path replacement. This allows customizing which paths are allowed to be replaced, e.g. by extension.cwdis used as path prefix for relative paths,root— absolute. No replacement takes place if:chosen prefix is empty, as there is nothing to insert;
relative path traverses outside of
root`, or ``cwdifrootis empty. Paths relative tocwdare only allowed to traverse up torootonly and only ifrootis an exact prefix ofcwd.