Do not interpolate variables in leading comments.

There is at least one well-known proto file (plugin.proto) with comments
that include variable-like strings that are not actual variables. This
leads to DFATAL log statements that clutter the output and don't provide
any benefit.
pull/12938/head
Garret Kelly 7 years ago
parent 0f2cfdcc0f
commit cf5a1f2c81
  1. 2
      src/compiler/cpp_generator.cc
  2. 2
      src/compiler/csharp_generator.cc
  3. 2
      src/compiler/node_generator.cc
  4. 2
      src/compiler/objective_c_generator.cc
  5. 2
      src/compiler/php_generator.cc
  6. 1
      src/compiler/protobuf_plugin.h
  7. 2
      src/compiler/python_generator.cc
  8. 2
      src/compiler/ruby_generator.cc
  9. 1
      src/compiler/schema_interface.h

@ -104,7 +104,7 @@ grpc::string GetHeaderPrologue(grpc_generator::File* file,
grpc::string leading_comments = file->GetLeadingComments("//"); grpc::string leading_comments = file->GetLeadingComments("//");
if (!leading_comments.empty()) { if (!leading_comments.empty()) {
printer->Print(vars, "// Original file comments:\n"); printer->Print(vars, "// Original file comments:\n");
printer->Print(leading_comments.c_str()); printer->PrintRaw(leading_comments.c_str());
} }
printer->Print(vars, "#ifndef GRPC_$filename_identifier$__INCLUDED\n"); printer->Print(vars, "#ifndef GRPC_$filename_identifier$__INCLUDED\n");
printer->Print(vars, "#define GRPC_$filename_identifier$__INCLUDED\n"); printer->Print(vars, "#define GRPC_$filename_identifier$__INCLUDED\n");

@ -666,7 +666,7 @@ grpc::string GetServices(const FileDescriptor* file, bool generate_client,
grpc::string leading_comments = GetCsharpComments(file, true); grpc::string leading_comments = GetCsharpComments(file, true);
if (!leading_comments.empty()) { if (!leading_comments.empty()) {
out.Print("// Original file comments:\n"); out.Print("// Original file comments:\n");
out.Print(leading_comments.c_str()); out.PrintRaw(leading_comments.c_str());
} }
out.Print("#pragma warning disable 1591\n"); out.Print("#pragma warning disable 1591\n");

@ -250,7 +250,7 @@ grpc::string GenerateFile(const FileDescriptor* file) {
grpc::string leading_comments = GetNodeComments(file, true); grpc::string leading_comments = GetNodeComments(file, true);
if (!leading_comments.empty()) { if (!leading_comments.empty()) {
out.Print("// Original file comments:\n"); out.Print("// Original file comments:\n");
out.Print(leading_comments.c_str()); out.PrintRaw(leading_comments.c_str());
} }
out.Print("'use strict';\n"); out.Print("'use strict';\n");

@ -65,7 +65,7 @@ static void PrintAllComments(const DescriptorType* desc, Printer* printer) {
printer->Print(" * "); printer->Print(" * ");
size_t start_pos = it->find_first_not_of(' '); size_t start_pos = it->find_first_not_of(' ');
if (start_pos != grpc::string::npos) { if (start_pos != grpc::string::npos) {
printer->Print(it->c_str() + start_pos); printer->PrintRaw(it->c_str() + start_pos);
} }
printer->Print("\n"); printer->Print("\n");
} }

@ -164,7 +164,7 @@ grpc::string GenerateFile(const FileDescriptor* file,
grpc::string leading_comments = GetPHPComments(file, "//"); grpc::string leading_comments = GetPHPComments(file, "//");
if (!leading_comments.empty()) { if (!leading_comments.empty()) {
out.Print("// Original file comments:\n"); out.Print("// Original file comments:\n");
out.Print(leading_comments.c_str()); out.PrintRaw(leading_comments.c_str());
} }
map<grpc::string, grpc::string> vars; map<grpc::string, grpc::string> vars;

@ -141,6 +141,7 @@ class ProtoBufPrinter : public grpc_generator::Printer {
} }
void Print(const char* string) { printer_.Print(string); } void Print(const char* string) { printer_.Print(string); }
void PrintRaw(const char* string) { printer_.PrintRaw(string); }
void Indent() { printer_.Indent(); } void Indent() { printer_.Indent(); }
void Outdent() { printer_.Outdent(); } void Outdent() { printer_.Outdent(); }

@ -101,7 +101,7 @@ void PrivateGenerator::PrintAllComments(StringVector comments,
++it) { ++it) {
size_t start_pos = it->find_first_not_of(' '); size_t start_pos = it->find_first_not_of(' ');
if (start_pos != grpc::string::npos) { if (start_pos != grpc::string::npos) {
out->Print(it->c_str() + start_pos); out->PrintRaw(it->c_str() + start_pos);
} }
out->Print("\n"); out->Print("\n");
} }

@ -174,7 +174,7 @@ grpc::string GetServices(const FileDescriptor* file) {
grpc::string leading_comments = GetRubyComments(file, true); grpc::string leading_comments = GetRubyComments(file, true);
if (!leading_comments.empty()) { if (!leading_comments.empty()) {
out.Print("# Original file comments:\n"); out.Print("# Original file comments:\n");
out.Print(leading_comments.c_str()); out.PrintRaw(leading_comments.c_str());
} }
out.Print("\n"); out.Print("\n");

@ -86,6 +86,7 @@ struct Printer {
virtual void Print(const std::map<grpc::string, grpc::string>& vars, virtual void Print(const std::map<grpc::string, grpc::string>& vars,
const char* template_string) = 0; const char* template_string) = 0;
virtual void Print(const char* string) = 0; virtual void Print(const char* string) = 0;
virtual void PrintRaw(const char* string) = 0;
virtual void Indent() = 0; virtual void Indent() = 0;
virtual void Outdent() = 0; virtual void Outdent() = 0;
}; };

Loading…
Cancel
Save