Function: treesit-node-check
treesit-node-check is a function defined in treesit.c.
Signature
(treesit-node-check NODE PROPERTY)
Documentation
Return non-nil if NODE has PROPERTY, nil otherwise.
PROPERTY could be named, missing, extra, outdated,
has-error, or live.
Named nodes correspond to named rules in the language definition, whereas "anonymous" nodes correspond to string literals in the language definition.
Missing nodes are inserted by the parser in order to recover from certain kinds of syntax errors, i.e., should be there but not there.
Extra nodes represent things like comments, which are not required the language definition, but can appear anywhere.
A node is "outdated" if the parser has reparsed at least once after the node was created.
A node "has error" if itself is a syntax error or contains any syntax errors.
A node is "live" if its parser is not deleted and its buffer is live.
Other relevant functions are documented in the treesit group.
Shortdoc
;; treesit
(treesit-node-check node 'named)
e.g. => t
Source Code
// Defined in /usr/src/emacs/src/treesit.c
{
if (NILP (node)) return Qnil;
CHECK_TS_NODE (node);
CHECK_SYMBOL (property);
treesit_initialize ();
TSNode treesit_node = XTS_NODE (node)->node;
bool result;
if (EQ (property, Qoutdated))
return treesit_node_uptodate_p (node) ? Qnil : Qt;
treesit_check_node (node);
if (EQ (property, Qnamed))
result = ts_node_is_named (treesit_node);
else if (EQ (property, Qmissing))
result = ts_node_is_missing (treesit_node);
else if (EQ (property, Qextra))
result = ts_node_is_extra (treesit_node);
else if (EQ (property, Qhas_error))
result = ts_node_has_error (treesit_node);
else if (EQ (property, Qlive))
result = treesit_parser_live_p (XTS_NODE (node)->parser);
else
signal_error ("Expecting `named', `missing', `extra', "
"`outdated', `has-error', or `live', but got",
property);
return result ? Qt : Qnil;
}