CstNode
- class CstNode
A CST node
Members defined in
CstNode(23 members)RGet the node’s number of children.
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).
RGet the node’s type as a numerical id as it appears in the grammar ignoring aliases.
RGet the node’s type as it appears in the grammar ignoring aliases as a null-terminated string.
RCheck if a syntax node has been edited.
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 number of named children.
RGet the parse state after this node.
RGet this node’s parse state.
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 field name for node’s child at the given index, where zero represents the first child.
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 grammar_symbol: syside.Symbol
Get the node’s type as a numerical id as it appears in the grammar ignoring aliases.
- property grammar_type: str
Get the node’s type as it appears in the grammar ignoring aliases as a null-terminated string.
- 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. However:
If a new tree is created based on an older tree, and a node from the old tree is reused in the process, then that node will have the same id in both trees.
A node not marked as having changes does not guarantee it was reused.
If a node is marked as having changed in the old tree, it will not be reused.
- 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 next_parse_state: syside.StateId
Get the parse state after this node.
- property parse_state: syside.StateId
Get this node’s parse state.
- 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
- field_name_for_child(arg: int, /) str | None
Get the field name for node’s child at the given index, where zero represents the first child.
Returns
None, if no field is found
- 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.