[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
feature/tree-sitter a7288594f4 14/26: Change treesit-check-query and men
From: |
Yuan Fu |
Subject: |
feature/tree-sitter a7288594f4 14/26: Change treesit-check-query and mention it in documentation |
Date: |
Thu, 16 Jun 2022 14:53:46 -0400 (EDT) |
branch: feature/tree-sitter
commit a7288594f493a20664f1934a9fc760537caadcc3
Author: Yuan Fu <casouri@gmail.com>
Commit: Yuan Fu <casouri@gmail.com>
Change treesit-check-query and mention it in documentation
* 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.
---
doc/lispref/parsing.texi | 6 +++++-
lisp/treesit.el | 3 ++-
src/treesit.c | 10 ++++++----
3 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/doc/lispref/parsing.texi b/doc/lispref/parsing.texi
index 1c4a7805a3..36c03364e3 100644
--- a/doc/lispref/parsing.texi
+++ b/doc/lispref/parsing.texi
@@ -816,7 +816,7 @@ are both non-nil, it only pattern matches nodes in that
range.
@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
@@ -1111,6 +1111,10 @@ a query is accepted.
@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
diff --git a/lisp/treesit.el b/lisp/treesit.el
index 09f750f9d5..ad90d9f9f0 100644
--- a/lisp/treesit.el
+++ b/lisp/treesit.el
@@ -1038,10 +1038,11 @@ uses the first parser in `treesit-parser-list'."
(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)
diff --git a/src/treesit.c b/src/treesit.c
index 5b344a2ea1..df8c992bb5 100644
--- a/src/treesit.c
+++ b/src/treesit.c
@@ -1522,8 +1522,9 @@ DEFUN ("treesit-query-compile",
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))
@@ -1564,8 +1565,9 @@ compile your queries if it will be used over and over.
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)
{
- feature/tree-sitter 8f3b872e30 08/26: Add new type treesit-compiled-query, (continued)
- feature/tree-sitter 8f3b872e30 08/26: Add new type treesit-compiled-query, Yuan Fu, 2022/06/16
- feature/tree-sitter a73f2b9990 04/26: Fix treesit-search-forward, Yuan Fu, 2022/06/16
- feature/tree-sitter 35e2786c93 01/26: Fix typo and argument in treesit-beginning-of-defun, etc, Yuan Fu, 2022/06/16
- feature/tree-sitter 1dd8ddee12 02/26: Rename treesit-traverse-forward-depth-first, Yuan Fu, 2022/06/16
- feature/tree-sitter a8428b917d 09/26: * src/treesit.c (Ftreesit_query_p): New function., Yuan Fu, 2022/06/16
- feature/tree-sitter 316bdc334c 15/26: Add manual for treesit-traverse-forward and friends, Yuan Fu, 2022/06/16
- feature/tree-sitter 8aa04aac65 07/26: ; * lisp/treesit.el (treesit-defun-query): Improve docstring., Yuan Fu, 2022/06/16
- feature/tree-sitter e171ef933f 10/26: Support compiled queries in treesit-query-capture, Yuan Fu, 2022/06/16
- feature/tree-sitter b3de8850e0 06/26: Use the up-only parameter in treesit navigation functions, Yuan Fu, 2022/06/16
- feature/tree-sitter 016e4ca7a7 12/26: ; * doc/lispref/parsing.texi: Minor fix-up., Yuan Fu, 2022/06/16
- feature/tree-sitter a7288594f4 14/26: Change treesit-check-query and mention it in documentation,
Yuan Fu <=
- feature/tree-sitter 0332b8e2c5 21/26: ; * src/treesit.c (ts_check_buffer_size): Improve error message., Yuan Fu, 2022/06/16
- feature/tree-sitter c5b172ec58 03/26: * configure.ac (HAVE_TREE_SITTER): Not set TREE_SITTER_LIBS., Yuan Fu, 2022/06/16
- feature/tree-sitter bd1b27b7c7 23/26: ; Minor optimization in treesit range function, Yuan Fu, 2022/06/16
- feature/tree-sitter 33f7e10a29 26/26: Add treesit test for previous change, Yuan Fu, 2022/06/16
- feature/tree-sitter 184d212042 16/26: Merge branch 'feature/tree-sitter-depth-control' into feature/tree-sitter, Yuan Fu, 2022/06/16
- feature/tree-sitter b162faba0b 18/26: Fix compile warnings and errors in treesit.c, Yuan Fu, 2022/06/16
- feature/tree-sitter d729e3e3fc 19/26: * src/treesit.c (ts_check_range_argument): Check for point-min/max., Yuan Fu, 2022/06/16
- feature/tree-sitter 98bfb24081 17/26: Merge remote-tracking branch 'savannah/master' into feature/tree-sitter, Yuan Fu, 2022/06/16
- feature/tree-sitter 7cee82a91d 24/26: Fix treesit function ts_record_change and friends, Yuan Fu, 2022/06/16
- feature/tree-sitter d6b00f7ed9 20/26: ; * src/treesit.c (ts_read_buffer): Clarify comments., Yuan Fu, 2022/06/16