aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorStefan Kangas2022-12-31 06:30:21 +0100
committerStefan Kangas2022-12-31 06:30:21 +0100
commit2ec4e187c9c4592f9fbd86b67854110252b80140 (patch)
tree6b929b845c32a09cd2d64547c13d6e20dff575db /src
parent57e363a4514bddc443414aec1528fd9501d85034 (diff)
parentab1f245f1a1b36bae9a3051b6cb93ecd5b78dd7a (diff)
downloademacs-2ec4e187c9c4592f9fbd86b67854110252b80140.tar.gz
emacs-2ec4e187c9c4592f9fbd86b67854110252b80140.zip
Merge from origin/emacs-29
ab1f245f1a1 Show tree-sitter query source when signaling query error 0b58ea0e602 ; * lisp/treesit.el (treesit--install-language-grammar-1)... 724da28763c Add version tags and mention the new options in NEWS 8675f4136c7 Add new options for Ruby code indentation 4922de626f0 ; Fix doc strings of 'treesit-install-language-grammar' 69b2aaaaded ; Fix recently modified docs of 'set-face-attribute' (bug... 0248fc9e1ac Add treesit-install-language-grammar 0237c5927e9 Add treesit-language-abi-version 312f82d36f0 Change "language definition" to "language grammar" in man... fba35657da5 ; * lisp/progmodes/c-ts-mode.el (c-ts-mode--fill-paragrap... dec1b37a32b ; * doc/lispref/parsing.texi (Accessing Node Information)... 39265abf0cc * test/lisp/net/tramp-tests.el (tramp-test32-shell-comman... ebf65c7e7e3 * lisp/eshell/em-tramp.el (tramp): Require also at runtim... # Conflicts: # etc/NEWS
Diffstat (limited to 'src')
-rw-r--r--src/treesit.c42
1 files changed, 34 insertions, 8 deletions
diff --git a/src/treesit.c b/src/treesit.c
index eaa563a54c4..974d2fc4517 100644
--- a/src/treesit.c
+++ b/src/treesit.c
@@ -662,9 +662,8 @@ If DETAIL is non-nil, return (t . nil) when LANGUAGE is available,
662 } 662 }
663} 663}
664 664
665DEFUN ("treesit-language-version", 665DEFUN ("treesit-library-abi-version", Ftreesit_library_abi_version,
666 Ftreesit_language_version, 666 Streesit_library_abi_version,
667 Streesit_language_version,
668 0, 1, 0, 667 0, 1, 0,
669 doc: /* Return the language ABI version of the tree-sitter library. 668 doc: /* Return the language ABI version of the tree-sitter library.
670 669
@@ -680,6 +679,29 @@ is non-nil, return the oldest compatible ABI version. */)
680 return make_fixnum (TREE_SITTER_MIN_COMPATIBLE_LANGUAGE_VERSION); 679 return make_fixnum (TREE_SITTER_MIN_COMPATIBLE_LANGUAGE_VERSION);
681} 680}
682 681
682DEFUN ("treesit-language-version", Ftreesit_language_abi_version,
683 Streesit_language_abi_version,
684 0, 1, 0,
685 doc: /* Return the language ABI version of the tree-sitter LANGUAGE.
686Return nil if LANGUAGE is not available. */)
687 (Lisp_Object language)
688{
689 if (NILP (Ftreesit_langauge_available_p (language, Qnil)))
690 return Qnil;
691 else
692 {
693 Lisp_Object signal_symbol = Qnil;
694 Lisp_Object signal_data = Qnil;
695 TSLanguage *ts_language = treesit_load_language (language,
696 &signal_symbol,
697 &signal_data);
698 if (ts_language == NULL)
699 return Qnil;
700 uint32_t version = ts_language_version (ts_language);
701 return make_fixnum((ptrdiff_t) version);
702 }
703}
704
683/*** Parsing functions */ 705/*** Parsing functions */
684 706
685static void 707static void
@@ -1172,10 +1194,12 @@ treesit_query_error_to_string (TSQueryError error)
1172 1194
1173static Lisp_Object 1195static Lisp_Object
1174treesit_compose_query_signal_data (uint32_t error_offset, 1196treesit_compose_query_signal_data (uint32_t error_offset,
1175 TSQueryError error_type) 1197 TSQueryError error_type,
1198 Lisp_Object query_source)
1176{ 1199{
1177 return list3 (build_string (treesit_query_error_to_string (error_type)), 1200 return list4 (build_string (treesit_query_error_to_string (error_type)),
1178 make_fixnum (error_offset + 1), 1201 make_fixnum (error_offset + 1),
1202 query_source,
1179 build_pure_c_string ("Debug the query with `treesit-query-validate'")); 1203 build_pure_c_string ("Debug the query with `treesit-query-validate'"));
1180} 1204}
1181 1205
@@ -1217,7 +1241,8 @@ treesit_ensure_query_compiled (Lisp_Object query, Lisp_Object *signal_symbol,
1217 { 1241 {
1218 *signal_symbol = Qtreesit_query_error; 1242 *signal_symbol = Qtreesit_query_error;
1219 *signal_data = treesit_compose_query_signal_data (error_offset, 1243 *signal_data = treesit_compose_query_signal_data (error_offset,
1220 error_type); 1244 error_type,
1245 source);
1221 } 1246 }
1222 XTS_COMPILED_QUERY (query)->query = treesit_query; 1247 XTS_COMPILED_QUERY (query)->query = treesit_query;
1223 return treesit_query; 1248 return treesit_query;
@@ -2605,7 +2630,7 @@ the query. */)
2605 if (treesit_query == NULL) 2630 if (treesit_query == NULL)
2606 xsignal (Qtreesit_query_error, 2631 xsignal (Qtreesit_query_error,
2607 treesit_compose_query_signal_data (error_offset, 2632 treesit_compose_query_signal_data (error_offset,
2608 error_type)); 2633 error_type, query));
2609 cursor = ts_query_cursor_new (); 2634 cursor = ts_query_cursor_new ();
2610 needs_to_free_query_and_cursor = true; 2635 needs_to_free_query_and_cursor = true;
2611 } 2636 }
@@ -3345,7 +3370,8 @@ then in the system default locations for dynamic libraries, in that order. */);
3345 Vtreesit_extra_load_path = Qnil; 3370 Vtreesit_extra_load_path = Qnil;
3346 3371
3347 defsubr (&Streesit_language_available_p); 3372 defsubr (&Streesit_language_available_p);
3348 defsubr (&Streesit_language_version); 3373 defsubr (&Streesit_library_abi_version);
3374 defsubr (&Streesit_language_abi_version);
3349 3375
3350 defsubr (&Streesit_parser_p); 3376 defsubr (&Streesit_parser_p);
3351 defsubr (&Streesit_node_p); 3377 defsubr (&Streesit_node_p);