Skip to content

Commit 3846ad4

Browse files
committed
Incorporate review feedback
1 parent 356a15a commit 3846ad4

File tree

5 files changed

+9
-10
lines changed

5 files changed

+9
-10
lines changed

README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,12 @@ Java bindings to the [tree-sitter] parsing library.
1010

1111
- Install JDK 22 and set `JAVA_HOME` to it
1212
- Download [jextract] and add it to your `PATH`
13+
- Install the `tree-sitter` & `tree-sitter-java` libraries
1314

1415
```bash
1516
git clone https://github.com/tree-sitter/java-tree-sitter
1617
cd java-tree-sitter
17-
git submodule init
18-
git submodule update
19-
# build tree-sitter and tree-sitter-java native libraries,
20-
# for example by replicating the steps in .github/workflows/ci.yml
18+
git submodule update --init
2119
mvn test
2220
```
2321

pom.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,7 @@
8181
<skip>${jextract.skip}</skip>
8282
<target name="jextract">
8383
<echo level="info">Generating sources using jextract</echo>
84-
<exec osfamily="windows" executable="powershell" failonerror="true">
85-
<arg value="${project.basedir}/scripts/jextract.ps1"/>
84+
<exec osfamily="windows" executable="${project.basedir}/scripts/jextract.ps1" failonerror="true">
8685
<arg value="${project.basedir}"/>
8786
<arg value="${project.build.directory}"/>
8887
</exec>

scripts/TreeSitter_java.patch

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
--- a/target/generated-sources/jextract/io/github/treesitter/jtreesitter/internal/TreeSitter.java
2-
+++ b/target/generated-sources/jextract/io/github/treesitter/jtreesitter/internal/TreeSitter.java
1+
--- a/generated-sources/jextract/io/github/treesitter/jtreesitter/internal/TreeSitter.java
2+
+++ b/generated-sources/jextract/io/github/treesitter/jtreesitter/internal/TreeSitter.java
33
@@ -55,9 +55,7 @@
44
};
55
}

src/main/java/io/github/treesitter/jtreesitter/NativeLibraryLookup.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
*
1111
* @see java.util.ServiceLoader
1212
*/
13+
@FunctionalInterface
1314
public interface NativeLibraryLookup {
1415
/**
1516
* Returns the {@link SymbolLookup} to be used for the tree-sitter native library.

src/main/java/io/github/treesitter/jtreesitter/internal/ChainedLibraryLookup.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,17 @@ final class ChainedLibraryLookup implements NativeLibraryLookup {
1111
@Override
1212
public SymbolLookup get(Arena arena) {
1313
var serviceLoader = ServiceLoader.load(NativeLibraryLookup.class);
14+
// NOTE: can't use _ because of palantir/palantir-java-format#934
1415
SymbolLookup lookup = (name) -> Optional.empty();
1516
for (var libraryLookup : serviceLoader) {
1617
lookup = lookup.or(libraryLookup.get(arena));
1718
}
1819
return lookup.or(findLibrary(arena)).or(Linker.nativeLinker().defaultLookup());
1920
}
2021

21-
private SymbolLookup findLibrary(Arena arena) {
22+
private static SymbolLookup findLibrary(Arena arena) {
2223
try {
23-
String library = System.mapLibraryName("tree-sitter");
24+
var library = System.mapLibraryName("tree-sitter");
2425
return SymbolLookup.libraryLookup(library, arena);
2526
} catch (IllegalArgumentException e) {
2627
return SymbolLookup.loaderLookup();

0 commit comments

Comments
 (0)