From 64580b29c1dfdd580052a01a5ccd3fb1c0a22f5c Mon Sep 17 00:00:00 2001 From: Protobuf Team Bot Date: Wed, 8 May 2024 11:34:05 -0700 Subject: [PATCH] Expose JavaPackageDirectory and FileClassName in java/names.h PiperOrigin-RevId: 631870244 --- src/google/protobuf/compiler/java/helpers.h | 3 +-- src/google/protobuf/compiler/java/names.cc | 8 ++++++++ src/google/protobuf/compiler/java/names.h | 14 ++++++++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/google/protobuf/compiler/java/helpers.h b/src/google/protobuf/compiler/java/helpers.h index 52b4017cf5..d99e085a65 100644 --- a/src/google/protobuf/compiler/java/helpers.h +++ b/src/google/protobuf/compiler/java/helpers.h @@ -78,8 +78,7 @@ std::string UniqueFileScopeIdentifier(const Descriptor* descriptor); // Gets the unqualified class name for the file. For each .proto file, there // will be one Java class containing all the immutable messages and another // Java class containing all the mutable messages. -// TODO: remove the default value after updating client code. -std::string FileClassName(const FileDescriptor* file, bool immutable = true); +std::string FileClassName(const FileDescriptor* file, bool immutable); // Returns the file's Java package name. std::string FileJavaPackage(const FileDescriptor* file, bool immutable, diff --git a/src/google/protobuf/compiler/java/names.cc b/src/google/protobuf/compiler/java/names.cc index ae18ee2e4e..7f026ecaf6 100644 --- a/src/google/protobuf/compiler/java/names.cc +++ b/src/google/protobuf/compiler/java/names.cc @@ -141,6 +141,14 @@ std::string FileJavaPackage(const FileDescriptor* file, Options options) { return FileJavaPackage(file, true /* immutable */, options); } +std::string JavaPackageDirectory(const FileDescriptor* file) { + return JavaPackageToDir(FileJavaPackage(file)); +} + +std::string FileClassName(const FileDescriptor* file) { + return FileClassName(file, /*immutable=*/true); +} + std::string CapitalizedFieldName(const FieldDescriptor* field) { return UnderscoresToCamelCase(FieldName(field), true); } diff --git a/src/google/protobuf/compiler/java/names.h b/src/google/protobuf/compiler/java/names.h index d6402fc5d3..c2eb34cb37 100644 --- a/src/google/protobuf/compiler/java/names.h +++ b/src/google/protobuf/compiler/java/names.h @@ -72,6 +72,20 @@ std::string ClassName(const ServiceDescriptor* descriptor); std::string FileJavaPackage(const FileDescriptor* descriptor, Options options = {}); +// Requires: +// descriptor != NULL +// +// Returns: +// Java package directory. +std::string JavaPackageDirectory(const FileDescriptor* file); + +// Requires: +// descriptor != NULL +// +// Returns: +// The unqualified Java class name. +std::string FileClassName(const FileDescriptor* file); + // Requires: // descriptor != NULL // Returns: