You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by je...@apache.org on 2022/04/19 09:43:29 UTC

[thrift] branch master updated: change the java gen @SuppressWarnings location

This is an automated email from the ASF dual-hosted git repository.

jensg pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/thrift.git


The following commit(s) were added to refs/heads/master by this push:
     new 35d22c526 change the java gen @SuppressWarnings location
35d22c526 is described below

commit 35d22c526e5fcf7eae826e873184c5d3dc51b5c0
Author: Jiayu Liu <ji...@airbnb.com>
AuthorDate: Thu Apr 14 11:49:10 2022 +0800

    change the java gen @SuppressWarnings location
---
 compiler/cpp/src/thrift/generate/t_java_generator.cc | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/compiler/cpp/src/thrift/generate/t_java_generator.cc b/compiler/cpp/src/thrift/generate/t_java_generator.cc
index 6f4267512..a875c9b62 100644
--- a/compiler/cpp/src/thrift/generate/t_java_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_java_generator.cc
@@ -481,7 +481,8 @@ string t_java_generator::java_package() {
 }
 
 string t_java_generator::java_suppressions() {
-  return "@SuppressWarnings({\"cast\", \"rawtypes\", \"serial\", \"unchecked\", \"unused\"})\n";
+  return "@SuppressWarnings({\"cast\", \"rawtypes\", \"serial\", \"unchecked\", \"unused\"})"
+         + endl;
 }
 
 string t_java_generator::java_nullable_annotation() {
@@ -621,7 +622,6 @@ void t_java_generator::generate_consts(std::vector<t_const*> consts) {
 
   // Print header
   f_consts << autogen_comment() << java_package() << java_suppressions();
-
   f_consts << "public class " << make_valid_java_identifier(program_name_) << "Constants {" << endl
            << endl;
   indent_up();
@@ -837,7 +837,7 @@ void t_java_generator::generate_java_struct(t_struct* tstruct, bool is_exception
   ofstream_with_content_based_conditional_update f_struct;
   f_struct.open(f_struct_name.c_str());
 
-  f_struct << autogen_comment() << java_package() << java_suppressions();
+  f_struct << autogen_comment() << java_package();
 
   generate_java_struct_definition(f_struct, tstruct, is_exception);
   f_struct.close();
@@ -855,9 +855,10 @@ void t_java_generator::generate_java_union(t_struct* tstruct) {
   ofstream_with_content_based_conditional_update f_struct;
   f_struct.open(f_struct_name.c_str());
 
-  f_struct << autogen_comment() << java_package() << java_suppressions();
+  f_struct << autogen_comment() << java_package();
 
   generate_java_doc(f_struct, tstruct);
+  f_struct << java_suppressions();
 
   bool is_final = (tstruct->annotations_.find("final") != tstruct->annotations_.end());
   bool is_deprecated = this->is_deprecated(tstruct->annotations_);
@@ -1485,6 +1486,7 @@ void t_java_generator::generate_java_struct_definition(ostream& out,
                                                        bool in_class,
                                                        bool is_result) {
   generate_java_doc(out, tstruct);
+  indent(out) << java_suppressions();
 
   bool is_final = (tstruct->annotations_.find("final") != tstruct->annotations_.end());
   bool is_deprecated = this->is_deprecated(tstruct->annotations_);
@@ -2982,11 +2984,12 @@ void t_java_generator::generate_service(t_service* tservice) {
   string f_service_name = package_dir_ + "/" + make_valid_java_filename(service_name_) + ".java";
   f_service_.open(f_service_name.c_str());
 
-  f_service_ << autogen_comment() << java_package() << java_suppressions();
+  f_service_ << autogen_comment() << java_package();
 
   if (!suppress_generated_annotations_) {
     generate_javax_generated_annotation(f_service_);
   }
+  f_service_ << java_suppressions();
   f_service_ << "public class " << service_name_ << " {" << endl << endl;
   indent_up();