Commit f0db64c
authored
feat(resolver): resolve calls through Object.defineProperty / defineProperties / create (#1328)
* feat(resolver): track constructor-assigned property types for receiver-typed resolution (JS/TS)
Closes #1306
Extends `handlePropWriteTypeMap` to seed the points-to type map from
`this.prop = new ClassName(...)` assignments, enabling resolution of
`this.prop.method()` calls through the existing receiver-typed path.
Before: `this.logger.error/info/warn()` in UserService were unresolvable
because only `obj.prop = identifier` writes were tracked (Phase 8.3d).
After: `this.logger = new Logger(...)` seeds `typeMap['this.logger'] = Logger`
with confidence 1.0 (same as `const x = new Ctor()` in variable declarators).
The existing `resolveByMethodOrGlobal` and native `edge_builder.rs` fallback
(`or_else(|| type_map.get(receiver))`) then pick up `this.logger` and resolve
`this.logger.error()` → `Logger.error`.
Impact: JS fixture receiver-typed recall 2/5 → 5/5 (40% → 100%).
Ratchet JS benchmark gate: precision 0.85→1.0, recall 0.5→0.9.
* fix(resolver): resolve this.method() to ClassName.method in JS/TS WASM path (#1314)
When a class method calls this.method() or super.method(), the WASM/JS
resolution path failed to find the target because methods are stored as
qualified names (e.g. Logger._write) but lookups used the unqualified
name (_write). The native Rust engine resolved this implicitly via its
class-scoped symbol table.
Fix: in buildFileCallEdges, after resolveCallTargets returns no targets
for a this/super receiver call, extract the class name prefix from the
caller's qualified name (e.g. Logger.info → Logger) and retry with the
fully-qualified method name (Logger._write) in the same file.
Fixes the JS benchmark recall (83.3% → 100%) and TS benchmark recall
(69.4% → 72.2%), satisfying CI thresholds of 90% and 72% respectively.
* docs(bench): explain JS/TS threshold values in resolution-benchmark (#1314)
Add inline comments explaining why JS recall is 0.9 and TS recall is
0.72, linking the thresholds to the Phase 8.3e same-class this.method()
fix and noting which remaining gaps (interface-dispatch, CHA) are tracked
in future phases.
Addresses Greptile P2 review comment on the threshold bump.
* fix(resolver): restrict same-class fallback to this receiver, exclude super (#1314)
* feat(resolver): resolve calls through Object.defineProperty / defineProperties / create
Seed composite pts keys from three property descriptor APIs so that
obj.key() can be traced back to the original function reference:
- Object.defineProperty(obj, "key", { value: fn })
→ type_map["obj.key"] = "fn"
- Object.defineProperties(obj, { "k1": { value: v1 }, ... })
→ type_map["obj.k1"] = "v1", …
- const obj = Object.create({ f1, f2 }) (shorthand or pair)
→ type_map["obj.f1"] = "f1", type_map["obj.f2"] = "f2"
Implemented in both the Rust extractor (native engine) and the TS
extractor (wasm engine) for parity. Adds a `define-property.js`
fixture with 5 expected edges (3 defineProperty/defineProperties + 2
create) that all now resolve at 100% recall.
Closes #1320
* fix(extractor): add string-type guard and anchored regex for defineProperty key extraction (#1328)
- defineProperty path: guard arg1.type !== 'string' before extraction, matching
the Rust seed_define_property_entries behaviour (which returns None for non-string AST nodes)
- defineProperties path: use anchored /^['"]|['"]$/ to strip only boundary quotes,
not quotes within the key value, with string-type guard
- seedProtoProperties: same anchored regex fix for pair keys
Closes the TS/Rust engine parity gap flagged in Greptile review. (docs check acknowledged)
* fix(test): flush deferred DB close before temp-dir removal in embedding regression (#1328)
On Windows, buildGraph uses closeDbDeferred which schedules the SQLite
WAL checkpoint via setImmediate. When afterAll runs before the deferred
close executes, fs.rmSync throws EBUSY on graph.db. Call flushDeferredClose
before the temp-dir cleanup to ensure the handle is closed synchronously.
* fix(test): apply biome formatting to define-property.js fixture
* docs(bench): update JS edge count comment to reflect 30 total expected edges after merge
* fix(test): use fs.rmSync maxRetries for robust EBUSY handling on Windows (#1328)1 parent a233110 commit f0db64c
7 files changed
Lines changed: 424 additions & 16 deletions
File tree
- crates/codegraph-core/src/extractors
- src/extractors
- tests
- benchmarks/resolution
- fixtures/javascript
- search
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
96 | 100 | | |
97 | 101 | | |
98 | 102 | | |
99 | 103 | | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
100 | 108 | | |
101 | 109 | | |
102 | 110 | | |
| |||
194 | 202 | | |
195 | 203 | | |
196 | 204 | | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
197 | 350 | | |
198 | 351 | | |
199 | 352 | | |
| |||
2292 | 2445 | | |
2293 | 2446 | | |
2294 | 2447 | | |
| 2448 | + | |
| 2449 | + | |
| 2450 | + | |
| 2451 | + | |
| 2452 | + | |
| 2453 | + | |
| 2454 | + | |
| 2455 | + | |
| 2456 | + | |
| 2457 | + | |
| 2458 | + | |
| 2459 | + | |
| 2460 | + | |
| 2461 | + | |
| 2462 | + | |
| 2463 | + | |
| 2464 | + | |
| 2465 | + | |
| 2466 | + | |
| 2467 | + | |
| 2468 | + | |
| 2469 | + | |
| 2470 | + | |
| 2471 | + | |
| 2472 | + | |
| 2473 | + | |
| 2474 | + | |
| 2475 | + | |
| 2476 | + | |
| 2477 | + | |
| 2478 | + | |
| 2479 | + | |
| 2480 | + | |
| 2481 | + | |
| 2482 | + | |
| 2483 | + | |
| 2484 | + | |
| 2485 | + | |
| 2486 | + | |
| 2487 | + | |
| 2488 | + | |
| 2489 | + | |
| 2490 | + | |
| 2491 | + | |
| 2492 | + | |
| 2493 | + | |
| 2494 | + | |
| 2495 | + | |
| 2496 | + | |
| 2497 | + | |
| 2498 | + | |
| 2499 | + | |
| 2500 | + | |
| 2501 | + | |
| 2502 | + | |
| 2503 | + | |
| 2504 | + | |
| 2505 | + | |
| 2506 | + | |
| 2507 | + | |
| 2508 | + | |
| 2509 | + | |
| 2510 | + | |
| 2511 | + | |
| 2512 | + | |
| 2513 | + | |
| 2514 | + | |
| 2515 | + | |
| 2516 | + | |
| 2517 | + | |
| 2518 | + | |
| 2519 | + | |
2295 | 2520 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
279 | 279 | | |
280 | 280 | | |
281 | 281 | | |
282 | | - | |
| 282 | + | |
283 | 283 | | |
284 | 284 | | |
285 | 285 | | |
| |||
294 | 294 | | |
295 | 295 | | |
296 | 296 | | |
297 | | - | |
| 297 | + | |
298 | 298 | | |
299 | 299 | | |
300 | 300 | | |
301 | 301 | | |
302 | | - | |
| 302 | + | |
303 | 303 | | |
304 | 304 | | |
305 | 305 | | |
| |||
337 | 337 | | |
338 | 338 | | |
339 | 339 | | |
340 | | - | |
| 340 | + | |
341 | 341 | | |
342 | 342 | | |
343 | 343 | | |
| |||
0 commit comments