This repository was archived by the owner on Oct 18, 2024. It is now read-only.
This repository was archived by the owner on Oct 18, 2024. It is now read-only.
[Feature Request]: add predicates support #23
Closed
Description
I am trying to port the rust bindings for the Query
including predicates) to kotlin. Whilst doing this I noticed that not all functions have bindings.
What is missing:
-
ts_query_capture_quantifier_for_id
- Add a
TSQuantifier
-enum - Add a method
TSQuery#getCaptureQuantifierForId(int patternId, int captureId)
- Add a
Implementation
getCaptureQuantifierForId
(untested)
TSQuantifier.java
public enum TSQuantifier {
TSQuantifierZero, // must match the array initialization value
TSQuantifierZeroOrOne,
TSQuantifierZeroOrMore,
TSQuantifierOne,
TSQuantifierOneOrMore
}
TSQuery.java
public class TSQuery {
// ...
public TSQuantifier getCaptureQuantifierForId(int patternId, int captureId) {
checkAccess();
int value = Native.getCaptureQuantifierForId(this.pointer, patternId, captureId);
if (value >= TSQualifier.values().length) throw new IllegalStateException("Illegal TSQuantifier value: " + value);
return TSQuantifier.values()[value];
}
// ...
private static class Native {
// ...
public static native int getCaptureQuantifierForId(long query, int patternId, int captureId);
}
}
ts_query.cc
extern "C" JNIEXPORT jint JNICALL
Java_com_itsaky_androidide_treesitter_TSQuery_00024Native_getCaptureQuantifierForId(JNIEnv* env, jclass self, jlong query, jint patternId, jint captureId) {
return (jint)ts_query_capture_quantifier_for_id((TSQuery*)query, patternId, captureId);
}
Metadata
Metadata
Assignees
Labels
No labels