@@ -3554,8 +3554,9 @@ static void extract_class_def(CBMExtractCtx *ctx, TSNode node, const CBMLangSpec
35543554 }
35553555
35563556 TSNode name_node = ts_node_child_by_field_name (node , TS_FIELD ("name" ));
3557- // ObjC: class name is first identifier child
3558- if (ts_node_is_null (name_node ) && ctx -> language == CBM_LANG_OBJC ) {
3557+ // ObjC/Java: class name is first identifier child (Java fallback for enum_declaration)
3558+ if (ts_node_is_null (name_node ) &&
3559+ (ctx -> language == CBM_LANG_OBJC || ctx -> language == CBM_LANG_JAVA )) {
35593560 name_node = cbm_find_child_by_kind (node , "identifier" );
35603561 }
35613562 // ObjectScript UDL: class name is a `class_name` child (no "name" field).
@@ -3974,6 +3975,12 @@ static TSNode find_class_body(TSNode class_node, CBMLanguage lang) {
39743975 for (const char * * f = body_fields ; * f ; f ++ ) {
39753976 TSNode body = ts_node_child_by_field_name (class_node , * f , (uint32_t )strlen (* f ));
39763977 if (!ts_node_is_null (body )) {
3978+ if (strcmp (ts_node_type (body ), "enum_body" ) == 0 ) {
3979+ TSNode decls = cbm_find_child_by_kind (body , "enum_body_declarations" );
3980+ if (!ts_node_is_null (decls )) {
3981+ return decls ;
3982+ }
3983+ }
39773984 return body ;
39783985 }
39793986 }
@@ -4029,17 +4036,31 @@ static TSNode find_class_body(TSNode class_node, CBMLanguage lang) {
40294036 "implementation_definition" ,
40304037 NULL };
40314038 uint32_t count = ts_node_child_count (class_node );
4039+ TSNode result = {0 };
40324040 for (uint32_t i = 0 ; i < count ; i ++ ) {
40334041 TSNode child = ts_node_child (class_node , i );
40344042 const char * ck = ts_node_type (child );
40354043 for (const char * * t = body_types ; * t ; t ++ ) {
40364044 if (strcmp (ck , * t ) == 0 ) {
4037- return child ;
4045+ result = child ;
4046+ break ;
40384047 }
40394048 }
4049+ if (!ts_node_is_null (result )) {
4050+ break ;
4051+ }
40404052 }
4041- TSNode null_node = {0 };
4042- return null_node ;
4053+ if (!ts_node_is_null (result ) && strcmp (ts_node_type (result ), "enum_body" ) == 0 ) {
4054+ TSNode decls = cbm_find_child_by_kind (result , "enum_body_declarations" );
4055+ if (!ts_node_is_null (decls )) {
4056+ return decls ;
4057+ }
4058+ }
4059+ if (ts_node_is_null (result )) {
4060+ TSNode null_node = {0 };
4061+ return null_node ;
4062+ }
4063+ return result ;
40434064}
40444065
40454066// Dart: resolve method name from method_signature/function_signature.
@@ -6200,7 +6221,8 @@ static void push_class_body_children(TSNode node, const CBMLangSpec *spec, wd_st
62006221 const char * ck = ts_node_type (child );
62016222 if (strcmp (ck , "field_declaration_list" ) == 0 || strcmp (ck , "class_body" ) == 0 ||
62026223 strcmp (ck , "declaration_list" ) == 0 || strcmp (ck , "body" ) == 0 ||
6203- strcmp (ck , "block" ) == 0 || strcmp (ck , "suite" ) == 0 ||
6224+ strcmp (ck , "block" ) == 0 || strcmp (ck , "suite" ) == 0 || strcmp (ck , "enum_body" ) == 0 ||
6225+ strcmp (ck , "enum_body_declarations" ) == 0 ||
62046226 // Groovy class bodies are a `closure` node; routing through the
62056227 // nested-class path keeps methods from being re-walked (and thus
62066228 // double-extracted) as top-level functions. Gated to Groovy so other
0 commit comments