* src/print.c (print_vectorlike): Check for outdated node.
* src/treesit.c (treesit_check_node): Use the new function.
(treesit_node_uptodate_p): New function.
* src/treesit.h: Declare new function.
case PVEC_TS_NODE:
/* Prints #<treesit-node (identifier) in 12-15> or
#<treesit-node "keyword" in 28-31>. */
- print_c_string ("#<treesit-node ", printcharfun);
+ print_c_string ("#<treesit-node", printcharfun);
+ if (!treesit_node_uptodate_p (obj))
+ {
+ print_c_string ("-outdated>", printcharfun);
+ break;
+ }
+ printchar (' ', printcharfun);
+ /* Now the node must be up-to-date, and calling functions like
+ Ftreesit_node_start will not signal. */
bool named = treesit_named_node_p (XTS_NODE (obj)->node);
const char *delim1 = named ? "(" : "\"";
const char *delim2 = named ? ")" : "\"";
treesit_check_node (Lisp_Object obj)
{
CHECK_TS_NODE (obj);
- Lisp_Object lisp_parser = XTS_NODE (obj)->parser;
- if (XTS_NODE (obj)->timestamp != XTS_PARSER (lisp_parser)->timestamp)
+ if (!treesit_node_uptodate_p (obj))
xsignal1 (Qtreesit_node_outdated, obj);
}
+bool treesit_node_uptodate_p (Lisp_Object obj)
+{
+ Lisp_Object lisp_parser = XTS_NODE (obj)->parser;
+ return XTS_NODE (obj)->timestamp == XTS_PARSER (lisp_parser)->timestamp;
+}
+
DEFUN ("treesit-node-type",
Ftreesit_node_type, Streesit_node_type, 1, 1, 0,
doc: /* Return the NODE's type as a string.
Lisp_Object
make_treesit_node (Lisp_Object parser, TSNode node);
+bool treesit_node_uptodate_p (Lisp_Object obj);
+
extern void treesit_delete_parser (struct Lisp_TS_Parser *);
extern void treesit_delete_query (struct Lisp_TS_Query *);
extern bool treesit_named_node_p (TSNode);