aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/google/protobuf/compiler/javanano/javanano_generator.cc
diff options
context:
space:
mode:
authorGravatar Max Cai <maxtroy@google.com>2013-07-24 14:16:38 +0100
committerGravatar Max Cai <maxtroy@google.com>2013-07-25 19:49:23 +0100
commit4c4d639025f35aa10030b02b165f489168f4d293 (patch)
treea1735652fcea7573f36c9f0a40713ef36ae17181 /src/google/protobuf/compiler/javanano/javanano_generator.cc
parent09400156818ec809cfc37a950d8b599b52cef88f (diff)
Per-file java_multiple_files flag.
Imported source files may have different values for the 'java_multiple_files' option to the main source file's. Whether the fully qualified Java name of an entity should include the outer class name depends on the flag value in the file defining the referenced entity, not the main file. This CL loads the flag values from the main and all transitively imported files into the params, and generates the fully qualified Java names accordingly. If the generator option 'java_multiple_files' is set, its value overrides any in-file values in all source/imported files. This is because this generator option is typically used on either none or all source files. Change-Id: Id6a4a42426d68961dc669487d38f35530deb7d8e
Diffstat (limited to 'src/google/protobuf/compiler/javanano/javanano_generator.cc')
-rw-r--r--src/google/protobuf/compiler/javanano/javanano_generator.cc11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/google/protobuf/compiler/javanano/javanano_generator.cc b/src/google/protobuf/compiler/javanano/javanano_generator.cc
index 19a3dccd..4b6b6a59 100644
--- a/src/google/protobuf/compiler/javanano/javanano_generator.cc
+++ b/src/google/protobuf/compiler/javanano/javanano_generator.cc
@@ -57,6 +57,10 @@ void UpdateParamsRecursively(Params& params,
params.set_java_package(
file->name(), file->options().java_package());
}
+ if (file->options().has_java_multiple_files()) {
+ params.set_java_multiple_files(
+ file->name(), file->options().java_multiple_files());
+ }
// Loop through all dependent files recursively
// adding dep
@@ -84,11 +88,6 @@ bool JavaNanoGenerator::Generate(const FileDescriptor* file,
string output_list_file;
Params params(file->name());
- // Get options from the proto file
- if (file->options().has_java_multiple_files()) {
- params.set_java_multiple_files(file->options().java_multiple_files());
- }
-
// Update per file params
UpdateParamsRecursively(params, file);
@@ -118,7 +117,7 @@ bool JavaNanoGenerator::Generate(const FileDescriptor* file,
} else if (options[i].first == "store_unknown_fields") {
params.set_store_unknown_fields(options[i].second == "true");
} else if (options[i].first == "java_multiple_files") {
- params.set_java_multiple_files(options[i].second == "true");
+ params.set_override_java_multiple_files(options[i].second == "true");
} else {
*error = "Ignore unknown javanano generator option: " + options[i].first;
}