|
|
|
@ -799,25 +799,8 @@ bool Parser::ParseTopLevelStatement(FileDescriptorProto* file, |
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
|
// Messages
|
|
|
|
|
|
|
|
|
|
bool Parser::ParseMessageDefinition( |
|
|
|
|
DescriptorProto* message, const LocationRecorder& message_location, |
|
|
|
|
const FileDescriptorProto* containing_file) { |
|
|
|
|
DO(Consume("message")); |
|
|
|
|
{ |
|
|
|
|
LocationRecorder location(message_location, |
|
|
|
|
DescriptorProto::kNameFieldNumber); |
|
|
|
|
location.RecordLegacyLocation(message, |
|
|
|
|
DescriptorPool::ErrorCollector::NAME); |
|
|
|
|
DO(ConsumeIdentifier(message->mutable_name(), "Expected message name.")); |
|
|
|
|
if (!IsUpperCamelCase(message->name())) { |
|
|
|
|
RecordWarning(absl::StrCat( |
|
|
|
|
"Message name should be in UpperCamelCase. Found: ", message->name(), |
|
|
|
|
". See https://developers.google.com/protocol-buffers/docs/style")); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
DO(ParseMessageBlock(message, message_location, containing_file)); |
|
|
|
|
|
|
|
|
|
if (syntax_identifier_ == "proto3") { |
|
|
|
|
PROTOBUF_NOINLINE static void GenerateSyntheticOneofs( |
|
|
|
|
DescriptorProto* message) { |
|
|
|
|
// Add synthetic one-field oneofs for optional fields, except messages which
|
|
|
|
|
// already have presence in proto3.
|
|
|
|
|
//
|
|
|
|
@ -853,6 +836,28 @@ bool Parser::ParseMessageDefinition( |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool Parser::ParseMessageDefinition( |
|
|
|
|
DescriptorProto* message, const LocationRecorder& message_location, |
|
|
|
|
const FileDescriptorProto* containing_file) { |
|
|
|
|
DO(Consume("message")); |
|
|
|
|
{ |
|
|
|
|
LocationRecorder location(message_location, |
|
|
|
|
DescriptorProto::kNameFieldNumber); |
|
|
|
|
location.RecordLegacyLocation(message, |
|
|
|
|
DescriptorPool::ErrorCollector::NAME); |
|
|
|
|
DO(ConsumeIdentifier(message->mutable_name(), "Expected message name.")); |
|
|
|
|
if (!IsUpperCamelCase(message->name())) { |
|
|
|
|
RecordWarning(absl::StrCat( |
|
|
|
|
"Message name should be in UpperCamelCase. Found: ", message->name(), |
|
|
|
|
". See https://developers.google.com/protocol-buffers/docs/style")); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
DO(ParseMessageBlock(message, message_location, containing_file)); |
|
|
|
|
|
|
|
|
|
if (syntax_identifier_ == "proto3") { |
|
|
|
|
GenerateSyntheticOneofs(message); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|