Skip to content

fix(groovy): emit inherits/implements edges for extends/implements#1534

Closed
Synvoya wants to merge 1 commit into
Graphify-Labs:v8from
Synvoya:fix/groovy-inheritance-edges
Closed

fix(groovy): emit inherits/implements edges for extends/implements#1534
Synvoya wants to merge 1 commit into
Graphify-Labs:v8from
Synvoya:fix/groovy-inheritance-edges

Conversation

@Synvoya

@Synvoya Synvoya commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Summary

The Groovy extractor silently drops every extends and implements relationship. contains, methods, imports, and calls all work — but class inheritance produces no edges.

Root cause

tree-sitter-groovy exposes inheritance through the same grammar shape as tree-sitter-java:

class_declaration <superclass=superclass, interfaces=super_interfaces>
  superclass        -> extends + type_identifier
  super_interfaces  -> implements + type_list -> type_identifier

But the inheritance-emitting block in _extract_generic is gated on config.ts_module == "tree_sitter_java". Groovy (ts_module="tree_sitter_groovy") never enters it — it was the only class-based JVM language in the file without an inheritance handler (Java, Kotlin, Scala, C#, Swift, C++, PHP, Python all have one).

Fix

Widen the gate to include tree_sitter_groovy. The existing _emit_java_parent_type / _java_collect_type_refs path consumes the identical node shapes verbatim — no new handler needed.

-            if config.ts_module == "tree_sitter_java":
+            if config.ts_module in ("tree_sitter_java", "tree_sitter_groovy"):

Verification

  • Added a base class + interface to the Groovy fixture and two regression tests (extends -> inherits, implements -> implements).
  • pytest tests/test_languages.py -> 269 passed, 13 skipped (was 267 + my 2 new); Java inheritance tests unaffected (the shared path is reused, not changed).
  • ruff check --config pyproject.toml -> clean.

Before / after

class UserService extends Base implements Repo {}

  • before: only contains edges
  • after: inherits UserService->Base, implements UserService->Repo

tree-sitter-groovy exposes inheritance via the same `superclass` and
`interfaces`/`type_list` fields as tree-sitter-java, but the inheritance-
emitting block in `_extract_generic` was gated on
`ts_module == "tree_sitter_java"`. Groovy was the only class-based JVM
language in the file with no inheritance handler, so every Groovy
`extends`/`implements` was silently dropped (contains/methods/imports/calls
were unaffected).

Widen the gate to include `tree_sitter_groovy`; the existing
`_emit_java_parent_type` path handles the identical node shapes verbatim.
Adds a base class + interface to the Groovy fixture and two regression
tests (extends -> inherits, implements -> implements).

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

Copy link
Copy Markdown
Collaborator

Merged into v8 as 64a6093 (your authorship). Confirmed the Java handler consumes the Groovy superclass/super_interfaces node shapes verbatim — extends→inherits and implements→implements both emit, Java inheritance tests unaffected. Clean one-line gate reuse. Full suite green. Ships next release.

@safishamsi safishamsi closed this Jul 1, 2026
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.

3 participants