File indexing completed on 2025-01-31 10:11:59
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 namespace google {
0021 namespace protobuf {
0022 class Descriptor;
0023 class EnumDescriptor;
0024 class FieldDescriptor;
0025 class FileDescriptor;
0026 class ServiceDescriptor;
0027
0028 namespace compiler {
0029 namespace java {
0030
0031
0032 enum NameEquality { NO_MATCH, EXACT_EQUAL, EQUAL_IGNORE_CASE };
0033
0034
0035
0036
0037 class ClassNameResolver {
0038 public:
0039 explicit ClassNameResolver(const Options& options = {}) : options_(options) {}
0040 ~ClassNameResolver() = default;
0041
0042 ClassNameResolver(const ClassNameResolver&) = delete;
0043 ClassNameResolver& operator=(const ClassNameResolver&) = delete;
0044
0045
0046 std::string GetFileClassName(const FileDescriptor* file, bool immutable);
0047 std::string GetFileClassName(const FileDescriptor* file, bool immutable,
0048 bool kotlin);
0049
0050 std::string GetFileImmutableClassName(const FileDescriptor* file);
0051
0052
0053 std::string GetFileDefaultImmutableClassName(const FileDescriptor* file);
0054
0055
0056
0057 bool HasConflictingClassName(const FileDescriptor* file,
0058 absl::string_view classname,
0059 NameEquality equality_mode);
0060
0061
0062
0063
0064
0065 std::string GetDescriptorClassName(const FileDescriptor* file);
0066
0067
0068 std::string GetClassName(const Descriptor* descriptor, bool immutable);
0069 std::string GetClassName(const Descriptor* descriptor, bool immutable,
0070 bool kotlin);
0071 std::string GetClassName(const EnumDescriptor* descriptor, bool immutable);
0072 std::string GetClassName(const EnumDescriptor* descriptor, bool immutable,
0073 bool kotlin);
0074 std::string GetClassName(const ServiceDescriptor* descriptor, bool immutable);
0075 std::string GetClassName(const ServiceDescriptor* descriptor, bool immutable,
0076 bool kotlin);
0077 std::string GetClassName(const FileDescriptor* descriptor, bool immutable);
0078 std::string GetClassName(const FileDescriptor* descriptor, bool immutable,
0079 bool kotlin);
0080
0081 template <class DescriptorType>
0082 std::string GetImmutableClassName(const DescriptorType* descriptor) {
0083 return GetClassName(descriptor, true);
0084 }
0085 template <class DescriptorType>
0086 std::string GetMutableClassName(const DescriptorType* descriptor) {
0087 return GetClassName(descriptor, false);
0088 }
0089
0090
0091 std::string GetExtensionIdentifierName(const FieldDescriptor* descriptor,
0092 bool immutable);
0093 std::string GetExtensionIdentifierName(const FieldDescriptor* descriptor,
0094 bool immutable, bool kotlin);
0095
0096
0097
0098
0099
0100 std::string GetJavaImmutableClassName(const Descriptor* descriptor);
0101 std::string GetJavaImmutableClassName(const EnumDescriptor* descriptor);
0102 std::string GetJavaImmutableClassName(const ServiceDescriptor* descriptor);
0103 std::string GetKotlinFactoryName(const Descriptor* descriptor);
0104 std::string GetKotlinExtensionsClassName(const Descriptor* descriptor);
0105 std::string GetKotlinExtensionsClassNameEscaped(const Descriptor* descriptor);
0106 std::string GetJavaMutableClassName(const Descriptor* descriptor);
0107 std::string GetJavaMutableClassName(const EnumDescriptor* descriptor);
0108 std::string GetJavaMutableClassName(const ServiceDescriptor* descriptor);
0109
0110 std::string GetDowngradedFileClassName(const FileDescriptor* file);
0111 std::string GetDowngradedClassName(const Descriptor* descriptor);
0112
0113
0114
0115 std::string GetClassFullName(absl::string_view name_without_package,
0116 const FileDescriptor* file, bool immutable,
0117 bool is_own_file);
0118 std::string GetClassFullName(absl::string_view name_without_package,
0119 const FileDescriptor* file, bool immutable,
0120 bool is_own_file, bool kotlin);
0121
0122 Options options_;
0123
0124 private:
0125
0126 std::string GetJavaClassFullName(absl::string_view name_without_package,
0127 const FileDescriptor* file, bool immutable);
0128 std::string GetJavaClassFullName(absl::string_view name_without_package,
0129 const FileDescriptor* file, bool immutable,
0130 bool kotlin);
0131
0132 absl::flat_hash_map<const FileDescriptor*, std::string>
0133 file_immutable_outer_class_names_;
0134 };
0135
0136 }
0137 }
0138 }
0139 }
0140
0141 #include "google/protobuf/port_undef.inc"
0142
0143 #endif