from __future__ import annotations

from dataclasses import dataclass, field


@dataclass(slots=True)
class Entrypoint:
    entry_id: str
    entry_type: str
    framework: str
    route_or_command: str
    handler_symbol_id: str
    path: str
    start_line: int
    end_line: int
    handler_symbol: str | None = None
    declaring_symbol: str | None = None
    entrypoint_kind: str | None = None
    http_method: str | None = None
    route_path: str | None = None
    decorator_text: str | None = None
    summary_text: str | None = None
    metadata: dict = field(default_factory=dict)


class EntrypointDetectorRegistry:
    def __init__(self, detectors: list) -> None:
        self._detectors = detectors

    def detect_all(self, *, path: str, symbols: list) -> list[Entrypoint]:
        items: list[Entrypoint] = []
        for detector in self._detectors:
            items.extend(detector.detect(path=path, symbols=symbols))
        return items
