feat: Java, Kotlin, and Swift component extraction#29
Open
bionicles wants to merge 1 commit into
Open
Conversation
Java and Swift are tree-sitter formatters (treesitter/java.rs,
treesitter/swift.rs) emitting source-text slices validated by the legacy
mini-patterns: Java's annotation/class/method/two-word-prototype rules
with the ' {\n' body gate, Swift's column-0 type headers and
modifier-free func/init signatures.
Kotlin is a procedural line scanner (extract/kotlin.rs): the community
grammar (tree-sitter-kotlin-ng) cannot recover from the deliberately
invalid constructs in the acceptance fixture — one ERROR node swallows
the rest of the file — while the legacy pattern is line-anchored and
keeps going. The scanner reproduces the legacy semantics: type headers
captured to a brace/blank-line/column-0 stop, last-'fun '-first matching
with the ' -> Word)' tail that preserves function-type parameters, enum
entry lines fused onto the following fun, and the strip-comments-then-
rstrip ordering whose interplay decides whether a closing paren survives
a trailing line comment.
All three fixture component sets match the legacy goldens byte-for-byte;
trees_v1 goldens regenerated with the three parsers unstubbed. Deep-
nesting robustness tests extended to the new languages. All visitors use
explicit heap stacks (no AST-depth recursion).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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 the "mobile gang" languages to the Rust port (item 1 of the post-port roadmap; closes part of #7's language list).
What
treesitter/java.rs): tree-sitter formatter. Reproduces the legacy combined-regex semantics: annotations (@Namelines, legacy charset truncation), classes ((public )?(abstract )?class ... extends ... implements ...),interface NAME, methods/constructors gated on a literal` {\n`after the signature, and the two-word bodyless-prototype rule (public String f();never matched — preserved).treesitter/swift.rs): tree-sitter formatter. Column-0 type headers (class/struct/protocol/enumkeyword-first, sopublic classis skipped — legacy rule), modifier-freefunc/initsignatures with optional-> T, raw multi-line parameter formatting preserved.extract/kotlin.rs): procedural line scanner, NOT tree-sitter. tree-sitter-kotlin-ng cannot recover from the deliberately invalid constructs in the acceptance fixture (ages: Array<Int>(42),) — one ERROR node swallows the rest of the file — while the legacy pattern is line-anchored and keeps going. The scanner reproduces type-header capture with brace/blank-line/column-0 stops, last-fun-first matching, the-> Word)tail that keeps function-type parameters intact, enum-entry fusion (PLUS {+ followingfun), and the strip-comments-then-rstrip ordering.Acceptance
JavaTest.java,KotlinTest.kt,swift_test.swiftcomponent sets match the legacy goldens byte-for-byte (now enforced bygolden_parity.rs—.java/.kt/.swiftadded to v1 scope).trees_v1goldens regenerated with the three parsers unstubbed; all 13 tree-render parity tests pass.cargo +stable clippy -D warningsclean, fmt clean.Notes
tree-sitter-java 0.23andtree-sitter-swift 0.7; no Kotlin grammar dependency.🤖 Generated with Claude Code