from collections.abc import (
    Callable,
)

from blends.models import (
    NId,
)
from blends.syntax.cfg.dispatchers import (
    await_expression_node,
    connect_to_block,
    connect_to_declarations,
    connect_to_next,
    end_node,
    if_node,
    method_invocation_node,
    multi_path,
    object_node,
    pair_node,
    step_by_step,
    switch_body,
    switch_section,
    variable_declaration_node,
)
from blends.syntax.models import (
    SyntaxCfgArgs,
)

DISPATCHERS: dict[str, Callable[[SyntaxCfgArgs], NId]] = {
    "Class": connect_to_block.build,
    "DoStatement": connect_to_block.build,
    "ElseClause": connect_to_block.build,
    "ForEachStatement": connect_to_block.build,
    "ForStatement": connect_to_block.build,
    "MethodDeclaration": connect_to_block.build,
    "Namespace": connect_to_block.build,
    "SwitchStatement": connect_to_block.build,
    "UsingStatement": connect_to_block.build,
    "WhileStatement": connect_to_block.build,
    "ArgumentList": multi_path.build,
    "BinaryOperation": multi_path.build,
    "DeclarationBlock": multi_path.build,
    "File": multi_path.build,
    "TryStatement": multi_path.build,
    "ClassBody": multi_path.build,
    "SwitchBody": switch_body.build,
    "SwitchSection": switch_section.build,
    "ExecutionBlock": step_by_step.build,
    "ParameterList": step_by_step.build,
    "If": if_node.build,
    "TernaryOperation": if_node.build,
    "MethodInvocation": method_invocation_node.build,
    "Annotation": connect_to_next.build,
    "Argument": connect_to_next.build,
    "ArrayInitializer": connect_to_next.build,
    "Assignment": connect_to_next.build,
    "Attribute": connect_to_next.build,
    "AwaitExpression": await_expression_node.build,
    "Break": connect_to_next.build,
    "CatchClause": connect_to_next.build,
    "CatchDeclaration": connect_to_next.build,
    "Comment": connect_to_next.build,
    "Continue": connect_to_next.build,
    "Debugger": connect_to_next.build,
    "ElementAccess": connect_to_next.build,
    "ExpressionStatement": step_by_step.build,
    "FinallyClause": connect_to_next.build,
    "JsxElement": connect_to_next.build,
    "Literal": connect_to_next.build,
    "MemberAccess": connect_to_next.build,
    "MissingNode": connect_to_next.build,
    "Modifiers": connect_to_next.build,
    "NamedArgument": connect_to_next.build,
    "NewExpression": connect_to_next.build,
    "Object": object_node.build,
    "ObjectCreation": connect_to_next.build,
    "Pair": pair_node.build,
    "Parameter": connect_to_next.build,
    "ParenthesizedExpression": connect_to_next.build,
    "ReservedWord": connect_to_next.build,
    "RestPattern": connect_to_next.build,
    "Selector": connect_to_next.build,
    "SpreadElement": connect_to_next.build,
    "SymbolLookup": connect_to_next.build,
    "This": connect_to_next.build,
    "ThrowStatement": connect_to_next.build,
    "UnaryExpression": connect_to_next.build,
    "Yield": connect_to_next.build,
    "VariableDeclaration": variable_declaration_node.build,
    "Return": connect_to_declarations.build,
    "Export": connect_to_declarations.build,
    "Import": connect_to_next.build,
    "ModuleImport": end_node.build,
}
