tree-sitter / tree-sitter

An incremental parsing system for programming tools

Home Page:https://tree-sitter.github.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ts_highlighter_add_language CAPI and Rust Implementation signature mismatch

TrueAbc opened this issue · comments

Problem

CAPI signature miss a const char* lang_name param.

highlight/include/tree_sitter/highlight.h

TSHighlightError ts_highlighter_add_language(
  TSHighlighter *self,
  const char *scope_name,
  const char *injection_regex,
  const TSLanguage *language,
  const char *highlight_query,
  const char *injection_query,
  const char *locals_query,
  uint32_t highlight_query_len,
  uint32_t injection_query_len,
  uint32_t locals_query_len,
);

highlight/src/c_lib.rs

#[no_mangle]
pub unsafe extern "C" fn ts_highlighter_add_language(
    this: *mut TSHighlighter,
    language_name: *const c_char,
    scope_name: *const c_char,
    injection_regex: *const c_char,
    language: Language,
    highlight_query: *const c_char,
    injection_query: *const c_char,
    locals_query: *const c_char,
    highlight_query_len: u32,
    injection_query_len: u32,
    locals_query_len: u32,
) -> ErrorCode {

Steps to reproduce

use c-api to highlight file

Expected behavior

add parameter to ts_highlighter_add_language in highlight/include/tree_sitter/highlight.h

Tree-sitter version (tree-sitter --version)

tree-sitter 0.22.5

Operating system/version

Ubuntu22.04

thanks for the report! should be fixed now