From 05f88c04fcea79ccf20010688905a485e8624821 Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Sun, 21 Jul 2024 17:46:12 +0200 Subject: [PATCH] Fix punctuation and doc style in treesit.c * src/treesit.c (Ftreesit_parser_included_ranges) (Ftreesit_query_capture, treesit_traverse_sibling_helper) (treesit_traverse_match_predicate): Fix punctiation and documentation style in comments and docstrings. (cherry picked from commit 68615a386699f8e6108cb294a2cbc5664948af39) --- src/treesit.c | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/src/treesit.c b/src/treesit.c index c95a9fb9b01..722f2a9360d 100644 --- a/src/treesit.c +++ b/src/treesit.c @@ -404,7 +404,7 @@ init_treesit_functions (void) buffer's parser list. The discussion can be found in bug#59693. */ -/*** Initialization */ +/*** Initialization */ static Lisp_Object Vtreesit_str_libtree_sitter; static Lisp_Object Vtreesit_str_tree_sitter; @@ -431,7 +431,7 @@ static Lisp_Object Vtreesit_str_pred; functions. Remember to update docstrings when changing this value. If we think of programs and AST, it is very rare for any program to - have a very deep AST. For example, you would need 1000+ levels of + have a very deep AST. For example, you would need 1000+ levels of nested if-statements, or a struct somehow nested for 1000+ levels. It's hard for me to imagine any hand-written or machine generated program to be like that. So I think 1000 is already generous. If @@ -485,10 +485,9 @@ treesit_initialize (void) } -/*** Loading language library */ +/*** Loading language library */ -/* Translates a symbol treesit- to a C name - treesit_. */ +/* Translate a symbol treesit- to a C name treesit_. */ static void treesit_symbol_to_c_name (char *symbol_name) { @@ -758,7 +757,7 @@ Return nil if a grammar library for LANGUAGE is not available. */) } -/*** Parsing functions */ +/*** Parsing functions */ static void treesit_check_parser (Lisp_Object obj) @@ -873,7 +872,7 @@ treesit_record_change (ptrdiff_t start_byte, ptrdiff_t old_end_byte, } } -/* Comment (ref:visible-beg-null) The purpose of visible_beg/end is to +/* Comment (ref:visible-beg-null) The purpose of visible_beg/end is to keep track of "which part of the buffer does the tree-sitter tree see", in order to update the tree correctly. Visible_beg/end have two purposes: they "clip" buffer changes within them, and they @@ -1150,7 +1149,7 @@ treesit_read_buffer (void *parser, uint32_t byte_index, } -/*** Functions for parser and node object */ +/*** Functions for parser and node object */ /* Wrap the parser in a Lisp_Object to be used in the Lisp machine. */ @@ -1575,7 +1574,7 @@ treesit_parser_live_p (Lisp_Object parser) } -/*** Parser API */ +/*** Parser API */ DEFUN ("treesit-parser-root-node", Ftreesit_parser_root_node, Streesit_parser_root_node, @@ -1748,7 +1747,7 @@ See also `treesit-parser-set-included-ranges'. */) /* When the parser doesn't have a range set and we call ts_parser_included_ranges on it, it doesn't return an empty list, - but rather return DEFAULT_RANGE. (A single range where start_byte + but rather return DEFAULT_RANGE. (A single range where start_byte = 0, end_byte = UINT32_MAX). So we need to track whether the parser is ranged ourselves. */ if (NILP (XTS_PARSER (parser)->last_set_ranges)) @@ -1851,8 +1850,8 @@ treesit_check_node (Lisp_Object obj) xsignal1 (Qtreesit_node_buffer_killed, obj); } -/* Checks that OBJ is a positive integer and it is within the visible - portion of BUF. */ +/* Check that OBJ is a positive integer and it is within the visible + portion of BUF. */ static void treesit_check_position (Lisp_Object obj, struct buffer *buf) { @@ -2368,7 +2367,7 @@ produced by tree-sitter. */) } -/*** Query functions */ +/*** Query functions */ /* Convert a Lisp string to its printed representation in the tree-sitter query syntax. */ @@ -3005,7 +3004,7 @@ the query. */) test for predicates. If predicates pass, then all good, if predicates don't pass, revert the result back to the result before this loop (PREV_RESULT). (Predicates control the entire - match.) This way we don't need to create a list of captures in + match.) This way we don't need to create a list of captures in every for loop and nconc it to RESULT every time. That is indeed the initial implementation in which Yoav found nconc being the bottleneck (98.4% of the running time spent on nconc). */ @@ -3083,7 +3082,7 @@ the query. */) } -/*** Navigation */ +/*** Navigation */ static inline void treesit_assume_true (bool val) @@ -3200,7 +3199,7 @@ treesit_traverse_sibling_helper (TSTreeCursor *cursor, if (ts_node_eq (first_child, start)) return false; - /* PROBE is always DELTA siblings ahead of CURSOR. */ + /* PROBE is always DELTA siblings ahead of CURSOR. */ TSTreeCursor probe = ts_tree_cursor_copy (cursor); /* This is position of PROBE minus position of CURSOR. */ ptrdiff_t delta = 0; @@ -3484,7 +3483,7 @@ treesit_traverse_match_predicate (TSTreeCursor *cursor, Lisp_Object pred, return true; } } - /* Returning false is better than UB. */ + /* Returning false is better than UB. */ return false; } @@ -3997,7 +3996,7 @@ DEFUN ("treesit-available-p", Ftreesit_available_p, } -/*** Initialization */ +/*** Initialization */ /* Initialize the tree-sitter routines. */ void -- 2.39.2