-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
fix(java): close parsing-layer coverage gaps F35/F38/F41 (#1928) #2045
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
magyargergo
merged 5 commits into
abhigyanpatwari:main
from
Sweetdevil144:fix/java-1928-parsing-layer-coverage
Jun 5, 2026
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
0f9415c
fix(java): close parsing-layer coverage gaps F35/F38/F41 (#1928)
Sweetdevil144 816321d
fix(scope-resolution): register Constructor overload keys so this()/s…
Sweetdevil144 500db05
Merge branch 'main' into fix/java-1928-parsing-layer-coverage
Sweetdevil144 2c49894
Merge branch 'main' into fix/java-1928-parsing-layer-coverage
magyargergo aaea9ee
fix(java): update fingerprint and add notes for constructor query cap…
Sweetdevil144 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
gitnexus/test/fixtures/lang-resolution/java-explicit-constructor/models/Base.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| package models; | ||
|
|
||
| public class Base { | ||
| public Base(int x) {} | ||
| } |
11 changes: 11 additions & 0 deletions
11
gitnexus/test/fixtures/lang-resolution/java-explicit-constructor/models/Child.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| package models; | ||
|
|
||
| public class Child extends Base { | ||
| public Child() { | ||
| super(1); | ||
| } | ||
|
|
||
| public Child(int x) { | ||
| this(); | ||
| } | ||
| } |
6 changes: 6 additions & 0 deletions
6
gitnexus/test/fixtures/lang-resolution/java-qualified-constructor/App.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| public class App { | ||
| public void make() { | ||
| pkg.Foo f = new pkg.Foo(); | ||
| new pkg.Box<String>(); | ||
| } | ||
| } |
5 changes: 5 additions & 0 deletions
5
gitnexus/test/fixtures/lang-resolution/java-qualified-constructor/pkg/Box.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| package pkg; | ||
|
|
||
| public class Box<T> { | ||
| public Box() {} | ||
| } |
7 changes: 7 additions & 0 deletions
7
gitnexus/test/fixtures/lang-resolution/java-qualified-constructor/pkg/Foo.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| package pkg; | ||
|
|
||
| public class Foo { | ||
| public Foo() {} | ||
|
|
||
| public void run() {} | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| /** | ||
| * Java parsing-layer coverage gaps (#1928) — end-to-end resolution. | ||
| * | ||
| * - F35: qualified / qualified-generic constructor calls (`new pkg.Foo()`, | ||
| * `new pkg.Box<String>()`) resolve to the target constructor instead of | ||
| * dropping the edge on a corrupted `pkg.Foo` reference name. | ||
| * - F38: `super(...)` / `this(...)` explicit constructor invocations emit CALLS | ||
| * edges to the superclass / sibling constructor. | ||
| */ | ||
| import { describe, it, expect, beforeAll } from 'vitest'; | ||
| import path from 'path'; | ||
| import { FIXTURES, getRelationships, runPipelineFromRepo, type PipelineResult } from './helpers.js'; | ||
|
|
||
| describe('Java qualified constructor resolution (F35 #1928)', () => { | ||
| let result: PipelineResult; | ||
|
|
||
| beforeAll(async () => { | ||
| result = await runPipelineFromRepo(path.join(FIXTURES, 'java-qualified-constructor'), () => {}); | ||
| }, 60000); | ||
|
|
||
| it('resolves `new pkg.Foo()` to the Foo constructor', () => { | ||
| const calls = getRelationships(result, 'CALLS'); | ||
| const fooCtor = calls.find((c) => c.target === 'Foo' && c.source === 'make'); | ||
| expect(fooCtor).toBeDefined(); | ||
| expect(fooCtor!.targetLabel).toBe('Constructor'); | ||
| expect(fooCtor!.targetFilePath).toBe('pkg/Foo.java'); | ||
| }); | ||
|
|
||
| it('resolves `new pkg.Box<String>()` to the Box constructor', () => { | ||
| const calls = getRelationships(result, 'CALLS'); | ||
| const boxCtor = calls.find((c) => c.target === 'Box' && c.source === 'make'); | ||
| expect(boxCtor).toBeDefined(); | ||
| expect(boxCtor!.targetLabel).toBe('Constructor'); | ||
| expect(boxCtor!.targetFilePath).toBe('pkg/Box.java'); | ||
| }); | ||
|
|
||
| it('does not emit a CALLS edge to a corrupted `pkg.Foo` / `pkg.Box` name', () => { | ||
| const calls = getRelationships(result, 'CALLS'); | ||
| expect(calls.some((c) => c.target === 'pkg.Foo' || c.target === 'pkg.Box')).toBe(false); | ||
| }); | ||
| }); | ||
|
|
||
| describe('Java explicit constructor invocation resolution (F38 #1928)', () => { | ||
| let result: PipelineResult; | ||
|
|
||
| beforeAll(async () => { | ||
| result = await runPipelineFromRepo(path.join(FIXTURES, 'java-explicit-constructor'), () => {}); | ||
| }, 60000); | ||
|
|
||
| it('resolves `super(1)` in Child() to the Base constructor', () => { | ||
| const calls = getRelationships(result, 'CALLS'); | ||
| const superCall = calls.find((c) => c.target === 'Base' && c.targetLabel === 'Constructor'); | ||
| expect(superCall).toBeDefined(); | ||
| expect(superCall!.source).toBe('Child'); | ||
| expect(superCall!.targetFilePath).toBe('models/Base.java'); | ||
| // Source is the arity-0 `Child()`, where `super(1)` lives. | ||
| expect(superCall!.rel.sourceId).toContain('Child.Child#0'); | ||
| expect(superCall!.rel.targetId).toContain('Base.Base#1'); | ||
| }); | ||
|
|
||
| it('resolves `this()` in Child(int) to a DISTINCT Child constructor (no self-loop)', () => { | ||
| const calls = getRelationships(result, 'CALLS'); | ||
| const thisCall = calls.find( | ||
| (c) => c.target === 'Child' && c.targetLabel === 'Constructor' && c.source === 'Child', | ||
| ); | ||
| expect(thisCall).toBeDefined(); | ||
| expect(thisCall!.targetFilePath).toBe('models/Child.java'); | ||
| // The edge must connect DISTINCT constructors: the caller `Child(int)` (#1) | ||
| // chains to `Child()` (#0). A self-loop (`#0 → #0`) — the bug this PR's | ||
| // review caught (#1928 F38: ctor overload keys missing in node-lookup) — | ||
| // satisfies the name-only match above but must NOT pass here. | ||
| expect(thisCall!.rel.sourceId).not.toBe(thisCall!.rel.targetId); | ||
| expect(thisCall!.rel.sourceId).toContain('Child.Child#1'); | ||
| expect(thisCall!.rel.targetId).toContain('Child.Child#0'); | ||
| }); | ||
| }); | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P2 · reproduced] F38
this()produces a self-loop, and this assertion masks it.Running the pipeline on this fixture,
Child(int x){ this(); }emits CALLSChild()@L3 → Child()@L3(selfLoop=true), not the intendedChild(int)@L7 → Child()@L3— both endpoints collapse onto the firstChildconstructor and the real ctor→ctor edge is lost (super(1)→Baseresolves correctly).This
find(...)matches by name only (source==='Child' && target==='Child'), which a self-loop satisfies, so the suite stays green on a broken edge.Root cause is pre-existing and outside this diff:
scope-resolution/graph-bridge/node-lookup.ts:101-135registers overload-disambiguation keys only forFunction/Method, neverConstructor, so same-name constructors first-wins-collapse to one graph node.Fix: at minimum assert the edge connects distinct constructors (e.g. by
startLine/arity or node id) so this test goes red and exposes the miss; the full fix extends thenode-lookup/idsoverload keys to includeConstructor.