TextDocument
- class TextDocument
A basic text document that holds source text and allows conversions between encoded text positions and byte offsets.
Note that the only way to update contents is through
.updatemethod.Members defined in
TextDocument(13 members)
RLanguage identifier of this text document.
RNumber of lines in this text document.
RFull source of this text document.
RLocation this text corresponds to.
RCurrent version of this text document.
Create an empty
TextDocumentfor multi-threaded applications
Create an empty
TextDocumentfor single-threaded applications
Get text corresponding to the given Utf-8 range.
Get byte offset at Utf-8 position.
Apply edits to the
contentsof this text documents.
Get Utf-16 position at the given byte offset.
Get Utf-32 position at the given byte offset.
Get Utf-8 position at the given byte offset.
Attributes
- property language_id: str
Language identifier of this text document.
- property line_count: int
Number of lines in this text document.
- property text: str
Full source of this text document.
- property url: syside.Url
Location this text corresponds to.
- property version: int
Current version of this text document.
Methods
- static create_mt() syside.SharedMutex[syside.TextDocument]
Create an empty
TextDocumentfor multi-threaded applications
- static create_mt(url: syside.Url, language: str, content: str, version: int = 0) syside.SharedMutex[syside.TextDocument]
- static create_st() syside.SharedMutex[syside.TextDocument]
Create an empty
TextDocumentfor single-threaded applications
- static create_st(url: syside.Url, language: str, content: str, version: int = 0) syside.SharedMutex[syside.TextDocument]
- get_text(range: syside.RangeUtf8) str
Get text corresponding to the given Utf-8 range.
- get_text(range: syside.RangeUtf16) str
Get text corresponding to the given Utf-16 range.
- get_text(range: syside.RangeUtf32) str
Get text corresponding to the given Utf-32 range.
- offset_at(position: syside.PositionUtf8) int
Get byte offset at Utf-8 position.
- offset_at(position: syside.PositionUtf16) int
Get byte offset at Utf-16 position.
- offset_at(position: syside.PositionUtf32) int
Get byte offset at Utf-32 position.
- update(changes: Sequence[syside.TextDocumentEditUtf8], version: int | None = None) None
Apply edits to the
contentsof this text documents.Updates the version to the given value, or increments an existing version.
- utf16_position_at(offset: int) syside.PositionUtf16
Get Utf-16 position at the given byte offset.
- utf32_position_at(offset: int) syside.PositionUtf32
Get Utf-32 position at the given byte offset.
- utf8_position_at(offset: int) syside.PositionUtf8
Get Utf-8 position at the given byte offset.