MCPcopy Create free account
hub / github.com/apache/fory / collect_field_imports

Method collect_field_imports

compiler/fory_compiler/generators/java.py:1492–1519  ·  view source on GitHub ↗

Collect imports for a field, including list modifiers.

(
        self,
        field: Field,
        imports: Set[str],
        parent_stack: Optional[List[Message]] = None,
    )

Source from the content-addressed store, hash-verified

1490 )
1491
1492 def collect_field_imports(
1493 self,
1494 field: Field,
1495 imports: Set[str],
1496 parent_stack: Optional[List[Message]] = None,
1497 ):
1498 """Collect imports for a field, including list modifiers."""
1499 is_any = (
1500 isinstance(field.field_type, PrimitiveType)
1501 and field.field_type.kind == PrimitiveKind.ANY
1502 )
1503 nullable = field.optional or is_any
1504 self.collect_type_imports(
1505 field.field_type,
1506 imports,
1507 field.element_optional,
1508 field.element_ref,
1509 field,
1510 parent_stack=parent_stack,
1511 )
1512 self.collect_integer_imports(field.field_type, imports)
1513 self.collect_array_imports(field, imports)
1514 if nullable:
1515 imports.add("org.apache.fory.annotation.Nullable")
1516 if field.ref:
1517 imports.add("org.apache.fory.annotation.Ref")
1518 if field.tag_id is not None:
1519 imports.add("org.apache.fory.annotation.ForyField")
1520
1521 def is_ref_target_type(
1522 self, field_type: FieldType, parent_stack: Optional[List[Message]] = None

Callers 1

Calls 4

collect_type_importsMethod · 0.95
collect_array_importsMethod · 0.95
addMethod · 0.65

Tested by

no test coverage detected