@@ -1854,7 +1854,7 @@ void Generator::GenerateRequiresImpl(const GeneratorOptions& options,
1854
1854
std::set<std::string>* provided,
1855
1855
bool require_jspb, bool require_extension,
1856
1856
bool require_map) const {
1857
-
1857
+
1858
1858
if (options.WantEs6 ()) {
1859
1859
// In ES6 mode, imports are handled by GenerateFile and
1860
1860
// goog.* isn't used.
@@ -2044,7 +2044,7 @@ void Generator::GenerateClassEs6(const GeneratorOptions& options,
2044
2044
return ;
2045
2045
}
2046
2046
2047
-
2047
+
2048
2048
std::string prefix = (desc->containing_type () == nullptr ) ?
2049
2049
" export " : (" static " + desc->name () + " = " );
2050
2050
@@ -2068,11 +2068,11 @@ void Generator::GenerateClassEs6(const GeneratorOptions& options,
2068
2068
" $prefix$class $classname$ extends jspb.Message {\n " ,
2069
2069
" prefix" , prefix,
2070
2070
" classname" , desc->name ());
2071
-
2071
+
2072
2072
printer->Indent ();
2073
2073
2074
2074
GenerateClassConstructor (options, printer, desc);
2075
-
2075
+
2076
2076
GenerateClassFieldInfo (options, printer, desc);
2077
2077
2078
2078
GenerateClassToObject (options, type_names, printer, desc);
@@ -2255,7 +2255,7 @@ void Generator::GenerateClassXid(const GeneratorOptions& options,
2255
2255
void Generator::GenerateOneofCaseDefinition (
2256
2256
const GeneratorOptions& options, io::Printer* printer,
2257
2257
const OneofDescriptor* oneof) const {
2258
-
2258
+
2259
2259
const std::string className = GetMessagePath (options, oneof->containing_type ());
2260
2260
2261
2261
const std::string oneofCaseName = options.WantEs6 () ? (
@@ -2294,7 +2294,7 @@ void Generator::GenerateOneofCaseDefinition(
2294
2294
" */\n " ,
2295
2295
" class" , className,
2296
2296
" oneof" , JSOneofName (oneof));
2297
-
2297
+
2298
2298
GenerateMethodStart (options, printer, className.c_str (),
2299
2299
(std::string (" get" ) + JSOneofName (oneof) + " Case" ).c_str ());
2300
2300
@@ -2319,7 +2319,7 @@ void Generator::GenerateClassToObject(const GeneratorOptions& options,
2319
2319
const char * if_guard_start = options.WantEs6 () ? " " : " if (jspb.Message.GENERATE_TO_OBJECT) {\n " ;
2320
2320
const char * if_guard_end = options.WantEs6 () ? " " : " }\n " ;
2321
2321
const std::string classSymbol = options.WantEs6 () ? desc->name () : GetMessagePath (options, desc);
2322
-
2322
+
2323
2323
printer->Print (
2324
2324
" \n "
2325
2325
" \n "
@@ -2742,7 +2742,7 @@ const char * methodEndBrace = options.WantEs6() ? "}" : "};";
2742
2742
" fielddef" , FieldDefinition (options, field),
2743
2743
" keytype" , key_type,
2744
2744
" valuetype" , value_type);
2745
-
2745
+
2746
2746
// Function start
2747
2747
if (options.import_style == GeneratorOptions::kImportEs6 ) {
2748
2748
printer->Print (
@@ -2981,12 +2981,12 @@ const char * methodEndBrace = options.WantEs6() ? "}" : "};";
2981
2981
" value);\n " ,
2982
2982
" typetag" , JSTypeTag (field),
2983
2983
" index" , JSFieldIndex (field));
2984
-
2984
+
2985
2985
GenerateMethodEnd (options, printer);
2986
2986
printer->Print (
2987
2987
" \n "
2988
2988
" \n " );
2989
-
2989
+
2990
2990
// DO NOT SUBMIT: Can the Annotate call be safely removed?
2991
2991
// printer->Annotate("settername", field);
2992
2992
@@ -3132,9 +3132,9 @@ const char * methodEndBrace = options.WantEs6() ? "}" : "};";
3132
3132
void Generator::GenerateRepeatedPrimitiveHelperMethods (
3133
3133
const GeneratorOptions& options, io::Printer* printer,
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 = std::string (" add" ) +
3137
+ const std::string adderName = std::string (" add" ) +
3138
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 ());
@@ -3184,7 +3184,7 @@ void Generator::GenerateRepeatedMessageHelperMethods(
3184
3184
const FieldDescriptor* field) const {
3185
3185
3186
3186
const std::string classSymbol = GetMessagePath (options, field->containing_type ());
3187
- const std::string adderName = std::string (" add" ) +
3187
+ const std::string adderName = std::string (" add" ) +
3188
3188
JSGetterName (options, field, BYTES_DEFAULT, /* drop_list = */ true );
3189
3189
const std::string adderMethodStart = MethodStart (
3190
3190
options, classSymbol.c_str (), adderName.c_str ());
@@ -3975,7 +3975,7 @@ void RegisterTypesDefinedInGeneratedFile(
3975
3975
TypeNames TypeNames::Es6TypeNames (
3976
3976
const GeneratorOptions& options,
3977
3977
const FileDescriptor* codegen_file) {
3978
-
3978
+
3979
3979
// Full proto name -> local alias in JS codegen file.
3980
3980
std::map<std::string, std::string> full_name_to_alias;
3981
3981
// Local aliases that are already reserved
@@ -4017,7 +4017,7 @@ TypeNames TypeNames::Es6TypeNames(
4017
4017
pick_name (message_type->full_name (), message_type->name ());
4018
4018
}
4019
4019
}
4020
-
4020
+
4021
4021
for (int j = 0 ; j < file->enum_type_count (); j++) {
4022
4022
auto enum_type = file->enum_type (j);
4023
4023
if (file == codegen_file) {
@@ -4069,7 +4069,7 @@ std::string TypeNames::SubmessageTypeRef(const FieldDescriptor* field) const {
4069
4069
GOOGLE_CHECK (this ->codegen_file == nullptr ||
4070
4070
this ->codegen_file == field->file ());
4071
4071
GOOGLE_CHECK_NOTNULL (field->message_type ());
4072
- return JsExpression (*field->message_type ());
4072
+ return JsExpression (*field->message_type ()) + " /* message_type = " + field-> message_type ()-> DebugString () + " */ " ;
4073
4073
}
4074
4074
4075
4075
std::string TypeNames::JsExpression (const std::string& full_name) const {
@@ -4079,15 +4079,14 @@ std::string TypeNames::JsExpression(const std::string& full_name) const {
4079
4079
if (iter != this ->map_ .end ()) {
4080
4080
return iter->second ;
4081
4081
}
4082
- // See if the parent full_name is available.
4082
+ // See if the parent full_name is available. If it is, use it as the prefix.
4083
4083
auto parts = google::protobuf::Split (full_name, " ." , false );
4084
4084
if (parts.size () > 1 ) {
4085
- // uh oh... not sure how this happend.
4086
4085
std::vector<std::string> parent_parts = {parts.begin (), parts.end () - 1 };
4087
4086
auto parent_path = google::protobuf::JoinStrings (
4088
4087
parent_parts,
4089
4088
" ." );
4090
- return this ->JsExpression (parent_path);
4089
+ return this ->JsExpression (parent_path) + " . " + parts[parts. size () - 1 ] ;
4091
4090
}
4092
4091
return std::string (" INVALID TYPE NAME " ) + full_name;
4093
4092
}
@@ -4117,7 +4116,7 @@ std::vector<std::string> ImportAliases(
4117
4116
out.push_back (exported_name + " as " + alias);
4118
4117
}
4119
4118
}
4120
-
4119
+
4121
4120
for (int j = 0 ; j < dep_file.enum_type_count (); j++) {
4122
4121
auto enum_type = dep_file.enum_type (j);
4123
4122
out.push_back (type_names.JsExpression (*enum_type));
0 commit comments