Function: treesit--compile-query-with-cache
treesit--compile-query-with-cache is a byte-compiled function defined
in treesit.el.gz.
Signature
(treesit--compile-query-with-cache LANG QUERY)
Documentation
Return the cached compiled QUERY for LANG.
If QUERY isn't cached, compile it and save to cache.
If QUERY is invalid, signals treesit-query-error. The fact that QUERY
is invalid is also stored in cache, and the next call to this function
with the same QUERY will signal too.
QUERY is compared with equal, so string form vs sexp form of a query,
and the same query written differently are all considered separate
queries.
Source Code
;; Defined in /usr/src/emacs/lisp/treesit.el.gz
(defun treesit--compile-query-with-cache (lang query)
"Return the cached compiled QUERY for LANG.
If QUERY isn't cached, compile it and save to cache.
If QUERY is invalid, signals `treesit-query-error'. The fact that QUERY
is invalid is also stored in cache, and the next call to this function
with the same QUERY will signal too.
QUERY is compared with `equal', so string form vs sexp form of a query,
and the same query written differently are all considered separate
queries."
(let ((value (gethash (cons lang query) treesit--query-cache)))
(if value
(if (treesit-compiled-query-p value)
value
(signal 'treesit-query-error value))
(condition-case err
(let ((compiled (treesit-query-compile lang query 'eager)))
(puthash (cons lang query) compiled treesit--query-cache)
compiled)
(treesit-query-error
(puthash (cons lang query) (cdr err) treesit--query-cache)
(signal 'treesit-query-error (cdr err)))))))