content: /*
   *  This file is part of android-tree-sitter.
   *
   *  android-tree-sitter library is free software; you can redistribute it and/or
   *  modify it under the terms of the GNU Lesser General Public
   *  License as published by the Free Software Foundation; either
   *  version 2.1 of the License, or (at your option) any later version.
   *
   *  android-tree-sitter library is distributed in the hope that it will be useful,
   *  but WITHOUT ANY WARRANTY; without even the implied warranty of
   *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   *  Lesser General Public License for more details.
   *
   *   You should have received a copy of the GNU General Public License
   *  along with android-tree-sitter.  If not, see <https://www.gnu.org/licenses/>.
   */
  
  package com.itsaky.androidide.treesitter;
  
  import com.itsaky.androidide.treesitter.annotations.GenerateNativeHeaders;
  import dalvik.annotation.optimization.FastNative;
  
  /**
   * @author Akash Yadav
   */
  public class TreeSitter {
  
    private static int sLangVer = -1, sMinCompatLangVer = -1;
  
    /**
     * Loads the <code>android-tree-sitter</code> native library using
     * {@link System#loadLibrary(String)}.
     */
    public static void loadLibrary() {
      System.loadLibrary("android-tree-sitter");
    }
  
  
    /**
     * The latest ABI version that is supported by the current version of the library. When Languages
     * are generated by the Tree-sitter CLI, they are assigned an ABI version number that corresponds
     * to the current CLI version. The Tree-sitter library is generally backwards-compatible with
     * languages generated using older CLI versions, but is not forwards-compatible.
     */
    public static int getLanguageVersion() {
      if (sLangVer == -1) {
        sLangVer = Native.getLanguageVersion();
      }
  
      return sLangVer;
    }
  
    /**
     * The earliest ABI version that is supported by the current version of the library.
     */
    public static int getMinimumCompatibleLanguageVersion() {
      if (sMinCompatLangVer == -1) {
        sMinCompatLangVer = Native.getMinimumCompatibleLanguageVersion();
      }
  
      return sMinCompatLangVer;
    }
  
    @GenerateNativeHeaders(fileName = "meta")
    private static final class Native {
  
      @FastNative
      static native int getLanguageVersion();
  
      /**
       * The earliest ABI version that is supported by the current version of the library.
       */
      @FastNative
      static native int getMinimumCompatibleLanguageVersion();
    }
  }