|
| 1 | +from typing import Any, ClassVar |
| 2 | +from typing_extensions import final |
| 3 | + |
| 4 | +from tree_sitter import Language |
| 5 | + |
| 6 | +@final |
| 7 | +class Node: |
| 8 | + @property |
| 9 | + def start_byte(self) -> int: ... |
| 10 | + @property |
| 11 | + def start_point(self) -> tuple[int, int]: ... |
| 12 | + @property |
| 13 | + def end_byte(self) -> int: ... |
| 14 | + @property |
| 15 | + def end_point(self) -> tuple[int, int]: ... |
| 16 | + @property |
| 17 | + def has_changes(self) -> bool: ... |
| 18 | + @property |
| 19 | + def has_error(self) -> bool: ... |
| 20 | + @property |
| 21 | + def is_missing(self) -> bool: ... |
| 22 | + @property |
| 23 | + def is_named(self) -> bool: ... |
| 24 | + @property |
| 25 | + def child_count(self) -> int: ... |
| 26 | + @property |
| 27 | + def named_child_count(self) -> bool: ... |
| 28 | + @property |
| 29 | + def children(self) -> list[Node]: ... |
| 30 | + @property |
| 31 | + def next_named_sibling(self) -> Node | None: ... |
| 32 | + @property |
| 33 | + def next_sibling(self) -> Node | None: ... |
| 34 | + @property |
| 35 | + def parent(self) -> Node | None: ... |
| 36 | + @property |
| 37 | + def prev_named_sibling(self) -> Node | None: ... |
| 38 | + @property |
| 39 | + def prev_sibling(self) -> Node | None: ... |
| 40 | + @property |
| 41 | + def text(self) -> bytes | Any: ... # can be None, but annoying to check |
| 42 | + @property |
| 43 | + def type(self) -> str: ... |
| 44 | + __hash__: ClassVar[None] # type: ignore[assignment] |
| 45 | + def child_by_field_id(self, __id: int) -> Node | None: ... |
| 46 | + def child_by_field_name(self, __name: str) -> Node | None: ... |
| 47 | + def sexp(self) -> str: ... |
| 48 | + def walk(self) -> TreeCursor: ... |
| 49 | + def __eq__(self, other: object) -> bool: ... |
| 50 | + def __ne__(self, other: object) -> bool: ... |
| 51 | + # There are __ge__, __gt__, __le__, __lt__ methods but they always return False |
| 52 | + # |
| 53 | + # >>> n |
| 54 | + # <Node kind=call, start_point=(0, 0), end_point=(0, 14)> |
| 55 | + # >>> n >= "", n <= "", n >= 0, n <= 0, n >= (0,0), n <= (0,0) |
| 56 | + # (False, False, False, False, False, False) |
| 57 | + |
| 58 | +@final |
| 59 | +class Parser: |
| 60 | + # At runtime, Parser(1, 2, 3) ignores the arguments, but that's most likely buggy code |
| 61 | + def __init__(self) -> None: ... |
| 62 | + def parse(self, source: bytes, old_tree: Tree | None = ..., keep_text: bool = ...) -> Tree: ... |
| 63 | + def set_language(self, __language: Language) -> None: ... |
| 64 | + |
| 65 | +@final |
| 66 | +class Query: |
| 67 | + # start_point and end_point arguments don't seem to do anything |
| 68 | + def captures(self) -> list[tuple[Node, str]]: ... |
| 69 | + |
| 70 | +@final |
| 71 | +class Tree: |
| 72 | + @property |
| 73 | + def root_node(self) -> Node: ... |
| 74 | + @property |
| 75 | + def text(self) -> bytes | Any: ... # technically ReadableBuffer | Any |
| 76 | + def edit( |
| 77 | + self, |
| 78 | + start_byte: int, |
| 79 | + old_end_byte: int, |
| 80 | + new_end_byte: int, |
| 81 | + start_point: tuple[int, int], |
| 82 | + old_end_point: tuple[int, int], |
| 83 | + new_end_point: tuple[int, int], |
| 84 | + ) -> None: ... |
| 85 | + def walk(self) -> TreeCursor: ... |
| 86 | + |
| 87 | +@final |
| 88 | +class TreeCursor: |
| 89 | + @property |
| 90 | + def node(self) -> Node: ... |
| 91 | + def current_field_name(self) -> str | None: ... |
| 92 | + def goto_first_child(self) -> bool: ... |
| 93 | + def goto_next_sibling(self) -> bool: ... |
| 94 | + def goto_parent(self) -> bool: ... |
0 commit comments