tree-sitter: add missing members (#8693)

This commit is contained in:
Akuli
2022-09-06 22:28:11 +03:00
committed by GitHub
parent 81f8a10e9b
commit b98ee679fb
3 changed files with 30 additions and 2 deletions

View File

@@ -1,18 +1,24 @@
# "self" argument is missing when stubtest inspects these methods
tree_sitter.Node.child_by_field_id
tree_sitter.Node.child_by_field_name
tree_sitter.Node.children_by_field_id
tree_sitter.Node.children_by_field_name
tree_sitter.Node.sexp
tree_sitter.Node.walk
tree_sitter.Parser.parse
tree_sitter.Parser.set_language
tree_sitter.Tree.edit
tree_sitter.Tree.get_changed_ranges
tree_sitter.Tree.walk
tree_sitter.TreeCursor.copy
tree_sitter.TreeCursor.current_field_name
tree_sitter.TreeCursor.goto_first_child
tree_sitter.TreeCursor.goto_next_sibling
tree_sitter.TreeCursor.goto_parent
tree_sitter.binding.Node.child_by_field_id
tree_sitter.binding.Node.child_by_field_name
tree_sitter.binding.Node.children_by_field_id
tree_sitter.binding.Node.children_by_field_name
tree_sitter.binding.Node.sexp
tree_sitter.binding.Node.walk
tree_sitter.binding.Parser.parse
@@ -20,7 +26,9 @@ tree_sitter.binding.Parser.set_language
tree_sitter.binding.Query.captures
tree_sitter.binding.Query.matches
tree_sitter.binding.Tree.edit
tree_sitter.binding.Tree.get_changed_ranges
tree_sitter.binding.Tree.walk
tree_sitter.binding.TreeCursor.copy
tree_sitter.binding.TreeCursor.current_field_name
tree_sitter.binding.TreeCursor.goto_first_child
tree_sitter.binding.TreeCursor.goto_next_sibling

View File

@@ -2,7 +2,7 @@ import ctypes
from _typeshed import StrPath
from collections.abc import Sequence
# Query is missing at runtime for some reason
# At runtime, Query and Range are available only in tree_sitter.binding
from tree_sitter.binding import Node as Node, Parser as Parser, Tree as Tree, TreeCursor as TreeCursor
class Language:

View File

@@ -18,6 +18,8 @@ class Node:
@property
def has_error(self) -> bool: ...
@property
def id(self) -> int: ...
@property
def is_missing(self) -> bool: ...
@property
def is_named(self) -> bool: ...
@@ -28,6 +30,8 @@ class Node:
@property
def children(self) -> list[Node]: ...
@property
def named_children(self) -> list[Node]: ...
@property
def next_named_sibling(self) -> Node | None: ...
@property
def next_sibling(self) -> Node | None: ...
@@ -41,9 +45,12 @@ class Node:
def text(self) -> bytes | Any: ... # can be None, but annoying to check
@property
def type(self) -> str: ...
__hash__: ClassVar[None] # type: ignore[assignment]
def children_by_field_name(self, name: str) -> list[Node]: ...
def children_by_field_id(self, __id: int) -> list[Node]: ...
def field_name_for_child(self, __child_index: int) -> str: ...
def child_by_field_id(self, __id: int) -> Node | None: ...
def child_by_field_name(self, __name: str) -> Node | None: ...
__hash__: ClassVar[None] # type: ignore[assignment]
def sexp(self) -> str: ...
def walk(self) -> TreeCursor: ...
def __eq__(self, other: object) -> bool: ...
@@ -67,6 +74,17 @@ class Query:
# start_point and end_point arguments don't seem to do anything
def captures(self) -> list[tuple[Node, str]]: ...
@final
class Range:
@property
def start_byte(self) -> int: ...
@property
def end_byte(self) -> int: ...
@property
def start_point(self) -> tuple[int, int]: ...
@property
def end_point(self) -> tuple[int, int]: ...
@final
class Tree:
@property
@@ -82,12 +100,14 @@ class Tree:
old_end_point: tuple[int, int],
new_end_point: tuple[int, int],
) -> None: ...
def get_changed_ranges(self, new_tree: Tree) -> list[Range]: ...
def walk(self) -> TreeCursor: ...
@final
class TreeCursor:
@property
def node(self) -> Node: ...
def copy(self) -> TreeCursor: ...
def current_field_name(self) -> str | None: ...
def goto_first_child(self) -> bool: ...
def goto_next_sibling(self) -> bool: ...