aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/google/protobuf/compiler/javanano/javanano_helpers.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_helpers.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_helpers.cc')
-rw-r--r--src/google/protobuf/compiler/javanano/javanano_helpers.cc4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/google/protobuf/compiler/javanano/javanano_helpers.cc b/src/google/protobuf/compiler/javanano/javanano_helpers.cc
index 2564a587..525b9dd9 100644
--- a/src/google/protobuf/compiler/javanano/javanano_helpers.cc
+++ b/src/google/protobuf/compiler/javanano/javanano_helpers.cc
@@ -210,7 +210,7 @@ string FileJavaPackage(const Params& params, const FileDescriptor* file) {
string ToJavaName(const Params& params, const string& full_name,
const FileDescriptor* file) {
string result;
- if (params.java_multiple_files()) {
+ if (params.java_multiple_files(file->name())) {
result = FileJavaPackage(params, file);
} else {
result = ClassName(params, file);
@@ -283,7 +283,7 @@ string ClassName(const Params& params, const EnumDescriptor* descriptor) {
// If the java_multiple_files option is present, we will generate enums into separate
// classes, each named after the original enum type. This takes precedence over
// any outer_classname.
- if (params.java_multiple_files() && last_dot_in_name != string::npos) {
+ if (params.java_multiple_files(file_name) && last_dot_in_name != string::npos) {
string enum_simple_name = full_name.substr(last_dot_in_name + 1);
if (!result.empty()) {
result += ".";