mirror of
https://github.com/colbymchenry/codegraph.git
synced 2026-10-19 14:32:59 +08:00
fix(kotlin): walk a same-line property accessor too
Follow-up to cf582f4. `val url: String get() = build(host)` nests the accessor
UNDER the property_declaration, so the hook consumed it and everything the
getter body called vanished — the initializer walk deliberately skipped
`getter`/`setter` on the theory that they are declaration, not code. They are
code.
Measured on the Android project this arc is validated against: 16 such
properties, whose accessor bodies contributed nothing at all.
An accessor written on its OWN line parses as a SIBLING of the property, not a
child, so it stays out of reach here and keeps attributing to the enclosing
class exactly as before. That asymmetry is the grammar's, and closing it means
looking backwards from a sibling accessor to the preceding declaration —
separate change, separate risk.
Whole-project re-measure (110 Kotlin + 100 JS + 37 Go files, both arms of the
extractor): 0 genuinely lost edges, +142 edges. The 13 edges that changed
identity are 9 JS initializer calls moving off the file node onto their
declaring constant, and 4 Kotlin `run(…)` call sites that used to name-match a
JavaScript test helper in desktop/test/ and now match a Kotlin `run` override.
This commit is contained in:
@@ -87,13 +87,15 @@ fn strip_js_ws(s: &str) -> String {
|
||||
s.chars().filter(|c| !is_js_space(*c)).collect()
|
||||
}
|
||||
|
||||
/// A property's RHS: the named child right after the `=` token, plus a
|
||||
/// `property_delegate` (`by lazy { … }`). Everything else a
|
||||
/// `property_declaration` can hold is a declaration, not code — modifiers, the
|
||||
/// `val`/`var` keyword, the name+type, an extension receiver's type and type
|
||||
/// parameters, and `getter`/`setter` — so it stays unwalked. (Go's #693 fix
|
||||
/// walks the `value` field for the same reason; this grammar exposes no fields
|
||||
/// at all, hence the `=` anchor.)
|
||||
/// A property's CODE children: the named child right after the `=` token, a
|
||||
/// `property_delegate` (`by lazy { … }`), and an accessor the grammar nested
|
||||
/// under the declaration (`val x: Int get() = compute()` — written on ONE line;
|
||||
/// an accessor on its own line parses as a SIBLING of the property and is not
|
||||
/// reachable from here). What stays unwalked is the declaration itself —
|
||||
/// modifiers, the `val`/`var` keyword, the name+type, and an extension
|
||||
/// receiver's type and type parameters. (Go's #693 fix walks the `value` field
|
||||
/// for the same reason; this grammar exposes no fields at all, hence the `=`
|
||||
/// anchor.)
|
||||
fn property_initializers<'t>(node: Node<'t>) -> Vec<Node<'t>> {
|
||||
let mut out: Vec<Node<'t>> = Vec::new();
|
||||
let mut after_eq = false;
|
||||
@@ -108,7 +110,7 @@ fn property_initializers<'t>(node: Node<'t>) -> Vec<Node<'t>> {
|
||||
if after_eq {
|
||||
out.push(c);
|
||||
after_eq = false;
|
||||
} else if c.kind() == "property_delegate" {
|
||||
} else if matches!(c.kind(), "property_delegate" | "getter" | "setter") {
|
||||
out.push(c);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user