From 01413aa4a477393acffe5381449ab7816d44e9e8 Mon Sep 17 00:00:00 2001 From: Yuan Fu Date: Mon, 10 Mar 2025 20:15:39 -0700 Subject: [PATCH] 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. (cherry picked from commit 03a6d4256f861d71e09206ac09d48f16efd52b64) --- src/treesit.c | 32 -------------------------------- src/treesit.h | 14 -------------- 2 files changed, 46 deletions(-) diff --git a/src/treesit.c b/src/treesit.c index 9622addd09b..b0979397d35 100644 --- a/src/treesit.c +++ b/src/treesit.c @@ -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); diff --git a/src/treesit.h b/src/treesit.h index d4cfc47ee5d..0d4635f4253 100644 --- a/src/treesit.h +++ b/src/treesit.h @@ -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. */ -- 2.39.5