feat(lang-java): add @ctxo/lang-java syntax-tier plugin#74
Open
utafrali wants to merge 1 commit into
Open
Conversation
Implements the Java language plugin against Plugin API v1, scoped to syntax tier. Built on tree-sitter-java. Detection wiring (pom.xml, build.gradle, .java) was already in place in @ctxo/cli — no CLI changes needed. Coverage: - Symbols: classes, interfaces, enums, records, methods, constructors. Nested types are qualified Outer.Inner. Methods are qualified Outer.method. - Edges: imports (with wildcard skip and static-import normalization), extends, implements. Edge targets are name-keyed and resolved against the cross-file symbol registry, matching the convention used by @ctxo/lang-csharp so the SymbolGraph fuzzy resolver binds them to real symbols. - Cyclomatic complexity: counts if, for, enhanced_for, while, do, switch_label, catch_clause, ternary_expression, and &&/|| short-circuits. Validation: - 29/29 unit tests pass (including a registry-resolution test confirming cross-file extends/implements bind to real symbol IDs) - E2E demo on a 3-file Maven project: implements edge from PercentageDiscount resolves to src/.../Discount.java::Discount::interface (RESOLVED, not dangling) — verified by joining edges → symbols in the SQLite cache. Out of scope (tracked as separate issues): - full tier (JDT/javac) — Go composite pattern as reference - Sealed permits, enum constants with bodies, initializer blocks, anonymous inner classes — require new SymbolKind/EdgeKind values in @ctxo/plugin-api - Doctor language-coverage-check.ts resolves require from CLI dist instead of consumer project root; pre-existing CLI bug surfaces as a spurious "missing plugins for: java" warning even when the plugin loads correctly - TreeSitterAdapter and logger duplication across lang-go / lang-csharp / lang-java — promote to a shared package - runtime-check.ts and index-command.ts hardcoded language tables
This was referenced Apr 19, 2026
Owner
|
Lets discuss open questions. |
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.
Summary
Adds
@ctxo/lang-java— a Java language plugin built ontree-sitter-java, scoped totier: 'syntax'. Detection wiring (pom.xml,build.gradle,build.gradle.kts,.java) was already in place in@ctxo/cli, so no CLI changes are needed.Coverage
Outer.Inner); methods are qualified by enclosing type (Outer.method); constructors asClassName.ClassName.imports(with wildcard skip and static-import normalization),extends,implements(includinginterface extends). Edge targets are name-keyed and resolved against the cross-file symbol registry — same convention as@ctxo/lang-csharp, soSymbolGraph.resolveNodeIdbinds them to real symbols on indexed targets.if,for,enhanced_for,while,do,switch_label,catch_clause,ternary_expression, plus&&/||short-circuit operators.Validation
__unresolved__sentinel removal)pom.xml+ 3.javafiles):implementsedge fromPercentageDiscountresolves tosrc/main/java/com/example/shop/Discount.java::Discount::interface— verified by joiningedges → symbolsin the SQLite cache. No dangling targets.pnpm typecheckclean;pnpm buildproducesdist/index.js(13.7 KB) +dist/index.d.ts(3.5 KB)Test plan
npm install -D @ctxo/lang-java, thenctxo init+ctxo indexextends/implementsedges (no__unresolved__::sentinel anywhere)Out of scope (tracked as separate follow-up issues)
fulltier (JDT/javac analyzer) for resolvedcalls/usesedges@ctxo/plugin-api: extendSymbolKind/EdgeKindto support sealedpermits, enum constants with bodies, initializer blocks, anonymous inner classesdoctorlanguage-coverage-check.tsresolver bug (pre-existing, not Java-specific): surfaces as a spuriousmissing plugins for: javawarning even when the plugin loads correctlyTreeSitterAdapterand namespaced logger to a shared package (lang-go, lang-csharp, lang-java duplicate them today)runtime-check.tsandindex-command.tsProcess notes
.changeset/add-lang-java.md) for aminorbump on@ctxo/lang-java0.8.0to align with sibling plugins (@ctxo/lang-go@0.8.0,@ctxo/lang-csharp@0.7.2,@ctxo/lang-typescript@0.7.1)peerDependencies: { "@ctxo/plugin-api": "^0.7.1" }matches siblingssite/docs/languages/overview.mdsupport matrix with the Java rowpackages/lang-java/README.mddocuments coverage, edge encoding, and the known limitations from the follow-up issuesReview process
This PR went through three rounds of internal review focused on (a) contract compliance vs. siblings, (b) empirical end-to-end edge resolution, and (c) ecosystem integration. The first draft used an
__unresolved__::Name::kindsentinel for unresolved edge targets — reviewers showed this never matchesSymbolGraph.resolveNodeId's fuzzy lookup. The current encoding mirrors@ctxo/lang-csharp's registry-walk fallback and was verified end-to-end against the demo SQLite (one cross-fileimplementsedge, RESOLVED).