33 #include <google/protobuf/compiler/java/java_file.h>
34 #include <google/protobuf/compiler/java/java_helpers.h>
35 #include <google/protobuf/compiler/java/java_options.h>
36 #include <google/protobuf/compiler/java/java_generator.h>
37 #include <google/protobuf/compiler/code_generator.h>
48 return CodeGenerator::Feature::FEATURE_PROTO3_OPTIONAL;
58 std::vector<std::pair<std::string, std::string> >
options;
63 if (
option.first ==
"output_list_file") {
65 }
else if (
option.first ==
"immutable") {
67 }
else if (
option.first ==
"mutable") {
68 *
error =
"Mutable not supported by Kotlin generator";
70 }
else if (
option.first ==
"shared") {
72 }
else if (
option.first ==
"lite") {
74 }
else if (
option.first ==
"annotate_code") {
76 }
else if (
option.first ==
"annotation_list_file") {
79 *
error =
"Unknown generator option: " +
option.first;
91 std::vector<std::string> all_files;
92 std::vector<std::string> all_annotations;
94 std::unique_ptr<FileGenerator> file_generator;
100 if (!file_generator->Validate(
error)) {
105 return std::unique_ptr<io::ZeroCopyOutputStream>(
context->Open(
filename));
109 kotlin_filename += file_generator->GetKotlinClassname();
110 kotlin_filename +=
".kt";
111 all_files.push_back(kotlin_filename);
112 std::string info_full_path = kotlin_filename +
".pb.meta";
114 all_annotations.push_back(info_full_path);
118 auto output = open_file(kotlin_filename);
124 file_options.
annotate_code ? &annotation_collector :
nullptr);
130 auto info_output = open_file(info_full_path);
131 annotations.SerializeToZeroCopyStream(info_output.get());
139 io::Printer srclist_printer(srclist_raw_output.get(),
'$');
140 for (
auto& all_file : all_files) {
141 srclist_printer.
Print(
"$filename$\n",
"filename", all_file);
148 auto annotation_list_raw_output =
150 io::Printer annotation_list_printer(annotation_list_raw_output.get(),
'$');
151 for (
auto& all_annotation : all_annotations) {
152 annotation_list_printer.
Print(
"$filename$\n",
"filename", all_annotation);