File indexing completed on 2026-08-02 09:18:38
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_NAME_RESOLVER_H__
0009 #define GOOGLE_PROTOBUF_COMPILER_JAVA_NAME_RESOLVER_H__
0010
0011 #include <string>
0012
0013 #include "absl/container/flat_hash_map.h"
0014 #include "google/protobuf/compiler/java/options.h"
0015 #include "google/protobuf/port.h"
0016
0017
0018 #include "google/protobuf/port_def.inc"
0019
0020
0021 namespace google {
0022 namespace protobuf {
0023 class Descriptor;
0024 class EnumDescriptor;
0025 class FieldDescriptor;
0026 class FileDescriptor;
0027 class ServiceDescriptor;
0028
0029 namespace compiler {
0030 namespace java {
0031
0032
0033 enum NameEquality { NO_MATCH, EXACT_EQUAL, EQUAL_IGNORE_CASE };
0034
0035
0036
0037
0038 class PROTOC_EXPORT ClassNameResolver {
0039 public:
0040 explicit ClassNameResolver(const Options& options = {}) : options_(options) {}
0041 ~ClassNameResolver() = default;
0042
0043 ClassNameResolver(const ClassNameResolver&) = delete;
0044 ClassNameResolver& operator=(const ClassNameResolver&) = delete;
0045
0046
0047 std::string GetFileClassName(const FileDescriptor* file, bool immutable);
0048 std::string GetFileClassName(const FileDescriptor* file, bool immutable,
0049 bool kotlin);
0050
0051 std::string GetFileImmutableClassName(const FileDescriptor* file);
0052
0053
0054 static std::string GetFileDefaultImmutableClassName(
0055 const FileDescriptor* file);
0056
0057
0058
0059 static bool HasConflictingClassName(const FileDescriptor* file,
0060 absl::string_view classname,
0061 NameEquality equality_mode);
0062
0063
0064
0065
0066
0067 std::string GetDescriptorClassName(const FileDescriptor* file);
0068
0069
0070 std::string GetClassName(const Descriptor* descriptor, bool immutable);
0071 std::string GetClassName(const Descriptor* descriptor, bool immutable,
0072 bool kotlin);
0073 std::string GetClassName(const EnumDescriptor* descriptor, bool immutable);
0074 std::string GetClassName(const EnumDescriptor* descriptor, bool immutable,
0075 bool kotlin);
0076 std::string GetClassName(const ServiceDescriptor* descriptor, bool immutable);
0077 std::string GetClassName(const ServiceDescriptor* descriptor, bool immutable,
0078 bool kotlin);
0079 std::string GetClassName(const FileDescriptor* descriptor, bool immutable);
0080 std::string GetClassName(const FileDescriptor* descriptor, bool immutable,
0081 bool kotlin);
0082
0083 template <class DescriptorType>
0084 std::string GetImmutableClassName(const DescriptorType* descriptor) {
0085 return GetClassName(descriptor, true);
0086 }
0087
0088
0089 std::string GetExtensionIdentifierName(const FieldDescriptor* descriptor,
0090 bool immutable);
0091 std::string GetExtensionIdentifierName(const FieldDescriptor* descriptor,
0092 bool immutable, bool kotlin);
0093
0094
0095
0096
0097
0098 std::string GetJavaImmutableClassName(const Descriptor* descriptor);
0099 std::string GetJavaImmutableClassName(const EnumDescriptor* descriptor);
0100 std::string GetJavaImmutableClassName(const ServiceDescriptor* descriptor);
0101 std::string GetKotlinFactoryName(const Descriptor* descriptor);
0102 std::string GetFullyQualifiedKotlinFactoryName(const Descriptor* descriptor);
0103 std::string GetKotlinExtensionsClassName(const Descriptor* descriptor);
0104 std::string GetKotlinExtensionsClassNameEscaped(const Descriptor* descriptor);
0105 std::string GetFileJavaPackage(const FileDescriptor* file, bool immutable);
0106
0107
0108
0109 std::string GetClassFullName(absl::string_view name_without_package,
0110 const FileDescriptor* file, bool immutable,
0111 bool is_own_file);
0112 std::string GetClassFullName(absl::string_view name_without_package,
0113 const FileDescriptor* file, bool immutable,
0114 bool is_own_file, bool kotlin);
0115
0116 Options options_;
0117
0118 private:
0119
0120 template <typename Descriptor>
0121 std::string GetJavaClassFullName(absl::string_view name_without_package,
0122 const Descriptor& descriptor,
0123 bool immutable);
0124 template <typename Descriptor>
0125 std::string GetJavaClassFullName(absl::string_view name_without_package,
0126 const Descriptor& descriptor, bool immutable,
0127 bool kotlin);
0128
0129 template <typename Descriptor>
0130 std::string GetJavaClassPackage(const Descriptor& descriptor, bool immutable);
0131
0132 };
0133
0134 }
0135 }
0136 }
0137 }
0138
0139 #include "google/protobuf/port_undef.inc"
0140
0141 #endif