File tree Expand file tree Collapse file tree 4 files changed +36
-0
lines changed
main/java/io/github/treesitter/jtreesitter
test/java/io/github/treesitter/jtreesitter Expand file tree Collapse file tree 4 files changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -108,6 +108,8 @@ $env:package = 'io.github.treesitter.jtreesitter.internal'
108108 -- include- function ts_query_cursor_set_match_limit `
109109 -- include- function ts_query_cursor_set_max_start_depth `
110110 -- include- function ts_query_cursor_set_point_range `
111+ -- include- function ts_query_cursor_set_timeout_micros `
112+ -- include- function ts_query_cursor_timeout_micros `
111113 -- include- function ts_query_delete `
112114 -- include- function ts_query_disable_capture `
113115 -- include- function ts_query_disable_pattern `
Original file line number Diff line number Diff line change @@ -108,6 +108,8 @@ jextract \
108108 --include-function ts_query_cursor_set_match_limit \
109109 --include-function ts_query_cursor_set_max_start_depth \
110110 --include-function ts_query_cursor_set_point_range \
111+ --include-function ts_query_cursor_set_timeout_micros \
112+ --include-function ts_query_cursor_timeout_micros \
111113 --include-function ts_query_delete \
112114 --include-function ts_query_disable_capture \
113115 --include-function ts_query_disable_pattern \
Original file line number Diff line number Diff line change @@ -294,6 +294,25 @@ public Query setMatchLimit(@Unsigned int matchLimit) throws IllegalArgumentExcep
294294 return this ;
295295 }
296296
297+ /**
298+ * Get the maximum duration in microseconds that query
299+ * execution should be allowed to take before halting.
300+ *
301+ * @apiNote Defaults to {@code 0} (unlimited).
302+ */
303+ public @ Unsigned long getTimeoutMicros () {
304+ return ts_query_cursor_timeout_micros (cursor );
305+ }
306+
307+ /**
308+ * Set the maximum duration in microseconds that query
309+ * execution should be allowed to take before halting.
310+ */
311+ public Query setTimeoutMicros (@ Unsigned long timeoutMicros ) {
312+ ts_query_cursor_set_timeout_micros (cursor , timeoutMicros );
313+ return this ;
314+ }
315+
297316 /**
298317 * Set the maximum start depth for the query.
299318 *
Original file line number Diff line number Diff line change @@ -101,6 +101,19 @@ void setMatchLimit() {
101101 });
102102 }
103103
104+ @ Test
105+ void getTimeoutMicros () {
106+ assertQuery (query -> assertEquals (0 , query .getTimeoutMicros ()));
107+ }
108+
109+ @ Test
110+ void setTimeoutMicros () {
111+ assertQuery (query -> {
112+ assertSame (query , query .setTimeoutMicros (10 ));
113+ assertEquals (10 , query .getTimeoutMicros ());
114+ });
115+ }
116+
104117 @ Test
105118 void setMaxStartDepth () {
106119 assertQuery (query -> assertSame (query , query .setMaxStartDepth (10 )));
You can’t perform that action at this time.
0 commit comments