@@ -3134,14 +3134,16 @@ void Generator::GenerateRepeatedPrimitiveHelperMethods(
3134
3134
const FieldDescriptor* field, bool untyped) const {
3135
3135
3136
3136
const std::string classSymbol = GetMessagePath (options, field->containing_type ());
3137
- const std::string adderName = JSGetterName (options, field, BYTES_DEFAULT,
3138
- /* drop_list = */ true );
3137
+ const std::string adderName = std::string ( " add " ) +
3138
+ JSGetterName (options, field, BYTES_DEFAULT, /* drop_list = */ true );
3139
3139
const std::string adderMethodStart = MethodStart (
3140
3140
options, classSymbol.c_str (), adderName.c_str ());
3141
3141
3142
3142
// clang-format off
3143
3143
printer->Print (
3144
3144
" /**\n "
3145
+ " * Adds a value to the repeated field $field_name$ \n "
3146
+ " *\n "
3145
3147
" * @param {$optionaltype$} value\n "
3146
3148
" * @param {number=} opt_index\n "
3147
3149
" * @return {!$class$} returns this\n "
@@ -3150,9 +3152,8 @@ void Generator::GenerateRepeatedPrimitiveHelperMethods(
3150
3152
" return jspb.Message.addToRepeatedField(this, "
3151
3153
" $index$" ,
3152
3154
" methodstart" , adderMethodStart,
3153
- " class" , classSymbol, " addername" ,
3154
- " add" + JSGetterName (options, field, BYTES_DEFAULT,
3155
- /* drop_list = */ true ),
3155
+ " class" , classSymbol,
3156
+ " addername" , adderName,
3156
3157
" optionaltype" ,
3157
3158
JSFieldTypeAnnotation (
3158
3159
options, field,
@@ -3183,23 +3184,26 @@ void Generator::GenerateRepeatedMessageHelperMethods(
3183
3184
const FieldDescriptor* field) const {
3184
3185
3185
3186
const std::string classSymbol = GetMessagePath (options, field->containing_type ());
3186
- const std::string adderName = JSGetterName (options, field, BYTES_DEFAULT, /* drop_list = */ true );
3187
+ const std::string adderName = std::string (" add" ) +
3188
+ JSGetterName (options, field, BYTES_DEFAULT, /* drop_list = */ true );
3187
3189
const std::string adderMethodStart = MethodStart (
3188
3190
options, classSymbol.c_str (), adderName.c_str ());
3189
3191
3190
3192
printer->Print (
3191
3193
" /**\n "
3194
+ " * Adds a value to the repeated field $field_name$ \n "
3195
+ " *\n "
3192
3196
" * @param {!$optionaltype$=} opt_value\n "
3193
3197
" * @param {number=} opt_index\n "
3194
3198
" * @return {!$optionaltype$}\n "
3195
3199
" */\n "
3196
3200
" $methodstart$(opt_value, opt_index) {\n "
3197
3201
" return jspb.Message.addTo$repeatedtag$WrapperField(" ,
3198
- " optionaltype" , JSTypeName (options, field, BYTES_DEFAULT), " class" , classSymbol,
3202
+ " optionaltype" , JSTypeName (options, field, BYTES_DEFAULT),
3203
+ " field_name" , field->name (),
3204
+ " class" , classSymbol,
3199
3205
" methodstart" , adderMethodStart,
3200
- " addername" ,
3201
- " add" + JSGetterName (options, field, BYTES_DEFAULT,
3202
- /* drop_list = */ true ),
3206
+ " addername" , adderName,
3203
3207
" repeatedtag" , (field->is_repeated () ? " Repeated" : " " ));
3204
3208
3205
3209
printer->Annotate (" addername" , field);
@@ -3209,8 +3213,8 @@ void Generator::GenerateRepeatedMessageHelperMethods(
3209
3213
" \n "
3210
3214
" \n " ,
3211
3215
" index" , JSFieldIndex (field), " oneofgroup" ,
3212
- (InRealOneof (field) ? (" , " + JSOneofArray (options, field)) : " " ), " class " ,
3213
- type_names.SubmessageTypeRef (field));
3216
+ (InRealOneof (field) ? (" , " + JSOneofArray (options, field)) : " " ),
3217
+ " class " , type_names.SubmessageTypeRef (field));
3214
3218
}
3215
3219
3216
3220
void Generator::GenerateClassExtensionFieldInfo (const GeneratorOptions& options,
0 commit comments