* doc/lispref/parsing.texi (Pattern Matching): Mention it.
* lisp/treesit.el (treesit-check-query): Rename to
treesit-query-validate.
* src/treesit.c (Ftreesit_query_capture, Ftreesit_query_compile):
Mention it.
@vindex treesit-query-error
This function raise a @var{treesit-query-error} if @var{query} is
malformed. The signal data contains a description of the specific
-error.
+error. You can use @code{treesit-query-validate} to debug the query.
@end defun
@defun treesit-query-in source query &optional beg end
@defun treesit-query-compile language query
This function compiles @var{query} for @var{language} into a compiled
query object and returns it.
+
+This function raise a @var{treesit-query-error} if @var{query} is
+malformed. The signal data contains a description of the specific
+error. You can use @code{treesit-query-validate} to debug the query.
@end defun
@defun treesit-expand-query query
(remove '(:eval treesit--inspect-name)
mode-line-misc-info))))
-(defun treesit-check-query (query language)
+(defun treesit-query-validate (language query)
"Check if QUERY is valid for LANGUAGE.
If QUERY is invalid, display the query in a popup buffer, jumps
to the offending pattern and highlight the pattern."
+ (cl-assert (or (consp query) (stringp query)))
(let ((buf (get-buffer-create "*tree-sitter check query*")))
(with-temp-buffer
(treesit-get-parser-create language)
Querying a compiled query is much faster than an uncompiled one.
LANGUAGE is the language this query is for.
-Signals treesit-query-error if QUERY is malformed or something
-else goes wrong. */)
+Signals treesit-query-error if QUERY is malformed or something else
+goes wrong. You can use `treesit-query-validate' to debug the
+query. */)
(Lisp_Object language, Lisp_Object query)
{
if (!Ftreesit_query_p (query))
BEG and END, if both non-nil, specifies the range in which the query
is executed.
-Raise an treesit-query-error if QUERY is malformed, or something
-else goes wrong. */)
+Signals treesit-query-error if QUERY is malformed or something else
+goes wrong. You can use `treesit-query-validate' to debug the
+query. */)
(Lisp_Object node, Lisp_Object query,
Lisp_Object beg, Lisp_Object end)
{