aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/google/protobuf/compiler/javanano/javanano_message_field.cc
diff options
context:
space:
mode:
authorGravatar Max Cai <maxtroy@google.com>2013-10-14 16:28:08 +0100
committerGravatar Max Cai <maxtroy@google.com>2013-10-16 12:44:35 +0100
commit9a93c5f593043286dc2821e1dae7f6a83a7a5810 (patch)
treeb0f6170c1013239d7cbc558dfd6f5990b91777e5 /src/google/protobuf/compiler/javanano/javanano_message_field.cc
parent665d99f4bccfd8b1edb8778c2c423088a4fdf25f (diff)
Make generated code more aligned with Google Java style.
- Blank line after opening a message class (but not an enum interface). - Let all code blocks insert blank lines before themselves. This applies to 'package' statement, all message classes, enum classes or constant groups, extensions, bitfields, proto fields (one block per field; i.e. accessors don't have blank lines among them), and basic MessageNano methods. In this case we don't need to guess what the next block is and create blank lines for it. - Fixed some newline/indent errors. - Only one SuppressWarnings("hiding") per file. Change-Id: I865f52ad4fb6ea3b3a98b97ac9d78d19fc46c858
Diffstat (limited to 'src/google/protobuf/compiler/javanano/javanano_message_field.cc')
-rw-r--r--src/google/protobuf/compiler/javanano/javanano_message_field.cc9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/google/protobuf/compiler/javanano/javanano_message_field.cc b/src/google/protobuf/compiler/javanano/javanano_message_field.cc
index 027428f0..225cf42c 100644
--- a/src/google/protobuf/compiler/javanano/javanano_message_field.cc
+++ b/src/google/protobuf/compiler/javanano/javanano_message_field.cc
@@ -98,7 +98,7 @@ GenerateMergingCode(io::Printer* printer) const {
printer->Print(variables_,
"if (this.$name$ == null) {\n"
" this.$name$ = new $type$();\n"
- "}");
+ "}\n");
if (descriptor_->type() == FieldDescriptor::TYPE_GROUP) {
printer->Print(variables_,
@@ -173,7 +173,7 @@ GenerateMergingCode(io::Printer* printer) const {
printer->Print(variables_,
"if (!has$capitalized_name$()) {\n"
" set$capitalized_name$(new $type$());\n"
- "}");
+ "}\n");
if (descriptor_->type() == FieldDescriptor::TYPE_GROUP) {
printer->Print(variables_,
@@ -231,10 +231,11 @@ void RepeatedMessageFieldGenerator::
GenerateMergingCode(io::Printer* printer) const {
// First, figure out the length of the array, then parse.
printer->Print(variables_,
- "int arrayLength = com.google.protobuf.nano.WireFormatNano"
+ "int arrayLength = com.google.protobuf.nano.WireFormatNano\n"
" .getRepeatedFieldArrayLength(input, $tag$);\n"
"int i = this.$name$ == null ? 0 : this.$name$.length;\n"
- "$type$[] newArray = new $type$[i + arrayLength];\n"
+ "$type$[] newArray =\n"
+ " new $type$[i + arrayLength];\n"
"if (i != 0) {\n"
" java.lang.System.arraycopy(this.$name$, 0, newArray, 0, i);\n"
"}\n"