DocumentSegment

class DocumentSegment

Utf-8 based segment into a source text document.

Members defined in DocumentSegment (10 members)

end

RW

End byte of this segment

offset

RW

Start byte of this segment

range

RW

Text range of this segment

__init__

from_cst

Construct a segment corresponding to the given CST node.

from_cst_end

Construct a segment corresponding to the end position of the given CST node.

from_cst_start

Construct a segment corresponding to the start position of the given CST node.

from_node

Construct DocumentSegment from the nearest CST node that contains node.

from_node_field

Construct DocumentSegment from a tree-sitter field named field at index.

from_node_symbol

Construct DocumentSegment from a tree-sitter symbol named symbol at index.

Attributes

property end: int

End byte of this segment

property offset: int

Start byte of this segment

property range: syside.RangeUtf8

Text range of this segment

Methods

__init__(range: syside.RangeUtf8 = ..., offset: int = 0, end: int = 0) None
static from_cst(arg: syside.CstNode, /) syside.DocumentSegment

Construct a segment corresponding to the given CST node.

static from_cst_end(arg: syside.CstNode, /) syside.DocumentSegment

Construct a segment corresponding to the end position of the given CST node.

static from_cst_start(arg: syside.CstNode, /) syside.DocumentSegment

Construct a segment corresponding to the start position of the given CST node.

static from_node(arg: syside.AstNode, /) syside.DocumentSegment

Construct DocumentSegment from the nearest CST node that contains node.

static from_node_field(node: syside.AstNode, field: str, index: int = 0) syside.DocumentSegment

Construct DocumentSegment from a tree-sitter field named field at index.

If node does not contain a CST node with a matching field, the nearest CST segment is returned instead.

static from_node_symbol(node: syside.AstNode, symbol: str, index: int = 0) syside.DocumentSegment

Construct DocumentSegment from a tree-sitter symbol named symbol at index.

If node does not contain a CST node with a matching symbol, the nearest CST segment is returned instead.

Used in