Skip to content

Commit

Permalink
Expose JavaPackageDirectory and FileClassName in java/names.h
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 631870244
  • Loading branch information
protobuf-github-bot authored and Copybara-Service committed May 8, 2024
1 parent d5b7d7a commit 64580b2
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/google/protobuf/compiler/java/helpers.h
Expand Up @@ -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,
Expand Down
8 changes: 8 additions & 0 deletions src/google/protobuf/compiler/java/names.cc
Expand Up @@ -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);
}
Expand Down
14 changes: 14 additions & 0 deletions src/google/protobuf/compiler/java/names.h
Expand Up @@ -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:
Expand Down

0 comments on commit 64580b2

Please sign in to comment.