Skip to content

Commit cbf4ddf

Browse files
committed
docs: extend Javadoc
1 parent 1d0055d commit cbf4ddf

File tree

8 files changed

+27
-9
lines changed

8 files changed

+27
-9
lines changed

README.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
# Java Tree-sitter
22

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/)
3+
[![CI][ci-shield]](https://github.com/tree-sitter/java-tree-sitter/actions/workflows/ci.yml)
4+
[![central][central-shield]](https://central.sonatype.com/artifact/io.github.tree-sitter/jtreesitter)
5+
[![docs][docs-shield]][docs]
66

77
Java bindings to the [tree-sitter] parsing library.
88

9+
## Usage
10+
11+
See the [documentation][docs].
12+
913
## Building
1014

1115
- Install JDK 22 and set `JAVA_HOME` to it
@@ -29,8 +33,9 @@ These alternatives support older JDK versions or Android:
2933
- [AndroidIDEOfficial/android-tree-sitter](https://github.com/AndroidIDEOfficial/android-tree-sitter) (Android SDK 21+)
3034

3135
[tree-sitter]: https://tree-sitter.github.io/tree-sitter/
32-
[ci]: https://img.shields.io/github/actions/workflow/status/tree-sitter/java-tree-sitter/ci.yml?logo=github&label=CI
33-
[central]: https://img.shields.io/maven-central/v/io.github.tree-sitter/jtreesitter?logo=sonatype&label=Maven%20Central
34-
[docs]: https://img.shields.io/github/deployments/tree-sitter/java-tree-sitter/github-pages?logo=githubpages&label=API%20Docs
36+
[ci-shield]: https://img.shields.io/github/actions/workflow/status/tree-sitter/java-tree-sitter/ci.yml?logo=github&label=CI
37+
[central-shield]: https://img.shields.io/maven-central/v/io.github.tree-sitter/jtreesitter?logo=sonatype&label=Maven%20Central
38+
[docs-shield]: https://img.shields.io/github/deployments/tree-sitter/java-tree-sitter/github-pages?logo=githubpages&label=API%20Docs
39+
[docs]: https://tree-sitter.github.io/java-tree-sitter/
3540
[FFM]: https://docs.oracle.com/en/java/javase/22/core/foreign-function-and-memory-api.html
3641
[jextract]: https://jdk.java.net/jextract/

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ Charset charset() {
4040
* @param charset one of {@link StandardCharsets#UTF_8}, {@link StandardCharsets#UTF_16BE},
4141
* {@link StandardCharsets#UTF_16LE}, or {@link StandardCharsets#UTF_16} (native byte order).
4242
* @throws IllegalArgumentException If the character set is invalid.
43+
* @since 0.25.1
4344
*/
4445
@SuppressWarnings("SameParameterValue")
4546
public static @NonNull InputEncoding valueOf(@NonNull Charset charset) throws IllegalArgumentException {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ private static UnsatisfiedLinkError unresolved(String name) {
6767
* <strong>The {@linkplain Arena} used to load the language
6868
* must not be closed while the language is being used.</strong>
6969
*
70+
* @throws UnsatisfiedLinkError If the language symbol could not be found.
7071
* @throws RuntimeException If the language could not be loaded.
7172
* @since 0.23.1
7273
*/

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
/**
1515
* A class that is used to look up valid symbols in a specific parse state.
1616
*
17+
* <p>Iterator instances can be created using {@link Language#lookaheadIterator(short)}.
18+
*
1719
* <p>Lookahead iterators can be useful to generate suggestions and improve syntax error diagnostics.<br>
1820
* To get symbols valid in an {@index ERROR} node, use the lookahead iterator on its first leaf node state.<br>
1921
* For {@index MISSING} nodes, a lookahead iterator created on the previous non-extra leaf node may be appropriate.

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public final class Parser implements AutoCloseable {
2626
* Creates a new instance with a {@code null} language.
2727
*
2828
* @apiNote Parsing cannot be performed while the language is {@code null}.
29+
* @see #setLanguage(Language)
2930
*/
3031
public Parser() {
3132
arena = Arena.ofShared();
@@ -400,6 +401,10 @@ public String toString() {
400401
public static final class Options {
401402
private final Predicate<State> progressCallback;
402403

404+
/**
405+
* @param progressCallback Called when parsing progress was made. Return {@code true} to cancel parsing,
406+
* {@code false} to continue parsing.
407+
*/
403408
public Options(Predicate<State> progressCallback) {
404409
this.progressCallback = progressCallback;
405410
}

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,8 @@ public static class Options {
293293
private final @Nullable BiPredicate<QueryPredicate, QueryMatch> predicateCallback;
294294

295295
/**
296-
* @param progressCallback Progress handler.
296+
* @param progressCallback Progress handler. Return {@code true} to cancel query execution,
297+
* {@code false} to continue query execution.
297298
* @param predicateCallback Custom predicate handler.
298299
*/
299300
private Options(
@@ -304,7 +305,8 @@ private Options(
304305
}
305306

306307
/**
307-
* @param progressCallback Progress handler.
308+
* @param progressCallback Progress handler. Return {@code true} to cancel query execution,
309+
* {@code false} to continue query execution.
308310
*/
309311
public Options(Predicate<State> progressCallback) {
310312
this.progressCallback = progressCallback;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import java.util.List;
88
import org.jspecify.annotations.NullMarked;
99

10-
/** A match that corresponds to a certain pattern in the query. */
10+
/** A match that corresponds to a certain pattern in a {@link Query}. */
1111
@NullMarked
1212
public record QueryMatch(@Unsigned int patternIndex, List<QueryCapture> captures) {
1313
/** Creates an instance of a QueryMatch record class. */

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
/**
1313
* A class that can be used to efficiently walk a {@linkplain Tree syntax tree}.
1414
*
15+
* <p>A cursor can be created using {@link Tree#walk()} and {@link Node#walk()}.
16+
*
1517
* @apiNote The node the cursor was constructed with is considered the
1618
* root of the cursor, and the cursor cannot walk outside this node.
1719
*/

0 commit comments

Comments
 (0)