MCPcopy Create free account
hub / github.com/Graphify-Labs/graphify / _pascal_resolve_unit

Function _pascal_resolve_unit

graphify/extract.py:13009–13026  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

13007
13008
13009def _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
13029def _pascal_resolve_class(from_path: Path, class_name: str) -> str | None:

Callers 3

_extract_pascal_regexFunction · 0.85
walkFunction · 0.85
extract_lazarus_packageFunction · 0.85

Calls 3

_make_idFunction · 0.90
_pascal_project_rootFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected