"""
This type stub file was generated by pyright.
"""

import rich.repr
from enum import StrEnum
from functools import cached_property
from typing import Generic, Self, TYPE_CHECKING, TypeVar, final
from graph_sitter.core.autocommit import reader
from graph_sitter.core.expressions import Expression
from graph_sitter.core.node_id_factory import NodeId
from graph_sitter.core.symbol_groups.multi_line_collection import MultiLineCollection
from graph_sitter.writer_decorators import apidoc, noapidoc
from graph_sitter.codebase.codebase_graph import CodebaseGraph
from graph_sitter.core.detached_symbols.code_block import CodeBlock
from tree_sitter import Node as TSNode

if TYPE_CHECKING:
    ...
@apidoc
class StatementType(StrEnum):
    """Enum representing the different types of statements that can be parsed."""
    COMMENT = ...
    ASSIGNMENT = ...
    EXPRESSION_STATEMENT = ...
    CLASS_ATTRIBUTE = ...
    RETURN_STATEMENT = ...
    RAISE_STATEMENT = ...
    WITH_STATEMENT = ...
    PASS_STATEMENT = ...
    BREAK_STATEMENT = ...
    LABELED_STATEMENT = ...
    TRY_CATCH_STATEMENT = ...
    IF_BLOCK_STATEMENT = ...
    FOR_LOOP_STATEMENT = ...
    WHILE_STATEMENT = ...
    SWITCH_STATEMENT = ...
    SYMBOL_STATEMENT = ...
    UNSPECIFIED = ...
    EXPORT_STATEMENT = ...
    IMPORT_STATEMENT = ...


Parent = TypeVar("Parent", bound="CodeBlock")
@apidoc
class Statement(Expression[Parent], Generic[Parent]):
    """Interface for a single code statement. Enables analysis/editing of more complex code
    structures.

    Examples include:
    - a chain of function calls, assignment expression, if/else statement, for/while loop
    - in context of a block in a class definition, a statement can be a function definition or attribute
    """
    statement_type: StatementType = ...
    _pos: int
    def __init__(self, ts_node: TSNode, file_node_id: NodeId, G: CodebaseGraph, parent: Parent, pos: int | None = ...) -> None:
        ...
    
    def __rich_repr__(self) -> rich.repr.Result:
        ...
    
    @property
    def index(self) -> int:
        """The 0-based index of the statement in the parent code block.

        Returns the sequential position of this statement within its containing code block.

        Returns:
            int: The 0-based index of this statement within its parent code block.
        """
        ...
    
    @classmethod
    @noapidoc
    @final
    def from_code_block(cls, ts_node: TSNode, code_block: CodeBlock, pos: int | None = ...) -> Statement:
        ...
    
    @cached_property
    @reader
    def nested_code_blocks(self) -> list[Parent]:
        """Returns all nested code blocks within the statement.

        Finds and parses any immediate 'block' or 'statement_block' nodes within the statement.

        Returns:
            list[TCodeBlock]: A list of parsed code blocks that are directly nested within this statement. Each block has a level one higher than its parent block.
        """
        ...
    
    @property
    @reader
    def nested_statements(self) -> list[MultiLineCollection[Statement[Self], Parent]]:
        """Returns a list of statement collections within nested code blocks.

        Accesses and retrieves the statements from each code block nested within the current statement,
        such as the statements within if/else branches or loop bodies.

        Returns:
            A list where each element is a
                collection of statements from one nested code block. Returns an empty list if there are no
                nested code blocks.
        """
        ...
    


