generateOneofAccessors method
Implementation
void generateOneofAccessors(IndentingWriter out, OneofNames oneof) {
out.println();
for (final field in _oneofFields[oneof.index]) {
_emitIndexAnnotation(field.number, out);
}
out.printlnAnnotated(
'${oneof.oneofEnumName} ${oneof.whichOneofMethodName}() '
'=> ${oneof.byTagMapName}[\$_whichOneof(${oneof.index})]!;',
[
NamedLocation(
name: oneof.whichOneofMethodName,
fieldPathSegment: Paths.buildOneofPath(fieldPath, oneof),
start: '${oneof.oneofEnumName} '.length,
),
],
);
for (final field in _oneofFields[oneof.index]) {
_emitIndexAnnotation(field.number, out);
}
out.printlnAnnotated(
'void ${oneof.clearMethodName}() '
'=> \$_clearField(\$_whichOneof(${oneof.index}));',
[
NamedLocation(
name: oneof.clearMethodName,
fieldPathSegment: Paths.buildOneofPath(fieldPath, oneof),
start: 'void '.length,
),
],
);
}