feat: Add Java language support - #53
Open
jhouserizer wants to merge 1 commit into
Open
Conversation
Adds tree-sitter-java (v0.21.0, peer-compatible with tree-sitter@0.21.x) and implements Java extraction in the Tier-1 code graph. Supported constructs: - class, interface, record, enum, annotation type declarations (record -> class kind; @interface -> interface kind) - method, constructor, annotation element declarations (interface/abstract methods with no body) - superclass (extends) + super_interfaces (implements) heritage edges - extends_interfaces on interfaces (extends -> interface edges) - implements on enums (super_interfaces only, no extends) - import_declaration imports (scoped_identifier path, incl. wildcard `.*`) - method_invocation calls with member_access / field_access / this resolution - visibility detection (public modifier = exported) - field, local variable, parameter, varargs, try-with-resources, enhanced-for, and catch parameter type bindings (incl. var/new X() fallback) - generic_type and array_type unwrapping for bare type-name extraction (com.example.Base<Bar> -> Base; Foo[] -> Foo) - JDK collection / utility types in the builtin-container blocklist (List, Map, String, etc.) so their methods never wire to repo symbols - build.gradle.kts scope marker (Kotlin-DSL Gradle) alongside pom.xml / build.gradle Files changed: - package.json: tree-sitter-java@^0.21.0 dependency - src/graph/extract.ts: Language type, languageOf, JAVA_KINDS, GRAMMARS, describeJava, heritageEdges (java branch), calleeName (java branch), javaReceiver, isImport, importSpecifier, javaExported, javaTypeName - src/graph/bindings.ts: defName, isClassNode, handleJava dispatch, handleJava, javaTypeName, javaNewTypeName - src/graph/types.ts: Kind type comments updated for Java - src/graph/scopes.ts: pom.xml + build.gradle + build.gradle.kts project markers - src/graph/resolve.ts: Java builtin container types; bare Java calls search method kind (Java has no function kind) - test/graph-java.test.ts: 19 test cases covering classes/interfaces/enums/ records, methods/constructors/visibility, heritage edges (class/interface/ enum/annotation/generic/scoped-generic), call edges (member + receiver resolution, bare/static calls, this-qualified in enum/interface methods), import edges (incl. wildcard), contains edges, varargs, try-with-resources, enhanced-for, catch parameter binding Verified: 538/539 tests pass on this repo (the 1 failure is a pre-existing flaky lock-release test unrelated to this change). TypeScript build clean. Tested end-to-end on spring-framework (9,192 .java files): 121,316 nodes, 303,946 edges, 100,866 call edges all resolved, 0 parse errors.
jhouserizer
force-pushed
the
feat/java-language-support
branch
from
August 5, 2026 14:47
d697cce to
22e493b
Compare
|
This PR is working without any errors for me. Thanks ! |
|
Can you update this PR and resolved conflicts ? |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Adds
tree-sitter-java(v0.21.0, peer-compatible withtree-sitter@0.21.x) and implements Java extraction in the Tier-1 code graph, bringing Java to parity with the existing TypeScript/Python/Go support.What's supported
Definitions (nodes)
class,interface,record,enum, and@interface(annotation type) declarationsrecord→classkind;@interface→interfacekindmethodandconstructordeclarations, including interface/abstract methods with no body and annotation elements (String value() default "";)Edges
extends(superclass) +implements(super_interfaces) on classes;extends(extends_interfaces) on interfaces;implementson enumsmethod_invocationwith receiver resolution viathis,this.x, bare identifiers, andfield_accessimport_declaration(scoped_identifier path, incl. wildcard.*and static imports)Bindings (receiver-type resolution)
Foo... args), try-with-resources, enhanced-for loop variables, and catch parametersvar/new X()initializer fallback when no type annotation is presentgeneric_typeandarray_typeunwrapping to bare names (com.example.Base<Bar>→Base;Foo[]→Foo)Visibility:
publicmodifier →exported: true(matching the existing C#/TS rule)Resolution: JDK collection/utility types (
List,Map,String,Exception, …) added to the builtin-container blocklist so their methods never wire to repo symbols; bare Java calls searchmethodkind (Java has nofunctionkind)Scopes:
pom.xml,build.gradle, andbuild.gradle.ktsproject markersVerification
Tests
test/graph-java.test.tscovering classes/interfaces/enums/records, methods/constructors/visibility, heritage edges (class/interface/enum/annotation/generic/scoped-generic), call edges (member + receiver resolution, bare/static calls, this-qualified in enum/interface methods), import edges (incl. wildcard), contains edges, varargs, try-with-resources, enhanced-for, and catch parameter bindingEnd-to-end on spring-framework and quartz-scheduler (large/modest sized popular Java repos)
Built the graph for
spring-projects/spring-framework(9,192.javafiles) end-to-end:@interface)interfacekindUnresolved
extends/implementstargets are external JDK types (RuntimeException,Exception,Serializable, …) — expected and correct.graft ask,graft skeleton, andgraft mapall return correct, useful results on the generated graph.Files changed
package.json/package-lock.jsontree-sitter-java@^0.21.0dependencysrc/graph/extract.tsLanguagetype,languageOf,JAVA_KINDS,GRAMMARS,describeJava,heritageEdges(java branch),calleeName(java branch),javaReceiver,isImport,importSpecifier,javaExported,javaTypeNamesrc/graph/bindings.tsdefName,isClassNode,handleJavadispatch,handleJava,javaTypeName,javaNewTypeNamesrc/graph/types.tsKindtype comments updated for Javasrc/graph/scopes.tspom.xml+build.gradle+build.gradle.ktsproject markerssrc/graph/resolve.tsmethodkindtest/graph-java.test.tsNotes
tree-sitter-java), version-pinned to^0.21.0fortree-sitter@0.21.xcompatibility.ctx.lang === "java".javaTypeNamehelper is duplicated acrossextract.tsandbindings.ts(not imported) per the existing no-value-import-of-extract rule that keepsbindings.tsfree of a value import onextract.ts.