Resolve a Pascal unit name to the graphify node ID of its source file. Scans all Pascal files under the project root (the highest ancestor that directly contains .pas/.dpr files) and returns _make_id(str(matched_path)). Result is cached per project root so the rglob runs at most once pe
(from_path: Path, unit_name: str)
| 13007 | |
| 13008 | |
| 13009 | def _pascal_resolve_unit(from_path: Path, unit_name: str) -> str: |
| 13010 | """Resolve a Pascal unit name to the graphify node ID of its source file. |
| 13011 | |
| 13012 | Scans all Pascal files under the project root (the highest ancestor that |
| 13013 | directly contains .pas/.dpr files) and returns _make_id(str(matched_path)). |
| 13014 | Result is cached per project root so the rglob runs at most once per |
| 13015 | project. Falls back to _make_id(unit_name) for units not found on disk |
| 13016 | (e.g. standard RTL units like SysUtils, Windows). |
| 13017 | """ |
| 13018 | root = _pascal_project_root(from_path) |
| 13019 | root_key = str(root) |
| 13020 | if root_key not in _pascal_unit_cache: |
| 13021 | unit_map: dict[str, str] = {} |
| 13022 | for ext in (".pas", ".pp", ".dpr", ".dpk", ".inc"): |
| 13023 | for f in root.rglob("*" + ext): |
| 13024 | unit_map[f.stem.lower()] = _make_id(str(f)) |
| 13025 | _pascal_unit_cache[root_key] = unit_map |
| 13026 | return _pascal_unit_cache[root_key].get(unit_name.lower(), _make_id(unit_name)) |
| 13027 | |
| 13028 | |
| 13029 | def _pascal_resolve_class(from_path: Path, class_name: str) -> str | None: |
no test coverage detected