@@ -745,9 +745,14 @@ TSNode cbm_resolve_func_name(TSNode node, CBMLanguage lang) {
745745 }
746746
747747 /* Swift and newer tree-sitter-kotlin: function_declaration has no `name`
748- * field; the function name is a `simple_identifier` child. */
748+ * field; the function name is a `simple_identifier` child. A Swift
749+ * protocol requirement (a bodyless `func` inside a protocol) is a
750+ * separate node type with the same shape; it is named here as well as in
751+ * resolve_method_name because swift_func_types now admits it, so it can
752+ * reach the free-function path too and would otherwise land unnamed. */
749753 if ((lang == CBM_LANG_SWIFT || lang == CBM_LANG_KOTLIN ) &&
750- strcmp (kind , "function_declaration" ) == 0 ) {
754+ (strcmp (kind , "function_declaration" ) == 0 ||
755+ strcmp (kind , "protocol_function_declaration" ) == 0 )) {
751756 TSNode si = cbm_find_child_by_kind (node , "simple_identifier" );
752757 if (!ts_node_is_null (si )) {
753758 return si ;
@@ -4579,6 +4584,7 @@ static TSNode find_class_body(TSNode class_node, CBMLanguage lang) {
45794584 static const char * body_types [] = {"class_body" ,
45804585 "interface_body" ,
45814586 "enum_body" ,
4587+ "protocol_body" ,
45824588 "template_body" ,
45834589 "interface_type" ,
45844590 "struct_type" ,
@@ -4699,7 +4705,8 @@ static TSNode resolve_method_name(TSNode child, CBMLanguage lang) {
46994705 }
47004706
47014707 if ((lang == CBM_LANG_SWIFT || lang == CBM_LANG_KOTLIN ) &&
4702- strcmp (ck , "function_declaration" ) == 0 ) {
4708+ (strcmp (ck , "function_declaration" ) == 0 ||
4709+ strcmp (ck , "protocol_function_declaration" ) == 0 )) {
47034710 return cbm_find_child_by_kind (child , "simple_identifier" );
47044711 }
47054712
0 commit comments