Coverage for src/renaissance/syntax_tree/siblings.py: 0%
12 statements
« prev ^ index » next coverage.py v7.16.1, created at 2026-10-02 13:12 +0000
« prev ^ index » next coverage.py v7.16.1, created at 2026-10-02 13:12 +0000
1"""AI: Protocol for a contiguous range of sibling syntax nodes."""
3from collections.abc import Sequence
4from typing import Protocol, Self, runtime_checkable
6from renaissance.syntax_tree.syntax_node import SyntaxNode
7from renaissance.syntax_tree.text_segment import TextSegment
9# TODO: Do we only want to wrap the AST sequence matches in AST pattern matching?
10# or also the parser output?
13@runtime_checkable
14class Siblings[NodeType](TextSegment, Protocol):
15 """Protocol for contiguous siblings, i.e., a range of syntax nodes.
17 Siblings is a text segment.
18 When the range of siblings is empty, the start and end offset of the text segment are the same.
19 Yet, an offset within the text is available.
21 Read-only access is enforced "as much as possible" by
22 exposing only @property getters in the protocol
23 """
25 @property
26 def syntax_nodes(self) -> Sequence[SyntaxNode[NodeType]]:
27 """The sequence of SyntaxNodes corresponding to these siblings."""
28 ...
30 @property
31 def parent(self) -> Self:
32 """The parent of these siblings.
34 The property 'parent' is not used to compare siblings.
35 """
36 ...
38 @property
39 def original_nodes(self) -> Sequence[NodeType]:
40 """The sequence of original nodes of these siblings as produced by the parser.
42 The property 'original_nodes' is not used to compare siblings.
43 """
44 ...