CstNode
- class CstNode
Description
A CST node
Inheritance:
Members defined in
CstNode(15 members)RGet the node’s number of descendants, including one for the node itself.
RGet the node’s end byte.
RGet the node’s end position in terms of rows and columns (Utf-8 based).
RCheck if the node is a syntax error or contains any syntax errors.
RGet a numeric id for this node that is unique.
RCheck if the node is a syntax error.
RCheck if the node is extra.
RCheck if the node is missing.
RCheck if the node is named.
RGet the node’s start byte.
RGet the node’s start position in terms of rows and columns (Utf-8 based).
RGet an S-expression representing the node as a string.
RGet the node’s type as a numerical id.
RGet the node’s type as a string.
Get the node’s source text.
Attributes
- property descendant_count: int
Get the node’s number of descendants, including one for the node itself.
- property end_point: syside.PositionUtf8
Get the node’s end position in terms of rows and columns (Utf-8 based).
- property id: int
Get a numeric id for this node that is unique.
Within a given syntax tree, no two nodes have the same id.
- property is_extra: bool
Check if the node is extra.
Extra nodes represent things like comments, which are not required by the grammar, but can appear anywhere.
- property is_missing: bool
Check if the node is missing.
Missing nodes are inserted by the parser in order to recover from certain kinds of syntax errors.
- property is_named: bool
Check if the node is named.
Named nodes correspond to named rules in the grammar, whereas anonymous nodes correspond to string literals in the grammar.
- property start_point: syside.PositionUtf8
Get the node’s start position in terms of rows and columns (Utf-8 based).
- property symbol: syside.Symbol
Get the node’s type as a numerical id.
Methods
- text(arg: str, /) str
Get the node’s source text.
textis the full source text at the time of parsing. For example, if the associatedTextDocumenthas not been modified:def source_text(cst_node: syside.CstNode, document: syside.Document) -> str: if text_doc := document.text_document: with text_doc.lock() as text: return cst_node.text(text.text) ...
- text() str
Get the node’s source text from the associated
TextDocument.For performance reasons, modifications to the associated
TextDocumentafter receiving this CST node may affect the returned source string. This will be fixed in a future update.
Used by