TextDocument

class TextDocument

Description

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 .update method.

Inheritance:

Members defined in TextDocument (13 members)

language_id

R

Language identifier of this text document.

line_count

R

Number of lines in this text document.

text

R

Full source of this text document.

url

R

Location this text corresponds to.

version

R

Current version of this text document.

create_mt

Create an empty TextDocument for multi-threaded applications

create_st

Create an empty TextDocument for single-threaded applications

get_text

Get text corresponding to the given Utf-8 range.

offset_at

Get byte offset at Utf-8 position.

update

Apply edits to the contents of this text documents.

utf16_position_at

Get Utf-16 position at the given byte offset.

utf32_position_at

Get Utf-32 position at the given byte offset.

utf8_position_at

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]
static create_mt(url: syside.Url, language: str, content: str, version: int = 0) → syside.SharedMutex[syside.TextDocument]

Create an empty TextDocument for multi-threaded applications

static create_st() → syside.SharedMutex[syside.TextDocument]
static create_st(url: syside.Url, language: str, content: str, version: int = 0) → syside.SharedMutex[syside.TextDocument]

Create an empty TextDocument for single-threaded applications

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 contents of 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.

Used by