void assertHasField()

in source_gen/lib/src/constants/utils.dart [11:26]


void assertHasField(ClassElement root, String name) {
  ClassElement? element = root;
  while (element != null) {
    final field = element.getField(name);
    if (field != null) {
      return;
    }
    element = element.supertype?.element;
  }
  final allFields = root.fields.toSet()
    ..addAll(root.allSupertypes.expand((t) => t.element.fields));
  throw FormatException(
    'Class ${root.name} does not have field "$name".',
    'Fields: \n  - ${allFields.map((e) => e.name).join('\n  - ')}',
  );
}