diff options
author | Max Cai <maxtroy@google.com> | 2013-10-14 16:28:08 +0100 |
---|---|---|
committer | Max Cai <maxtroy@google.com> | 2013-10-16 12:44:35 +0100 |
commit | 9a93c5f593043286dc2821e1dae7f6a83a7a5810 (patch) | |
tree | b0f6170c1013239d7cbc558dfd6f5990b91777e5 /src/google/protobuf/compiler/javanano/javanano_file.cc | |
parent | 665d99f4bccfd8b1edb8778c2c423088a4fdf25f (diff) | |
download | protobuf-9a93c5f593043286dc2821e1dae7f6a83a7a5810.tar.gz protobuf-9a93c5f593043286dc2821e1dae7f6a83a7a5810.tar.bz2 protobuf-9a93c5f593043286dc2821e1dae7f6a83a7a5810.zip |
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_file.cc')
-rw-r--r-- | src/google/protobuf/compiler/javanano/javanano_file.cc | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/google/protobuf/compiler/javanano/javanano_file.cc b/src/google/protobuf/compiler/javanano/javanano_file.cc index 75d0e44f..4e9fe0a8 100644 --- a/src/google/protobuf/compiler/javanano/javanano_file.cc +++ b/src/google/protobuf/compiler/javanano/javanano_file.cc @@ -163,17 +163,22 @@ void FileGenerator::Generate(io::Printer* printer) { // We don't import anything because we refer to all classes by their // fully-qualified names in the generated source. printer->Print( - "// Generated by the protocol buffer compiler. DO NOT EDIT!\n" - "\n"); + "// Generated by the protocol buffer compiler. DO NOT EDIT!\n"); if (!java_package_.empty()) { printer->Print( - "package $package$;\n" - "\n", + "\n" + "package $package$;\n", "package", java_package_); } + // Note: constants (from enums, emitted in the loop below) may have the same names as constants + // in the nested classes. This causes Java warnings, but is not fatal, so we suppress those + // warnings here in the top-most class declaration. printer->Print( + "\n" + "@SuppressWarnings(\"hiding\")\n" "public final class $classname$ {\n" + " \n" " private $classname$() {}\n", "classname", classname_); printer->Indent(); @@ -223,12 +228,11 @@ static void GenerateSibling(const string& package_dir, io::Printer printer(output.get(), '$'); printer.Print( - "// Generated by the protocol buffer compiler. DO NOT EDIT!\n" - "\n"); + "// Generated by the protocol buffer compiler. DO NOT EDIT!\n"); if (!java_package.empty()) { printer.Print( - "package $package$;\n" - "\n", + "\n" + "package $package$;\n", "package", java_package); } |