File tree Expand file tree Collapse file tree 3 files changed +34
-12
lines changed
src/main/java/io/github/treesitter/jtreesitter Expand file tree Collapse file tree 3 files changed +34
-12
lines changed Original file line number Diff line number Diff line change 11package io .github .treesitter .jtreesitter ;
22
3- import java .util .function .BiConsumer ;
43import org .jspecify .annotations .NonNull ;
54
65/** A function that logs parsing results. */
76@ FunctionalInterface
8- public interface Logger extends BiConsumer < Logger . Type , String > {
7+ public interface Logger {
98 /**
10- * {@inheritDoc}
9+ * Performs this operation on the given arguments.
1110 *
1211 * @param type the log type
1312 * @param message the log message
1413 */
15- @ Override
16- void accept (@ NonNull Type type , @ NonNull String message );
14+ void log (@ NonNull Type type , @ NonNull String message );
15+
16+ /**
17+ * Performs this operation on the given arguments.
18+ *
19+ * @param type the log type
20+ * @param message the log message
21+ * @deprecated Use {@link #log(Logger.Type, String)} instead
22+ */
23+ @ Deprecated (since = "0.26.0" , forRemoval = true )
24+ default void accept (@ NonNull Type type , @ NonNull String message ) {
25+ log (type , message );
26+ }
1727
1828 /** The type of a log message. */
1929 enum Type {
Original file line number Diff line number Diff line change 11package io .github .treesitter .jtreesitter ;
22
3- import java .util .function .BiFunction ;
43import org .jspecify .annotations .NonNull ;
54import org .jspecify .annotations .Nullable ;
65
76/** A function that retrieves a chunk of text at a given byte offset and point. */
87@ FunctionalInterface
9- public interface ParseCallback extends BiFunction < Integer , Point , String > {
8+ public interface ParseCallback {
109 /**
11- * {@inheritDoc}
10+ * Applies this function to the given arguments.
1211 *
1312 * @param offset the current byte offset
1413 * @param point the current point
1514 * @return A chunk of text or {@code null} to indicate the end of the document.
1615 */
17- @ Override
1816 @ Nullable
19- String apply (@ Unsigned Integer offset , @ NonNull Point point );
17+ String read (@ Unsigned int offset , @ NonNull Point point );
18+
19+ /**
20+ * Applies this function to the given arguments.
21+ *
22+ * @param offset the current byte offset
23+ * @param point the current point
24+ * @return A chunk of text or {@code null} to indicate the end of the document.
25+ * @deprecated Use {@link #read(int, Point)} instead
26+ */
27+ @ Nullable
28+ @ Deprecated (since = "0.26.0" , forRemoval = true )
29+ default String apply (@ Unsigned Integer offset , @ NonNull Point point ) {
30+ return read (offset , point );
31+ }
2032}
Original file line number Diff line number Diff line change @@ -74,7 +74,7 @@ public Parser setLogger(@Nullable Logger logger) {
7474 var log = TSLogger .log .allocate (
7575 (_ , type , message ) -> {
7676 var logType = Logger .Type .values ()[type ];
77- logger .accept (logType , message .getString (0 ));
77+ logger .log (logType , message .getString (0 ));
7878 },
7979 arena );
8080 TSLogger .log (segment , log );
@@ -266,7 +266,7 @@ public Optional<Tree> parse(
266266 TSInput .encoding (input , encoding .ordinal ());
267267 var read = TSInput .read .allocate (
268268 (_ , index , point , bytes ) -> {
269- var result = parseCallback .apply (index , Point .from (point ));
269+ var result = parseCallback .read (index , Point .from (point ));
270270 if (result == null ) {
271271 bytes .set (C_INT , 0 , 0 );
272272 return MemorySegment .NULL ;
You can’t perform that action at this time.
0 commit comments