Skip to content

Commit 431f74d

Browse files
feat: initial commit
0 parents  commit 431f74d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+4836
-0
lines changed

.editorconfig

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
indent_size = 4
7+
indent_style = space
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
10+
max_line_length = 120
11+
12+
[LICENSE]
13+
max_line_length = off
14+
15+
[README.md]
16+
indent_size = 2
17+
max_line_length = off
18+
19+
[*.{xml,yml,json}]
20+
indent_size = 2
21+
max_line_length = off

.github/dependabot.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: github-actions
4+
directory: /
5+
schedule:
6+
interval: weekly
7+
day: sunday
8+
commit-message:
9+
prefix: ci
10+
labels: [dependencies]
11+
open-pull-requests-limit: 1
12+
groups:
13+
actions:
14+
patterns: ["*"]
15+
16+
- package-ecosystem: gitsubmodule
17+
directory: /
18+
schedule:
19+
interval: weekly
20+
day: friday
21+
commit-message:
22+
prefix: build
23+
labels: [dependencies]
24+
open-pull-requests-limit: 1
25+
groups:
26+
submodules:
27+
patterns: ["*"]
28+
29+
- package-ecosystem: maven
30+
directory: /
31+
schedule:
32+
interval: weekly
33+
day: saturday
34+
commit-message:
35+
prefix: build
36+
labels: [dependencies]
37+
open-pull-requests-limit: 1

.github/workflows/ci.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [master]
6+
paths:
7+
- src/**
8+
pull_request:
9+
branches: [master]
10+
paths:
11+
- src/**
12+
13+
concurrency:
14+
cancel-in-progress: true
15+
group: ${{github.workflow}}-${{github.ref_name}}
16+
17+
permissions:
18+
contents: write
19+
security-events: write
20+
21+
jobs:
22+
test:
23+
name: Test package
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: Checkout repository
27+
uses: actions/checkout@v4
28+
with:
29+
submodules: true
30+
- name: Set up Java
31+
uses: actions/setup-java@v4
32+
with:
33+
distribution: temurin
34+
java-version: 22
35+
cache: maven
36+
- name: Set up tree-sitter
37+
uses: tree-sitter/setup-action/lib@v1
38+
- name: Set up tree-sitter-java
39+
run: |-
40+
git clone --depth=1 https://github.com/tree-sitter/tree-sitter-java
41+
make -Ctree-sitter-java all install PREFIX="$RUNNER_TOOL_CACHE/tree-sitter/lib"
42+
- name: Set up jextract
43+
run: |-
44+
curl -LSs '${{vars.JEXTRACT_URL}}' | tar xzf - -C "$RUNNER_TOOL_CACHE"
45+
printf '%s/jextract-22/bin\n' "$RUNNER_TOOL_CACHE" >> "$GITHUB_PATH"
46+
- name: Run tests
47+
run: mvn --no-transfer-progress test
48+
- name: Patch SpotBugs SARIF report
49+
if: "!cancelled() && github.event_name == 'push'"
50+
run: mvn antrun:run@patch-sarif
51+
- name: Upload SpotBugs SARIF report
52+
uses: github/codeql-action/upload-sarif@v3
53+
if: "!cancelled() && github.event_name == 'push'"
54+
with:
55+
category: spotbugs
56+
sarif_file: target/reports/spotbugsSarif.json
57+
- name: Upload SpotBugs XML report
58+
uses: lcollins/[email protected]
59+
if: "!cancelled() && github.event_name == 'pull_request'"
60+
with:
61+
path: target/reports/spotbugs.xml
62+
- name: Upload JUnit XML report
63+
uses: mikepenz/action-junit-report@v4
64+
if: "!cancelled()"
65+
with:
66+
annotate_only: true
67+
detailed_summary: true
68+
report_paths: target/reports/surefire/TEST-*.xml

.github/workflows/deploy.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Deploy
2+
3+
on:
4+
push:
5+
tags: ["*"]
6+
7+
jobs:
8+
deploy:
9+
name: Deploy package
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: write
13+
environment:
14+
name: maven-central
15+
url: https://central.sonatype.com/artifact/io.github.tree-sitter/jtreesitter
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v4
19+
with:
20+
submodules: true
21+
- name: Set up Java
22+
uses: actions/setup-java@v4
23+
with:
24+
distribution: temurin
25+
java-version: 22
26+
cache: maven
27+
server-id: central
28+
server-username: SONATYPE_USERNAME
29+
server-password: SONATYPE_TOKEN
30+
gpg-private-key: ${{secrets.GPG_KEY}}
31+
- name: Set up tree-sitter
32+
uses: tree-sitter/setup-action/lib@v1
33+
- name: Set up tree-sitter-java
34+
run: |-
35+
git clone --depth=1 https://github.com/tree-sitter/tree-sitter-java
36+
make -Ctree-sitter-java all install PREFIX="$RUNNER_TOOL_CACHE/tree-sitter/lib"
37+
- name: Set up jextract
38+
run: |-
39+
curl -LSs '${{vars.JEXTRACT_URL}}' | tar xzf - -C "$RUNNER_TOOL_CACHE"
40+
printf '%s/jextract-22/bin\n' "$RUNNER_TOOL_CACHE" >> "$GITHUB_PATH"
41+
- name: Deploy to Maven Central
42+
run: mvn --no-transfer-progress deploy -Dspotbugs.skip=true
43+
env:
44+
SONATYPE_USERNAME: ${{secrets.SONATYPE_USERNAME}}
45+
SONATYPE_TOKEN: ${{secrets.SONATYPE_TOKEN}}
46+
MAVEN_GPG_PASSPHRASE: ${{secrets.GPG_PASSPHRASE}}
47+
- name: Create release
48+
run: gh release create $GITHUB_REF_NAME --generate-notes
49+
env:
50+
GH_TOKEN: ${{github.token}}
51+
GH_REPO: ${{github.repository}}

.github/workflows/docs.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Docs
2+
3+
on:
4+
workflow_run:
5+
workflows: [CI]
6+
types: [completed]
7+
branches: [master]
8+
9+
concurrency:
10+
cancel-in-progress: true
11+
group: ${{github.workflow}}-${{github.ref_name}}
12+
13+
jobs:
14+
test:
15+
name: Publish docs
16+
runs-on: ubuntu-latest
17+
if: github.event.workflow_run.conclusion == 'success'
18+
permissions:
19+
contents: read
20+
id-token: write
21+
pages: write
22+
environment:
23+
name: github-pages
24+
url: ${{steps.deployment.outputs.page_url}}
25+
steps:
26+
- name: Checkout repository
27+
uses: actions/checkout@v4
28+
with:
29+
submodules: true
30+
- name: Set up Java
31+
uses: actions/setup-java@v4
32+
with:
33+
distribution: temurin
34+
java-version: 22
35+
cache: maven
36+
- name: Set up tree-sitter
37+
uses: tree-sitter/setup-action/lib@v1
38+
- name: Set up tree-sitter-java
39+
run: |-
40+
git clone --depth=1 https://github.com/tree-sitter/tree-sitter-java
41+
make -Ctree-sitter-java all install PREFIX="$RUNNER_TOOL_CACHE/tree-sitter/lib"
42+
- name: Set up jextract
43+
run: |-
44+
curl -LSs '${{vars.JEXTRACT_URL}}' | tar xzf - -C "$RUNNER_TOOL_CACHE"
45+
printf '%s/jextract-22/bin\n' "$RUNNER_TOOL_CACHE" >> "$GITHUB_PATH"
46+
- name: Build javadoc
47+
run: mvn --no-transfer-progress javadoc:javadoc antrun:run@fix-javadoc
48+
- name: Upload pages artifact
49+
uses: actions/upload-pages-artifact@v3
50+
with:
51+
path: target/site/apidocs
52+
- name: Publish to GitHub Pages
53+
id: deployment
54+
uses: actions/deploy-pages@v4

.gitignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
### Maven ###
2+
target/
3+
4+
### JetBrains ###
5+
.idea/*
6+
out/
7+
*.iws
8+
*.iml
9+
*.ipr
10+
*.trace
11+
*.log
12+
.attach_*
13+
14+
### Vim ###
15+
[._]*.s[a-v][a-z]
16+
[._]*.sw[a-p]
17+
[._]s[a-rt-v][a-z]
18+
[._]ss[a-gi-z]
19+
[._]sw[a-p]
20+
Session.vim
21+
.nvimrc
22+
tags
23+
*~

.gitmodules

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[submodule "tree-sitter"]
2+
url = https://github.com/tree-sitter/tree-sitter
3+
path = core
4+
shallow = true

LICENSE

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) 2024 tree-sitter contributors
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is
8+
furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in all
11+
copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19+
SOFTWARE.

README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Java Tree-sitter
2+
3+
[![CI][ci]](https://github.com/tree-sitter/java-tree-sitter/actions/workflows/ci.yml)
4+
[![central][central]](https://central.sonatype.com/artifact/io.github.tree-sitter/jtreesitter)
5+
[![docs][docs]](https://tree-sitter.github.io/java-tree-sitter/)
6+
7+
Java bindings to the [tree-sitter] parsing library.
8+
9+
## Building
10+
11+
- Install JDK 22 and set `JAVA_HOME` to it
12+
- Download [jextract] and add it to your `PATH`
13+
14+
```bash
15+
git clone https://github.com/tree-sitter/java-tree-sitter
16+
cd java-tree-sitter
17+
git submodule init
18+
mvn test
19+
```
20+
21+
## Alternatives
22+
23+
These alternatives support older JDK versions or Android:
24+
25+
- [kotlin-tree-sitter](https://github.com/tree-sitter/kotlin-tree-sitter) (JDK 17+, Android SDK 23+, Kotlin 1.9)
26+
- [tree-sitter-ng](https://github.com/bonede/tree-sitter-ng) (JDK 8+)
27+
- [android-tree-sitter](https://github.com/AndroidIDEOfficial/android-tree-sitter) (Android SDK 21+)
28+
29+
[tree-sitter]: https://tree-sitter.github.io/tree-sitter/
30+
[ci]: https://img.shields.io/github/actions/workflow/status/tree-sitter/java-tree-sitter/ci.yml?logo=github&label=CI
31+
[central]: https://img.shields.io/maven-central/v/io.github.tree-sitter/jtreesitter?logo=sonatype&label=Maven%20Central
32+
[docs]: https://img.shields.io/github/deployments/tree-sitter/java-tree-sitter/github-pages?logo=githubpages&label=API%20Docs
33+
[FFM]: https://docs.oracle.com/en/java/javase/22/core/foreign-function-and-memory-api.html
34+
[jextract]: https://jdk.java.net/jextract/

core

Submodule core added at 6ec478c

0 commit comments

Comments
 (0)