Return array type annotation for primitive list fields.
(self, field: Field)
| 1770 | return False |
| 1771 | |
| 1772 | def get_array_annotation(self, field: Field) -> Optional[str]: |
| 1773 | """Return array type annotation for primitive list fields.""" |
| 1774 | if isinstance(field.field_type, ArrayType): |
| 1775 | element_type = field.field_type.element_type |
| 1776 | elif isinstance(field.field_type, ListType): |
| 1777 | if not self.java_array(field): |
| 1778 | return None |
| 1779 | if field.element_optional or field.element_ref: |
| 1780 | return None |
| 1781 | element_type = field.field_type.element_type |
| 1782 | else: |
| 1783 | return None |
| 1784 | if not isinstance(element_type, PrimitiveType): |
| 1785 | return None |
| 1786 | kind = element_type.kind |
| 1787 | if isinstance(field.field_type, ArrayType) and not self.java_array(field): |
| 1788 | if kind in (PrimitiveKind.FLOAT16, PrimitiveKind.BFLOAT16): |
| 1789 | return None |
| 1790 | if isinstance(field.field_type, ListType) and not self.java_array(field): |
| 1791 | if kind in (PrimitiveKind.FLOAT16, PrimitiveKind.BFLOAT16): |
| 1792 | return None |
| 1793 | if kind == PrimitiveKind.INT8: |
| 1794 | return "@Int8Type" |
| 1795 | if kind == PrimitiveKind.UINT8: |
| 1796 | return "@UInt8Type" |
| 1797 | if kind == PrimitiveKind.UINT16: |
| 1798 | return "@UInt16Type" |
| 1799 | if kind == PrimitiveKind.UINT32: |
| 1800 | return "@UInt32Type" |
| 1801 | if kind == PrimitiveKind.UINT64: |
| 1802 | return "@UInt64Type" |
| 1803 | if kind == PrimitiveKind.FLOAT16: |
| 1804 | return "@Float16Type" |
| 1805 | if kind == PrimitiveKind.BFLOAT16: |
| 1806 | return "@BFloat16Type" |
| 1807 | return None |
| 1808 | |
| 1809 | def has_array_field(self, message: Message) -> bool: |
| 1810 | """Check if message has fields that require array-aware generated code.""" |
no test coverage detected