mirror of
https://github.com/colbymchenry/codegraph.git
synced 2026-10-24 03:08:45 +08:00
Squash danusha2345's PR #1511 atd282f9e8onto main8c9c4761, preserving its nine non-merge commits and main's existing Unreleased notes. Calls in Kotlin, Java, TS/JS, Scala, Rust and Python declaration initializers now retain the owner established by the upstream regression expectations. Include the upstream CFML, dynamic-dispatch summary and viewer follow-ups. Linux fail-to-pass validation (Node 22.19.0, rebuilt dist and native kernel): - Before: TS load belonged to file:app.ts; Python/Kotlin/Scala/Rust calls vanished; Java lost the field-lambda, anonymous override and eager calls. - After: all six languages PASS; 12 native/WASM LF/CRLF parity checks PASS. - Focused initializer regressions: 10 passed with CODEGRAPH_KERNEL=0 and 10 passed with the kernel enabled; Kotlin's grammar fallback is recorded. - Related regression suites: 879 passed, 1 skipped across 15 test files. - Evidence: /workspace/cg-1510-repro/before and /workspace/cg-1510-repro/after (combined test output: after/vitest.log). Fixes #1510 Supersedes #1511 Co-authored-by: Colby McHenry <colbymchenry@users.noreply.github.com> Co-authored-by: danusha2345 <ewidusoc498@gmail.com>
This commit is contained in:
@@ -66,6 +66,7 @@ export function buildFile(cg: CodeGraph, projectRoot: string, requested: string)
|
||||
const nodes = cg.getNodesInFile(storedPath);
|
||||
const nodeIds = nodes.map((n) => n.id);
|
||||
const inThisFile = new Set(nodeIds);
|
||||
const nodeKindById = new Map(nodes.map((n) => [n.id, n.kind]));
|
||||
const fileNode = nodes.find((n) => n.kind === 'file') ?? null;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -106,8 +107,20 @@ export function buildFile(cg: CodeGraph, projectRoot: string, requested: string)
|
||||
// the same signal `/api/entrypoints` ranks on. It is worth a line on this
|
||||
// screen because the outline cannot show it: top-level code belongs to no
|
||||
// symbol, so the only way to read it is to open the file node itself.
|
||||
// A call made while initializing a module-level variable or constant is
|
||||
// attributed to that name (#693), so those names are top-level code too and
|
||||
// are counted with the file — the same set `getTopCallingFiles` ranks on.
|
||||
const moduleLevelValueIds = fileNode
|
||||
? cg
|
||||
.getOutgoingEdgesFrom([fileNode.id], ['contains'])
|
||||
.map((e) => e.target)
|
||||
.filter((id) => {
|
||||
const kind = nodeKindById.get(id);
|
||||
return kind === 'variable' || kind === 'constant';
|
||||
})
|
||||
: [];
|
||||
const topLevelEdges = fileNode
|
||||
? cg.getOutgoingEdgesFrom([fileNode.id], ['calls', 'instantiates'])
|
||||
? cg.getOutgoingEdgesFrom([fileNode.id, ...moduleLevelValueIds], ['calls', 'instantiates'])
|
||||
: [];
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user