Skip to content
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

Description

@AntonPieper

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:

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);
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions