File indexing completed on 2025-01-31 10:11:58
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_FILE_H__
0013 #define GOOGLE_PROTOBUF_COMPILER_JAVA_FILE_H__
0014
0015 #include <memory>
0016 #include <string>
0017 #include <vector>
0018
0019 #include "google/protobuf/compiler/java/options.h"
0020 #include "google/protobuf/port.h"
0021
0022 namespace google {
0023 namespace protobuf {
0024 class FileDescriptor;
0025 namespace io {
0026 class Printer;
0027 }
0028 namespace compiler {
0029 class GeneratorContext;
0030 namespace java {
0031 class Context;
0032 class MessageGenerator;
0033 class GeneratorFactory;
0034 class ExtensionGenerator;
0035 class ClassNameResolver;
0036 }
0037 }
0038 }
0039 }
0040
0041 namespace google {
0042 namespace protobuf {
0043 namespace compiler {
0044 namespace java {
0045
0046 class FileGenerator {
0047 public:
0048 FileGenerator(const FileDescriptor* file, const Options& options,
0049 bool immutable_api = true);
0050 FileGenerator(const FileGenerator&) = delete;
0051 FileGenerator& operator=(const FileGenerator&) = delete;
0052 ~FileGenerator();
0053
0054
0055
0056
0057 bool Validate(std::string* error);
0058
0059 void Generate(io::Printer* printer);
0060
0061 std::string GetKotlinClassname();
0062 void GenerateKotlin(io::Printer* printer);
0063 void GenerateKotlinSiblings(const std::string& package_dir,
0064 GeneratorContext* generator_context,
0065 std::vector<std::string>* file_list,
0066 std::vector<std::string>* annotation_list);
0067
0068
0069
0070
0071 void GenerateSiblings(const std::string& package_dir,
0072 GeneratorContext* generator_context,
0073 std::vector<std::string>* file_list,
0074 std::vector<std::string>* annotation_list);
0075
0076 const std::string& java_package() { return java_package_; }
0077 const std::string& classname() { return classname_; }
0078
0079 private:
0080 void GenerateDescriptorInitializationCodeForImmutable(io::Printer* printer);
0081
0082 bool ShouldIncludeDependency(const FileDescriptor* descriptor,
0083 bool immutable_api_);
0084
0085 const FileDescriptor* file_;
0086 std::string java_package_;
0087 std::string classname_;
0088
0089 std::vector<std::unique_ptr<MessageGenerator>> message_generators_;
0090 std::vector<std::unique_ptr<ExtensionGenerator>> extension_generators_;
0091 std::unique_ptr<Context> context_;
0092 std::unique_ptr<GeneratorFactory> generator_factory_;
0093 ClassNameResolver* name_resolver_;
0094 const Options options_;
0095 bool immutable_api_;
0096 };
0097
0098 }
0099 }
0100 }
0101 }
0102
0103 #endif