From 622f291606093f83a7f5540e091fe6fbe90f12d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89amonn=20McManus?= Date: Tue, 16 Apr 2024 07:36:57 -0700 Subject: [PATCH] Add `proto2::compiler::java::CapitalizedOneofName`. PiperOrigin-RevId: 625326468 --- src/google/protobuf/compiler/java/names.cc | 4 ++++ src/google/protobuf/compiler/java/names.h | 13 ++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/google/protobuf/compiler/java/names.cc b/src/google/protobuf/compiler/java/names.cc index 1ce35d642c..2c47db1942 100644 --- a/src/google/protobuf/compiler/java/names.cc +++ b/src/google/protobuf/compiler/java/names.cc @@ -144,6 +144,10 @@ std::string CapitalizedFieldName(const FieldDescriptor* field) { return UnderscoresToCamelCase(FieldName(field), true); } +std::string CapitalizedOneofName(const OneofDescriptor* oneof) { + return UnderscoresToCamelCase(oneof->name(), true); +} + std::string UnderscoresToCamelCase(const FieldDescriptor* field) { return UnderscoresToCamelCase(FieldName(field), false); } diff --git a/src/google/protobuf/compiler/java/names.h b/src/google/protobuf/compiler/java/names.h index 5e8b402876..d6402fc5d3 100644 --- a/src/google/protobuf/compiler/java/names.h +++ b/src/google/protobuf/compiler/java/names.h @@ -17,8 +17,9 @@ #include -#include "google/protobuf/descriptor.h" +#include "absl/strings/string_view.h" #include "google/protobuf/compiler/java/options.h" +#include "google/protobuf/descriptor.h" // Must be last. #include "google/protobuf/port_def.inc" @@ -74,8 +75,14 @@ std::string FileJavaPackage(const FileDescriptor* descriptor, // Requires: // descriptor != NULL // Returns: -// Capitalized camel case name field name. -std::string CapitalizedFieldName(const FieldDescriptor* descriptor); +// Capitalized camel case field name. +std::string CapitalizedFieldName(const FieldDescriptor* field); + +// Requires: +// descriptor != NULL +// Returns: +// Capitalized camel case oneof name. +std::string CapitalizedOneofName(const OneofDescriptor* oneof); // Returns: // Converts a name to camel-case. If cap_first_letter is true, capitalize the