Skip to content

fix(extract): emit Java generic parent relationships#1511

Closed
oleksii-tumanov wants to merge 1 commit into
Graphify-Labs:v8from
oleksii-tumanov:fix/java-generic-inheritance
Closed

fix(extract): emit Java generic parent relationships#1511
oleksii-tumanov wants to merge 1 commit into
Graphify-Labs:v8from
oleksii-tumanov:fix/java-generic-inheritance

Conversation

@oleksii-tumanov

Copy link
Copy Markdown
Contributor

Summary

  • emit inherits and implements edges for parameterized Java parents
  • emit generic_arg references for parent type arguments and cover class and interface cases

Fixes #1510

Result

Label-normalized relevant edges from the final patch:

[
  {
    "source": "Service",
    "target": "Base",
    "relation": "inherits",
    "confidence": "EXTRACTED"
  },
  {
    "source": "Service",
    "target": "Dependency",
    "relation": "references",
    "confidence": "EXTRACTED",
    "context": "generic_arg"
  },
  {
    "source": "Service",
    "target": "Handler",
    "relation": "implements",
    "confidence": "EXTRACTED"
  },
  {
    "source": "Service",
    "target": "Event",
    "relation": "references",
    "confidence": "EXTRACTED",
    "context": "generic_arg"
  }
]

Testing

  • uv run --frozen pytest tests/test_languages.py -q -k java_generic_parents (1 passed)
  • uv run --frozen pytest tests/ -q --tb=short (2442 passed, 28 skipped)
  • uv run --frozen ruff check graphify/extract.py tests/test_languages.py (passed)

safishamsi pushed a commit that referenced this pull request Jun 28, 2026
A generic parent — `class Foo extends Bar<T>` or `implements List<T>` — is a
`generic_type` node in the tree, but the inheritance extractor only fired on a
bare `type_identifier`, so those inherits/implements edges were silently dropped.
The parent type is now unwrapped to its base (`Bar<T>` -> `Bar`) for the
inherits/implements edge, and the type arguments are emitted as `generic_arg`
references.

Ported from PR #1511 by @oleksii-tumanov. Known pre-existing limitation (not
introduced here, worth a separate follow-up): the extractor has no type-parameter
tracking, so a bare parameter like `T` in `extends Container<T>` still produces a
`generic_arg` reference to `T`; the inherits/implements edge itself always targets
the real base type, never `T`.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@safishamsi

Copy link
Copy Markdown
Collaborator

Thanks @oleksii-tumanov — confirmed the bug (generic parents are generic_type nodes, so the inherits/implements edge was dropped) and the fix (unwrap to the base type, type args as generic_arg). Verified edges target the base, never the Bar<...> wrapper. Landed on v8 in 1f3f1c1 with your authorship. One pre-existing limitation noted in the commit (a bare type parameter T still gets a generic_arg ref — the extractor has no type-param tracking anywhere; worth a separate follow-up, not introduced here). Closing as merged-by-port.

@safishamsi safishamsi closed this Jun 28, 2026
safishamsi pushed a commit that referenced this pull request Jun 28, 2026
The generic-parent support (#1511) emitted a spurious references/generic_arg edge
(and a sourceless stub node) for a bare type parameter — the T in
`class Box<T> extends Container<T>` — because the Java extractor had no type-
parameter tracking. _java_collect_type_refs now collects the in-scope type-
parameter names (walking class/interface/record/method/constructor declarations,
including bounded and multiple params) and skips references to them, while keeping
every real type. Scoped to the declaring node, so a real class that shares a name
with a type parameter elsewhere is still referenced.

Ported from PR #1518 by @oleksii-tumanov. Closes the nit flagged when #1511 landed.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Java generic parents are skipped during inheritance extraction

2 participants