Extract AST nodes and edges from a list of code files. Two-pass process: 1. Per-file structural extraction (classes, functions, imports) 2. Cross-file import resolution: turns file-level imports into class-level INFERRED edges (DigestAuth --uses--> Response) Args: pa
(
paths: list[Path],
cache_root: Path | None = None,
*,
root: Path | None = None,
parallel: bool = True,
max_workers: int | None = None,
resolution_context_nodes: list[dict] | None = None,
resolution_context_edges: list[dict] | None = None,
release_parse_memo: bool = False,
refresh_astro_cache: bool = False,
refresh_paths: "Iterable[Path] | None" = None,
)
| 12932 | |
| 12933 | |
| 12934 | def extract( |
| 12935 | paths: list[Path], |
| 12936 | cache_root: Path | None = None, |
| 12937 | *, |
| 12938 | root: Path | None = None, |
| 12939 | parallel: bool = True, |
| 12940 | max_workers: int | None = None, |
| 12941 | resolution_context_nodes: list[dict] | None = None, |
| 12942 | resolution_context_edges: list[dict] | None = None, |
| 12943 | release_parse_memo: bool = False, |
| 12944 | refresh_astro_cache: bool = False, |
| 12945 | refresh_paths: "Iterable[Path] | None" = None, |
| 12946 | ) -> dict: |
| 12947 | """Extract AST nodes and edges from a list of code files. |
| 12948 | |
| 12949 | Two-pass process: |
| 12950 | 1. Per-file structural extraction (classes, functions, imports) |
| 12951 | 2. Cross-file import resolution: turns file-level imports into |
| 12952 | class-level INFERRED edges (DigestAuth --uses--> Response) |
| 12953 | |
| 12954 | Args: |
| 12955 | paths: files to extract from |
| 12956 | root: explicit anchor for source_file relativization, node ids, and |
| 12957 | symbol resolution. Pass the SCAN root whenever the cache lives |
| 12958 | somewhere else (`--out`); without it the anchor falls back to |
| 12959 | cache_root and every scanned file reads as out-of-root (#1941). |
| 12960 | cache_root: explicit root for graphify-out/cache/ (overrides the |
| 12961 | inferred common path prefix). Pass Path('.') when running on a |
| 12962 | subdirectory so the cache stays at ./graphify-out/cache/. |
| 12963 | Anchors ids/source_file only as a fallback when `root` is unset. |
| 12964 | parallel: if True and there are >= _PARALLEL_THRESHOLD uncached files, |
| 12965 | use ProcessPoolExecutor for multi-core extraction. |
| 12966 | max_workers: max subprocess count. Defaults to GRAPHIFY_MAX_WORKERS |
| 12967 | if set, else one worker per _BYTES_PER_WORKER of uncached source |
| 12968 | up to cpu_count; always bounded by len(uncached_work). |
| 12969 | resolution_context_nodes: read-only AST nodes from files that are NOT |
| 12970 | being extracted this run (an incremental rebuild's unchanged |
| 12971 | corpus, #2406). They extend the cross-file resolution indexes — |
| 12972 | the shared direct-call pass's label/file indexes, the |
| 12973 | indirect_call callable guard (via the persisted `_callable` / |
| 12974 | `_callable_class` markers, #2438), and the member-call resolvers |
| 12975 | run by `run_language_resolvers` (#2437) — so a changed caller can |
| 12976 | still bind `foo()`, `obj.method()`, or `submit(handler)` to an |
| 12977 | unchanged callee. JS/TS resolution may read unchanged modules for |
| 12978 | export facts. Context nodes are never mutated or returned. Raw calls |
| 12979 | come only from `paths`, so emitted edges are owned by re-extracted files. |
| 12980 | resolution_context_edges: structural resolver edges from the same |
| 12981 | unchanged corpus (#2437). These map receiver types to their methods |
| 12982 | and preserve inheritance evidence for language-specific resolvers. |
| 12983 | Read-only, same contract as |
| 12984 | resolution_context_nodes: they widen the resolvers' view but only |
| 12985 | fresh results are appended to the returned nodes/edges. |
| 12986 | release_parse_memo: no effect; kept so existing callers still work. |
| 12987 | Python resolution no longer memoizes parsed trees, so there is |
| 12988 | nothing to release. |
| 12989 | refresh_astro_cache: reparse Astro files after a JS/TS resolver input |
| 12990 | changes. Fresh results replace the ordinary per-file AST cache. |
| 12991 | refresh_paths: files to parse even on an AST cache hit. An incremental |