diff options
author | Max Cai <maxtroy@google.com> | 2013-07-24 14:16:38 +0100 |
---|---|---|
committer | Max Cai <maxtroy@google.com> | 2013-07-25 19:49:23 +0100 |
commit | 4c4d639025f35aa10030b02b165f489168f4d293 (patch) | |
tree | a1735652fcea7573f36c9f0a40713ef36ae17181 /java/src/test | |
parent | 09400156818ec809cfc37a950d8b599b52cef88f (diff) | |
download | protobuf-4c4d639025f35aa10030b02b165f489168f4d293.tar.gz protobuf-4c4d639025f35aa10030b02b165f489168f4d293.tar.bz2 protobuf-4c4d639025f35aa10030b02b165f489168f4d293.zip |
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 'java/src/test')
-rw-r--r-- | java/src/test/java/com/google/protobuf/NanoTest.java | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/java/src/test/java/com/google/protobuf/NanoTest.java b/java/src/test/java/com/google/protobuf/NanoTest.java index 92ddda62..0ea80d40 100644 --- a/java/src/test/java/com/google/protobuf/NanoTest.java +++ b/java/src/test/java/com/google/protobuf/NanoTest.java @@ -35,6 +35,8 @@ import com.google.protobuf.nano.Extensions; import com.google.protobuf.nano.Extensions.AnotherMessage; import com.google.protobuf.nano.InternalNano; import com.google.protobuf.nano.MessageNano; +import com.google.protobuf.nano.MultipleImportingNonMultipleNano1; +import com.google.protobuf.nano.MultipleImportingNonMultipleNano2; import com.google.protobuf.nano.NanoOuterClass; import com.google.protobuf.nano.NanoOuterClass.TestAllTypesNano; import com.google.protobuf.nano.RecursiveMessageNano; @@ -2039,6 +2041,20 @@ public class NanoTest extends TestCase { assertEquals(nestedMsg2.bb, newMsg.repeatedNestedMessage[2].bb); } + /** + * Tests that code generation with mixed values of the java_multiple_files + * options between the main source file and the imported source files would + * generate correct references. Any error would cause this method to fail + * compilation. + */ + public void testNanoMultipleImportingNonMultiple() throws Exception { + UnittestImportNano.ImportMessageNano importMsg = new UnittestImportNano.ImportMessageNano(); + MultipleImportingNonMultipleNano1 nano1 = new MultipleImportingNonMultipleNano1(); + nano1.field = importMsg; + MultipleImportingNonMultipleNano2 nano2 = new MultipleImportingNonMultipleNano2(); + nano2.nano1 = nano1; + } + public void testNanoDefaults() throws Exception { TestAllTypesNano msg = new TestAllTypesNano(); for (int i = 0; i < 2; i++) { |