Collect ``(simple, raw)`` annotation names from a Java declaration's `modifiers` child. ``raw`` keeps the dotted qualifier of an inline-qualified annotation (``@org.pkg.Foo``); it equals ``simple`` when unqualified.
(declaration_node, source: bytes)
| 1095 | |
| 1096 | |
| 1097 | def _java_annotation_names(declaration_node, source: bytes) -> list[tuple[str, str]]: |
| 1098 | """Collect ``(simple, raw)`` annotation names from a Java declaration's |
| 1099 | `modifiers` child. ``raw`` keeps the dotted qualifier of an inline-qualified |
| 1100 | annotation (``@org.pkg.Foo``); it equals ``simple`` when unqualified.""" |
| 1101 | names: list[tuple[str, str]] = [] |
| 1102 | for anno in _java_annotation_nodes(declaration_node): |
| 1103 | name_node = anno.child_by_field_name("name") |
| 1104 | if name_node is None: |
| 1105 | for sub in anno.children: |
| 1106 | if sub.type in ("identifier", "scoped_identifier", "type_identifier"): |
| 1107 | name_node = sub |
| 1108 | break |
| 1109 | if name_node is not None: |
| 1110 | raw = _read_text(name_node, source) |
| 1111 | text = raw.rsplit(".", 1)[-1] |
| 1112 | if text: |
| 1113 | names.append((text, raw)) |
| 1114 | return names |
| 1115 | |
| 1116 | |
| 1117 | def _java_annotation_class_literal_refs( |
no test coverage detected