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