Remove parent-node field from tree-sitter parsers

* src/treesit.c (make_treesit_parser): Remove field.
(Ftreesit_parser_parent_node):
(Ftreesit_parser_set_parent_node): Remove
* src/treesit.h (Lisp_TS_Parser): Remove field.
This commit is contained in:
Yuan Fu 2025-03-10 20:15:39 -07:00
parent f79354460d
commit 03a6d4256f
No known key found for this signature in database
GPG key ID: 56E19BC57664A442
2 changed files with 0 additions and 46 deletions

View file

@ -1368,7 +1368,6 @@ make_treesit_parser (Lisp_Object buffer, TSParser *parser,
lisp_parser->tag = tag;
lisp_parser->last_set_ranges = Qnil;
lisp_parser->embed_level = Qnil;
lisp_parser->parent_node = Qnil;
lisp_parser->buffer = buffer;
lisp_parser->parser = parser;
lisp_parser->tree = tree;
@ -1856,35 +1855,6 @@ tree; otherwise it must be a non-negative integer. */)
return level;
}
DEFUN ("treesit-parser-parent-node",
Ftreesit_parser_parent_node, Streesit_parser_parent_node,
1, 1, 0,
doc: /* Return PARSER's parent node, if one exists.
Only embeded local parsers can have parent node. When Emacs uses a node
in the host parser to create this local parser, that node is considered
the parent node of the local parser. */)
(Lisp_Object parser)
{
treesit_check_parser (parser);
return XTS_PARSER (parser)->parent_node;
}
DEFUN ("treesit-parser-set-parent-node",
Ftreesit_parser_set_parent_node, Streesit_parser_set_parent_node,
2, 2, 0,
doc: /* Make NODE be the parent node of PARSER. */)
(Lisp_Object parser, Lisp_Object node)
{
treesit_check_parser (parser);
if (!NILP (node))
CHECK_TS_NODE (node);
XTS_PARSER (parser)->parent_node = node;
return node;
}
/* Return true if PARSER is not deleted and its buffer is live. */
static bool
treesit_parser_live_p (Lisp_Object parser)
@ -4642,8 +4612,6 @@ applies to LANGUAGE-A will be redirected to LANGUAGE-B instead. */);
defsubr (&Streesit_parser_tag);
defsubr (&Streesit_parser_embed_level);
defsubr (&Streesit_parser_set_embed_level);
defsubr (&Streesit_parser_parent_node);
defsubr (&Streesit_parser_set_parent_node);
defsubr (&Streesit_parser_root_node);
defsubr (&Streesit_parse_string);

View file

@ -72,20 +72,6 @@ struct Lisp_TS_Parser
friends) haven't touched this parser yet, and this parser isn't
part of the embed parser tree. */
Lisp_Object embed_level;
/* Some comments: Technically you could calculate embed_level by
following parent_node, but parent_node might be outdated so it's a
good idea to record embed_level separately. Embed_level and
parent_node could have been implemented as "parser properties" with
an obarray, but ultimately I think two explicit fields helps
documentation better and it's not clear to me that a property list
for a parser will be useful beyond this. And we can always convert
these to properties later, but not vice versa. */
/* When an embedded parser is created, it's usually based on a node in
the host parser. This field saves that node so it's possible to
climb up and out of the embedded parser into the host parser. Note
that the range of the embedded parser doesn't have to match that of
the parent node. */
Lisp_Object parent_node;
/* The buffer associated with this parser. */
Lisp_Object buffer;
/* The pointer to the tree-sitter parser. Never NULL. */