From f5e6f592b6440b60d47089f1c04d0dc5066bbd8b Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Thu, 10 Aug 2023 18:38:21 +0200 Subject: [PATCH] build(deps): bump tree-sitter-c to v0.20.5 also update highlight queries and test fixup: tests --- cmake.deps/CMakeLists.txt | 4 +- runtime/queries/c/folds.scm | 3 +- runtime/queries/c/highlights.scm | 49 ++++++++++++++++------ test/functional/treesitter/parser_spec.lua | 10 ++--- 4 files changed, 46 insertions(+), 20 deletions(-) diff --git a/cmake.deps/CMakeLists.txt b/cmake.deps/CMakeLists.txt index 814a004ec5..5917c776cf 100644 --- a/cmake.deps/CMakeLists.txt +++ b/cmake.deps/CMakeLists.txt @@ -185,8 +185,8 @@ set(GETTEXT_SHA256 66415634c6e8c3fa8b71362879ec7575e27da43da562c798a8a2f223e6e47 set(LIBICONV_URL https://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.15.tar.gz) set(LIBICONV_SHA256 ccf536620a45458d26ba83887a983b96827001e92a13847b45e4925cc8913178) -set(TREESITTER_C_URL https://github.com/tree-sitter/tree-sitter-c/archive/v0.20.2.tar.gz) -set(TREESITTER_C_SHA256 af66fde03feb0df4faf03750102a0d265b007e5d957057b6b293c13116a70af2 ) +set(TREESITTER_C_URL https://github.com/tree-sitter/tree-sitter-c/archive/v0.20.5.tar.gz) +set(TREESITTER_C_SHA256 694a5408246ee45d535df9df025febecdb50bee764df64a94346b9805a5f349b ) set(TREESITTER_LUA_URL https://github.com/MunifTanjim/tree-sitter-lua/archive/v0.0.17.tar.gz) set(TREESITTER_LUA_SHA256 8963fd0a185d786c164dfca3824941c7eaec497ce49a3a0bc24bf753f5e0e59c) set(TREESITTER_VIM_URL https://github.com/neovim/tree-sitter-vim/archive/v0.3.0.tar.gz) diff --git a/runtime/queries/c/folds.scm b/runtime/queries/c/folds.scm index 80c3039b6b..5a35334a24 100644 --- a/runtime/queries/c/folds.scm +++ b/runtime/queries/c/folds.scm @@ -13,7 +13,8 @@ (preproc_else) (preproc_ifdef) (initializer_list) + (gnu_asm_expression) ] @fold - (compound_statement +(compound_statement (compound_statement) @fold) diff --git a/runtime/queries/c/highlights.scm b/runtime/queries/c/highlights.scm index 46b8df97e4..83fe8b0616 100644 --- a/runtime/queries/c/highlights.scm +++ b/runtime/queries/c/highlights.scm @@ -1,5 +1,6 @@ ; Lower priority to prefer @parameter when identifier appears in parameter_declaration. ((identifier) @variable (#set! "priority" 95)) +(preproc_def (preproc_arg) @variable) [ "default" @@ -8,9 +9,14 @@ "typedef" "union" "goto" + "asm" + "__asm__" ] @keyword -"sizeof" @keyword.operator +[ + "sizeof" + "offsetof" +] @keyword.operator "return" @keyword.return @@ -36,6 +42,8 @@ "#else" "#elif" "#endif" + "#elifdef" + "#elifndef" (preproc_directive) ] @preproc @@ -43,7 +51,7 @@ "#include" @include -[ ";" ":" "," ] @punctuation.delimiter +[ ";" ":" "," "::" ] @punctuation.delimiter "..." @punctuation.special @@ -98,8 +106,8 @@ (comma_expression [ "," ] @operator) [ - (true) - (false) + (true) + (false) ] @boolean (conditional_expression [ "?" ":" ] @conditional.ternary) @@ -112,10 +120,17 @@ (number_literal) @number (char_literal) @character -[ - (preproc_arg) - (preproc_defined) -] @function.macro +((preproc_arg) @function.macro (#set! "priority" 90)) +(preproc_defined) @function.macro + +(((field_expression + (field_identifier) @property)) @_parent + (#not-has-parent? @_parent template_method function_declarator call_expression)) + +(field_designator) @property +(((field_identifier) @property) + (#has-ancestor? @property field_declaration) + (#not-has-ancestor? @property function_declarator)) (statement_identifier) @label @@ -126,7 +141,10 @@ (storage_class_specifier) @storageclass -(type_qualifier) @type.qualifier +[ + (type_qualifier) + (gnu_asm_qualifier) +] @type.qualifier (linkage_specification "extern" @storageclass) @@ -140,6 +158,8 @@ ((identifier) @constant (#lua-match? @constant "^[A-Z][A-Z0-9_]+$")) +(preproc_def (preproc_arg) @constant + (#lua-match? @constant "^[A-Z][A-Z0-9_]+$")) (enumerator name: (identifier) @constant) (case_statement @@ -147,6 +167,8 @@ ((identifier) @constant.builtin (#any-of? @constant.builtin "stderr" "stdin" "stdout")) +(preproc_def (preproc_arg) @constant.builtin + (#any-of? @constant.builtin "stderr" "stdin" "stdout")) ;; Preproc def / undef (preproc_def @@ -179,6 +201,9 @@ (parameter_declaration declarator: (identifier) @parameter) +(parameter_declaration + declarator: (array_declarator) @parameter) + (parameter_declaration declarator: (pointer_declarator) @parameter) @@ -186,15 +211,15 @@ [ "__attribute__" + "__declspec" + "__based" "__cdecl" "__clrcall" "__stdcall" "__fastcall" "__thiscall" "__vectorcall" - "_unaligned" - "__unaligned" - "__declspec" + (ms_pointer_modifier) (attribute_declaration) ] @attribute diff --git a/test/functional/treesitter/parser_spec.lua b/test/functional/treesitter/parser_spec.lua index eedfb5224e..f6ca9a9100 100644 --- a/test/functional/treesitter/parser_spec.lua +++ b/test/functional/treesitter/parser_spec.lua @@ -194,8 +194,8 @@ void ui_refresh(void) local firstrun = q(1) local manyruns = q(100) - -- First run should be at least 400x slower than an 100 subsequent runs. - local factor = is_os('win') and 200 or 400 + -- First run should be at least 200x slower than an 100 subsequent runs. + local factor = is_os('win') and 100 or 200 assert(factor * manyruns < firstrun, ('firstrun: %f ms, manyruns: %f ms'):format(firstrun / 1e6, manyruns / 1e6)) end) @@ -765,9 +765,9 @@ int x = INT_MAX; eq("table", exec_lua("return type(parser:children().c)")) eq({ {0, 0, 7, 0}, -- root tree - {3, 15, 3, 16}, -- VALUE 123 - {4, 16, 4, 17}, -- VALUE1 123 - {5, 16, 5, 17}, -- VALUE2 123 + {3, 16, 3, 16}, -- VALUE 123 + {4, 17, 4, 17}, -- VALUE1 123 + {5, 17, 5, 17}, -- VALUE2 123 {1, 26, 1, 63}, -- READ_STRING(x, y) (char *)read_string((x), (size_t)(y)) {2, 29, 2, 66} -- READ_STRING_OK(x, y) (char *)read_string((x), (size_t)(y)) }, get_ranges())