Resolve an annotation's name node across grammars. Java exposes a `name` * field; tree-sitter-kotlin does not — its annotation name lives in a nested * type_identifier: * @Foo -> (annotation (user_type (type_identifier))) * @Foo("/x") -> (annotation (constructor_invocation (user_type (type_identifier)) * (value_arguments ...)))
| 3372 | * (value_arguments ...))) |
| 3373 | * Returns a null node when no name can be resolved. */ |
| 3374 | static TSNode annotation_name_node(TSNode annotation) { |
| 3375 | TSNode name = ts_node_child_by_field_name(annotation, TS_FIELD("name")); |
| 3376 | if (!ts_node_is_null(name)) { |
| 3377 | return name; |
| 3378 | } |
| 3379 | TSNode ut = cbm_find_child_by_kind(annotation, "user_type"); |
| 3380 | if (ts_node_is_null(ut)) { |
| 3381 | TSNode ci = cbm_find_child_by_kind(annotation, "constructor_invocation"); |
| 3382 | if (!ts_node_is_null(ci)) { |
| 3383 | ut = cbm_find_child_by_kind(ci, "user_type"); |
| 3384 | } |
| 3385 | } |
| 3386 | if (!ts_node_is_null(ut)) { |
| 3387 | TSNode ti = cbm_find_child_by_kind(ut, "type_identifier"); |
| 3388 | if (ts_node_is_null(ti)) { |
| 3389 | ti = cbm_find_child_by_kind(ut, "simple_identifier"); |
| 3390 | } |
| 3391 | return ti; |
| 3392 | } |
| 3393 | TSNode null_node = {0}; |
| 3394 | return null_node; |
| 3395 | } |
| 3396 | |
| 3397 | /* Resolve an annotation's argument list across grammars. Kotlin keeps the args |
| 3398 | * under a `constructor_invocation` child as a `value_arguments` node rather than |
no test coverage detected