GitNexus/gitnexus/test
Gergő Magyar 66f9ec8eff
feat(java): add Java to MIGRATED_LANGUAGES with 100% scope-resolution parity (#1805)
* feat(java): add Java to MIGRATED_LANGUAGES with 100% scope-resolution parity

Route Java through the scope-resolution pipeline instead of the legacy
single-threaded call processor, fixing the analyze hang on large Java
codebases (issue #1741).

Changes:
- Add Java to MIGRATED_LANGUAGES (registry-primary-flag.ts)
- Add tree-sitter queries for var type inference (call-result, alias,
  field-access, enhanced-for), instanceof/switch pattern bindings,
  and method references (User::getName, this::save, User::new)
- Fix importedName to use simple class name instead of FQN so
  finalize binding materialization matches correctly
- Implement buildJavaMro with IMPLEMENTS edge transitive closure
  for interface default method resolution
- Implement populateJavaPackageSiblings for same-package implicit
  class visibility across files
- Implement cross-file return-type mirroring from imported class
  files via populateRangeBindings hook
- Add var type binding post-processing in captures.ts to resolve
  call-result and alias chains from same-file return types
- Add variable-aware argument type inference for overload resolution
- Fix pickConstructorOrClass to walk child scopes for Constructor
  defs (scope-resolution places them in Function scopes)
- Remove over-aggressive field_access suppression in shouldEmitReadMember
  so ACCESSES edges emit for field steps in method chains
- Enable collapseMemberCallsByCallerTarget for legacy parity
- Update unit tests to use Ruby as unmigrated language example

Parity: 178/178 integration tests pass in both registry-primary
and legacy modes.

* fix(java): address code review findings for scope-resolution migration

- pickConstructorOrClass: skip inner Class scopes when walking
  children for Constructor defs (prevents resolving to wrong
  constructor in nested-class scenarios)
- populateJavaCrossFileReturnTypes: filter out parameter-annotation
  bindings from class-scope mirroring to prevent foreign parameter
  types from shadowing local variables
- resolveVarTypeBindings: detect ambiguous names (overloaded methods
  with different return types, same-named variables across scopes)
  and skip resolution rather than last-write-wins
- sharedPrefixLength renamed to sharedSegmentCount: segment-based
  directory proximity for deterministic sort ordering
- Add MAX_PACKAGE_FILES cap (500) to skip O(N^2) package-siblings
  injection for pathologically large packages

* perf(java): optimize hot paths in scope-resolution migration

- Replace O(D^2) list.some() dedup with O(1) Set lookup in
  populateJavaPackageSiblings binding injection
- Replace queue.shift() O(N) with index-based O(1) iteration
  in closeInterfaces BFS traversal
- Cache sharedSegmentCount results per file in sort comparator
  to avoid redundant path splitting

* perf(ingestion): skip deferred accumulation for registry-primary languages

The legacy call/import/heritage processing path accumulates extracted
data from ALL files during the parse phase, then skips registry-primary
files one-by-one during processing.  For a 25K-file Java codebase this
wastes ~150 MB holding calls that are never consumed.

Gate the accumulation with a per-chunk file-path cache: calls, imports,
heritage, constructor bindings, and assignments for registry-primary
languages (Java, Python, TypeScript, Go, C#, C, C++, PHP, JavaScript,
Kotlin) are no longer pushed into the deferred arrays.  The scope-
resolution pipeline handles these languages independently.

Verified: 2258/2258 resolver integration tests pass across all languages.

* fix(java): address Codex adversarial review findings

- Cross-file return binding: detect ambiguous method names across
  imported classes (two classes with same-named methods but different
  return types) and delete the binding rather than first-wins
- Package-siblings: only inject top-level classes (parent is Module
  scope) to prevent nested/inner classes from leaking to package scope
- Add diagnostic log when MAX_PACKAGE_FILES cap fires so operators
  know same-package visibility was disabled for a large package

* fix(test): force REGISTRY_PRIMARY_JAVA=false in legacy call-processor unit tests

Three call-processor test suites use .java file paths to exercise
legacy DAG features (MRO fast path, interface dispatch, class lookup
fallback).  Now that Java is in MIGRATED_LANGUAGES, the call-processor
skips Java files.  Force the flag off in beforeEach/afterEach so the
legacy path runs, matching the existing Python pattern in the same file.

---------

Co-authored-by: Test <test@example.com>
2026-05-24 14:29:26 +01:00
..
fixtures feat(lang-kotlin): flip Kotlin to MIGRATED_LANGUAGES + close #1756 / #1757 (refs #1746) (#1782) 2026-05-23 07:24:35 +01:00
helpers fix(test): retry Windows temp cleanup in cli-e2e teardown (#1688) 2026-05-18 18:17:54 +01:00
integration fix(lbug): skip init lock and filesystem mutations for read-only opens (#1783) (#1784) 2026-05-24 08:05:27 +01:00
unit feat(java): add Java to MIGRATED_LANGUAGES with 100% scope-resolution parity (#1805) 2026-05-24 14:29:26 +01:00
utils fix: skip Claude augment hook when GitNexus server owns DB (#1493) 2026-05-14 16:39:30 +01:00