Apache Groovy grammar for tree-sitter (dekobon fork)
Project description
tree-sitter-groovy
Tree-sitter grammar for Apache Groovy — the JVM scripting language used in Jenkins pipelines, Gradle build files, and Spock test specifications.
Published as: @dekobon/tree-sitter-groovy on npm,
dekobon-tree-sitter-groovy on crates.io and PyPI,
github.com/dekobon/tree-sitter-groovy as a Go module / Swift package.
The unscoped name belongs to the upstream comparison grammar linked
below; the C library (no naming conflict) still ships as
libtree-sitter-groovy.
This grammar is purpose-built for Groovy (it does not extend the
tree-sitter-java grammar). It synthesises the best ideas from the
two existing community grammars while closing every operator and
statement gap they left open:
amaanq/tree-sitter-groovy— clean precedence table and shebang handling, but mis-shapes Groovy-specific syntax (Elvis?:, safe navigation?., spread operators, regex=~/==~, traits, exclusive ranges, identity===/!==, spaceship<=>, etc.) as Java-shaped parse trees.murtaza64/tree-sitter-groovy— purpose-built for Groovy, broad operator coverage and slashy strings, but has open bugs around empty block comments, multi-catch, multi-assignment, enums, switch-arrow, and apipeline-at-EOF constraint.
The full design is in SPECIFICATION.md.
Status
Fully functional Groovy 2.x--4.x parser with complete operator coverage, GString interpolation, generics, closures, command chains, and six language bindings. See Known limitations for deferred items.
Operator coverage
Every Groovy operator emits a distinct named node so downstream
tooling can identify each by node kind alone — no MISSING-child
inspection, no tree-shape heuristics. This is the contract that
closes
dekobon/big-code-analysis#246
(Elvis short-circuit counting) and
dekobon/big-code-analysis#247
(all Groovy-specific operator gaps).
| Category | Operators |
|---|---|
| Arithmetic | + - * / % ** ++ -- |
| Relational | < <= > >= == != <=> (spaceship) |
| Identity | === !== |
| Regex | =~ (find) ==~ (match) |
| Logical | && || ! ==> (implication) |
| Bitwise | & | ^ ~ << >> >>> |
| Conditional | ? : (ternary) ?: (Elvis) |
| Assignment | = += -= *= /= %= **= <<= >>= >>>= &= ^= |= ?= (Elvis assign) |
| Range | .. ..< <.. <..< |
| Member access | . ?. ??. (safe chain dot) *. (spread-dot) .& (method pointer) .@ (direct field) :: (method reference) |
| Subscript | [] ?[] (safe index) |
| Spread | *args *: (spread-map) |
| Membership | in !in instanceof !instanceof |
| Coercion | as |
Editor support
Tree-sitter queries (queries/groovy/highlights.scm,
folds.scm, indents.scm, injections.scm) are provided for editor
integration. Slashy and dollar-slashy string bodies inject as regex
for nested regex highlighting.
Recognized file extensions: .groovy, .gradle, .gvy, .gy, and
Jenkinsfile.
Filetype detection
The repo ships ftdetect/groovy.lua and ftplugin/groovy.lua for
Neovim. Neovim's built-in filetype detection already maps *.groovy,
*.gradle, and the bare filename Jenkinsfile to filetype groovy;
the shipped ftdetect/groovy.lua fills the gaps by mapping:
*.gvyand*.gy— declared intree-sitter.jsonbut not in Neovim's defaults.*.jenkinsfile— uncommon (the canonical name isJenkinsfile) but declared intree-sitter.jsonand used by some teams as an editor-detection hook.Jenkinsfile.*variants (Jenkinsfile.ci,Jenkinsfile.release, …) — common in repos with multiple pipelines, not handled by Neovim's built-in detection.
The existing ftplugin/groovy.lua then calls vim.treesitter.start().
Highlighting only renders once the parser binary and
queries/groovy/highlights.scm are registered with nvim-treesitter
(or equivalent) — without that, the start() call is a no-op and the
buffer falls back to non-treesitter highlighting.
For files that don't match any of those (e.g. a hand-named
build-pipeline with no extension), opt in with one of:
-
Modeline at the top of the file:
// vim: set filetype=groovy : -
Per-project autocmd in
.nvim.lua(sourced after:cdinto the project via Neovim's'exrc'). Notevim.fn.getcwd()is evaluated when the autocmd is defined, so this snippet belongs in a per-project config, not a globalinit.lua:vim.api.nvim_create_autocmd({ "BufRead", "BufNewFile" }, { pattern = vim.fn.getcwd() .. "/jenkins/*", callback = function() vim.bo.filetype = "groovy" end, })
Other editors follow the same pattern: rely on built-in detection for the common extensions and override per-directory or via a header comment for the rest.
Building
npm install
make build
make test
Bindings
Available bindings: C, Go, Node.js, Python, Rust, Swift. See
bindings/ for binding-specific READMEs and tests.
For Rust consumers:
[dependencies]
dekobon-tree-sitter-groovy = "0.1"
tree-sitter = "0.25"
let mut parser = tree_sitter::Parser::new();
let language = dekobon_tree_sitter_groovy::LANGUAGE;
parser.set_language(&language.into()).expect("Error loading Groovy parser");
let tree = parser.parse(source, None).unwrap();
Known limitations
These are documented in detail in
docs/divergences-from-spec.md.
- Groovy 5 contextual keywords (
val,async,await,defer) are not yet exposed as keyword tokens. They parse as plain identifiers, matching Groovy 2.x--4.x compiler behavior. - Typed local declarations require an initializer --
String xis ambiguous withString(x)(method call). UseString x = ...ordef xinstead. - Leading-operator line continuation --
a\n+ bgreedily joins asa + brather than splitting into two statements. Idiomatic Groovy places continuation operators at the end of the previous line.
Contributing
See CONTRIBUTING.md for how to build, test, and
submit changes. AGENTS.md covers project conventions
(commit messages, versioning, validation gates) and
SPECIFICATION.md is the authoritative grammar
design document.
Acknowledgements
We are grateful for the work done in the murtaza64/tree-sitter-groovy and amaanq/tree-sitter-groovy. These projects served as inspiration for some of the approaches in this project
License
Dual-licensed under Apache License 2.0 or MIT.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dekobon_tree_sitter_groovy-0.2.0.tar.gz.
File metadata
- Download URL: dekobon_tree_sitter_groovy-0.2.0.tar.gz
- Upload date:
- Size: 350.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7144385c8319c85b406d188f81d497c6599619593605b6d24df290e69f834aeb
|
|
| MD5 |
218886b01f056cc22a19acc8f2ce21d4
|
|
| BLAKE2b-256 |
f309b643d458b44e7a3d8bfea96af8a64789ff195557f6b57ea24284c46feed3
|
Provenance
The following attestation bundles were made for dekobon_tree_sitter_groovy-0.2.0.tar.gz:
Publisher:
release.yml on dekobon/tree-sitter-groovy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dekobon_tree_sitter_groovy-0.2.0.tar.gz -
Subject digest:
7144385c8319c85b406d188f81d497c6599619593605b6d24df290e69f834aeb - Sigstore transparency entry: 1574364981
- Sigstore integration time:
-
Permalink:
dekobon/tree-sitter-groovy@ff44ab5d86d663364cf8e765dc1f17f2b78b02e8 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/dekobon
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@ff44ab5d86d663364cf8e765dc1f17f2b78b02e8 -
Trigger Event:
push
-
Statement type:
File details
Details for the file dekobon_tree_sitter_groovy-0.2.0-cp38-abi3-win_amd64.whl.
File metadata
- Download URL: dekobon_tree_sitter_groovy-0.2.0-cp38-abi3-win_amd64.whl
- Upload date:
- Size: 113.8 kB
- Tags: CPython 3.8+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c3d3542dc6d49982999da7fad33b710e0cbed48e69634fb16a9a7a8c93c57f5d
|
|
| MD5 |
e3641fb42dc71ca4d045c9d7a896c36c
|
|
| BLAKE2b-256 |
e2f6841169c752832d28c87aacf7057b7943d940947d26cd95065c33fa0c53ad
|
Provenance
The following attestation bundles were made for dekobon_tree_sitter_groovy-0.2.0-cp38-abi3-win_amd64.whl:
Publisher:
release.yml on dekobon/tree-sitter-groovy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dekobon_tree_sitter_groovy-0.2.0-cp38-abi3-win_amd64.whl -
Subject digest:
c3d3542dc6d49982999da7fad33b710e0cbed48e69634fb16a9a7a8c93c57f5d - Sigstore transparency entry: 1574365025
- Sigstore integration time:
-
Permalink:
dekobon/tree-sitter-groovy@ff44ab5d86d663364cf8e765dc1f17f2b78b02e8 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/dekobon
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@ff44ab5d86d663364cf8e765dc1f17f2b78b02e8 -
Trigger Event:
push
-
Statement type:
File details
Details for the file dekobon_tree_sitter_groovy-0.2.0-cp38-abi3-win32.whl.
File metadata
- Download URL: dekobon_tree_sitter_groovy-0.2.0-cp38-abi3-win32.whl
- Upload date:
- Size: 113.1 kB
- Tags: CPython 3.8+, Windows x86
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
19b327863078faf0fe5902b0c5be613f8313c05cb81c081e421811970e31e943
|
|
| MD5 |
770e4ea73bfb7e61c6b2ca697de61113
|
|
| BLAKE2b-256 |
d2f73604b19a576a24d251e257b0616c163262307e305d3746de8e1452381ddd
|
Provenance
The following attestation bundles were made for dekobon_tree_sitter_groovy-0.2.0-cp38-abi3-win32.whl:
Publisher:
release.yml on dekobon/tree-sitter-groovy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dekobon_tree_sitter_groovy-0.2.0-cp38-abi3-win32.whl -
Subject digest:
19b327863078faf0fe5902b0c5be613f8313c05cb81c081e421811970e31e943 - Sigstore transparency entry: 1574365133
- Sigstore integration time:
-
Permalink:
dekobon/tree-sitter-groovy@ff44ab5d86d663364cf8e765dc1f17f2b78b02e8 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/dekobon
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@ff44ab5d86d663364cf8e765dc1f17f2b78b02e8 -
Trigger Event:
push
-
Statement type:
File details
Details for the file dekobon_tree_sitter_groovy-0.2.0-cp38-abi3-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: dekobon_tree_sitter_groovy-0.2.0-cp38-abi3-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 139.5 kB
- Tags: CPython 3.8+, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0b23b6f6d412c37d422768b29fc92b21570baea53621683f59eae19ba70d35a5
|
|
| MD5 |
d64091ed970a9dd946b02c8e9f4e67d4
|
|
| BLAKE2b-256 |
cdf029e648ca3d0251dfc48ab3df5b2020af83480c5cb0bf38607b6d64ae0cac
|
Provenance
The following attestation bundles were made for dekobon_tree_sitter_groovy-0.2.0-cp38-abi3-musllinux_1_2_x86_64.whl:
Publisher:
release.yml on dekobon/tree-sitter-groovy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dekobon_tree_sitter_groovy-0.2.0-cp38-abi3-musllinux_1_2_x86_64.whl -
Subject digest:
0b23b6f6d412c37d422768b29fc92b21570baea53621683f59eae19ba70d35a5 - Sigstore transparency entry: 1574365152
- Sigstore integration time:
-
Permalink:
dekobon/tree-sitter-groovy@ff44ab5d86d663364cf8e765dc1f17f2b78b02e8 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/dekobon
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@ff44ab5d86d663364cf8e765dc1f17f2b78b02e8 -
Trigger Event:
push
-
Statement type:
File details
Details for the file dekobon_tree_sitter_groovy-0.2.0-cp38-abi3-musllinux_1_2_i686.whl.
File metadata
- Download URL: dekobon_tree_sitter_groovy-0.2.0-cp38-abi3-musllinux_1_2_i686.whl
- Upload date:
- Size: 139.3 kB
- Tags: CPython 3.8+, musllinux: musl 1.2+ i686
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
127650e50febb3596e756b9928698333227545af881fb6b168b83d0854f43af9
|
|
| MD5 |
aaf8445aee09f174df85d331577bbcd3
|
|
| BLAKE2b-256 |
ba02defb3295dc57cd98b202ea5e3bbaf120f07a292da5576960ab6c0f6dad06
|
Provenance
The following attestation bundles were made for dekobon_tree_sitter_groovy-0.2.0-cp38-abi3-musllinux_1_2_i686.whl:
Publisher:
release.yml on dekobon/tree-sitter-groovy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dekobon_tree_sitter_groovy-0.2.0-cp38-abi3-musllinux_1_2_i686.whl -
Subject digest:
127650e50febb3596e756b9928698333227545af881fb6b168b83d0854f43af9 - Sigstore transparency entry: 1574365107
- Sigstore integration time:
-
Permalink:
dekobon/tree-sitter-groovy@ff44ab5d86d663364cf8e765dc1f17f2b78b02e8 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/dekobon
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@ff44ab5d86d663364cf8e765dc1f17f2b78b02e8 -
Trigger Event:
push
-
Statement type:
File details
Details for the file dekobon_tree_sitter_groovy-0.2.0-cp38-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: dekobon_tree_sitter_groovy-0.2.0-cp38-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 139.9 kB
- Tags: CPython 3.8+, manylinux: glibc 2.17+ x86-64, manylinux: glibc 2.5+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0f71ceeaf2199e78ad5b9bc0eab8fab04bec430024415b6b38a9a788a50d44ca
|
|
| MD5 |
22dd56b51ce6e61d645e3761ac6508c0
|
|
| BLAKE2b-256 |
b855450feb0bdf8def06a89dad243b6672b9e44695187c33a5922dc19a42ca2b
|
Provenance
The following attestation bundles were made for dekobon_tree_sitter_groovy-0.2.0-cp38-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
release.yml on dekobon/tree-sitter-groovy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dekobon_tree_sitter_groovy-0.2.0-cp38-abi3-manylinux1_x86_64.manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_5_x86_64.whl -
Subject digest:
0f71ceeaf2199e78ad5b9bc0eab8fab04bec430024415b6b38a9a788a50d44ca - Sigstore transparency entry: 1574365045
- Sigstore integration time:
-
Permalink:
dekobon/tree-sitter-groovy@ff44ab5d86d663364cf8e765dc1f17f2b78b02e8 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/dekobon
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@ff44ab5d86d663364cf8e765dc1f17f2b78b02e8 -
Trigger Event:
push
-
Statement type:
File details
Details for the file dekobon_tree_sitter_groovy-0.2.0-cp38-abi3-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl.
File metadata
- Download URL: dekobon_tree_sitter_groovy-0.2.0-cp38-abi3-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
- Upload date:
- Size: 140.5 kB
- Tags: CPython 3.8+, manylinux: glibc 2.17+ i686, manylinux: glibc 2.5+ i686
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
78e99349da4159ec21dfc18125fd59425f98fb24526bfaa3da5662bf704e862f
|
|
| MD5 |
4c042597986a767b8a46ada243c1cea1
|
|
| BLAKE2b-256 |
9ad03b124d6f10f6c5f5c19fa1c32d7081484f137e554449f28719ce6f41caba
|
Provenance
The following attestation bundles were made for dekobon_tree_sitter_groovy-0.2.0-cp38-abi3-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl:
Publisher:
release.yml on dekobon/tree-sitter-groovy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dekobon_tree_sitter_groovy-0.2.0-cp38-abi3-manylinux1_i686.manylinux2014_i686.manylinux_2_17_i686.manylinux_2_5_i686.whl -
Subject digest:
78e99349da4159ec21dfc18125fd59425f98fb24526bfaa3da5662bf704e862f - Sigstore transparency entry: 1574365009
- Sigstore integration time:
-
Permalink:
dekobon/tree-sitter-groovy@ff44ab5d86d663364cf8e765dc1f17f2b78b02e8 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/dekobon
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@ff44ab5d86d663364cf8e765dc1f17f2b78b02e8 -
Trigger Event:
push
-
Statement type:
File details
Details for the file dekobon_tree_sitter_groovy-0.2.0-cp38-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: dekobon_tree_sitter_groovy-0.2.0-cp38-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 119.9 kB
- Tags: CPython 3.8+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e66c7b9029131e95a4723203a182577b244e603460ee27780508a0e412ab482d
|
|
| MD5 |
62c5593f4ec5a35ea042bccd577a46bb
|
|
| BLAKE2b-256 |
9b2d2eb2e7b22101dc7bc249904c92d4127051bf81bd5a62ee1427e7cfb36cab
|
Provenance
The following attestation bundles were made for dekobon_tree_sitter_groovy-0.2.0-cp38-abi3-macosx_11_0_arm64.whl:
Publisher:
release.yml on dekobon/tree-sitter-groovy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dekobon_tree_sitter_groovy-0.2.0-cp38-abi3-macosx_11_0_arm64.whl -
Subject digest:
e66c7b9029131e95a4723203a182577b244e603460ee27780508a0e412ab482d - Sigstore transparency entry: 1574365069
- Sigstore integration time:
-
Permalink:
dekobon/tree-sitter-groovy@ff44ab5d86d663364cf8e765dc1f17f2b78b02e8 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/dekobon
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@ff44ab5d86d663364cf8e765dc1f17f2b78b02e8 -
Trigger Event:
push
-
Statement type: