mirror of
https://github.com/colbymchenry/codegraph.git
synced 2026-10-19 06:22:38 +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:
@@ -475,14 +475,37 @@ impl<'t> Walker<'t> {
|
||||
let docstring = preceding_docstring(node, self.src);
|
||||
let left = node.child_by_field_name("left").or_else(|| node.named_child(0));
|
||||
let right = node.child_by_field_name("right").or_else(|| node.named_child(1));
|
||||
let Some(left) = left else { return };
|
||||
if !matches!(left.kind(), "identifier" | "constant") {
|
||||
return;
|
||||
let mut assigned: Option<(u32, String)> = None;
|
||||
if let Some(left) = left {
|
||||
if matches!(left.kind(), "identifier" | "constant") {
|
||||
let name = self.text(left).to_string();
|
||||
let signature = right.map(|r| util::init_signature(self.text(r)));
|
||||
// No isConst hook ⇒ always `variable` (UPPER_CASE constants included).
|
||||
let row = self.create_node(
|
||||
"variable",
|
||||
&name,
|
||||
node,
|
||||
Extra { docstring, signature, ..Extra::default() },
|
||||
);
|
||||
if let Some(row) = row {
|
||||
assigned = Some((row, name));
|
||||
}
|
||||
}
|
||||
}
|
||||
// Walk the initializer ATTRIBUTED to the assigned name (#693): a
|
||||
// module-level `app = FastAPI()` / `handler = lambda: run()` dropped
|
||||
// every call on the right-hand side. A tuple target mints no symbol, so
|
||||
// its RHS is walked at the enclosing scope rather than lost.
|
||||
if let Some(right) = right {
|
||||
match assigned {
|
||||
Some((row, name)) => {
|
||||
self.stack.push(Scope { row, kind: "variable", name });
|
||||
self.visit_function_body(right);
|
||||
self.stack.pop();
|
||||
}
|
||||
None => self.visit_function_body(right),
|
||||
}
|
||||
}
|
||||
let name = self.text(left).to_string();
|
||||
let signature = right.map(|r| util::init_signature(self.text(r)));
|
||||
// No isConst hook ⇒ always `variable` (UPPER_CASE constants included).
|
||||
self.create_node("variable", &name, node, Extra { docstring, signature, ..Extra::default() });
|
||||
}
|
||||
|
||||
fn extract_import(&mut self, node: Node<'t>) {
|
||||
|
||||
Reference in New Issue
Block a user