Remove no longer needed comment helper.

PiperOrigin-RevId: 547200328
pull/13267/head
Thomas Van Lenten 1 year ago committed by Copybara-Service
parent fcab1a4371
commit b830c62623
  1. 41
      src/google/protobuf/compiler/objectivec/helpers.cc
  2. 8
      src/google/protobuf/compiler/objectivec/helpers.h

@ -341,9 +341,8 @@ std::string ObjCClassDeclaration(absl::string_view class_name) {
return absl::StrCat("GPBObjCClassDeclaration(", class_name, ");");
}
namespace {
std::vector<std::string> ExtractAndEscapeLines(const SourceLocation& location) {
void EmitCommentsString(io::Printer* printer, const SourceLocation& location,
bool prefer_single_line, bool add_leading_newilne) {
absl::string_view comments = location.leading_comments.empty()
? location.trailing_comments
: location.leading_comments;
@ -353,7 +352,7 @@ std::vector<std::string> ExtractAndEscapeLines(const SourceLocation& location) {
raw_lines.pop_back();
}
if (raw_lines.empty()) {
return {};
return;
}
std::vector<std::string> lines;
@ -375,40 +374,6 @@ std::vector<std::string> ExtractAndEscapeLines(const SourceLocation& location) {
{"/*", "/\\*"},
{"*/", "*\\/"}}));
}
return lines;
}
} // namespace
std::string BuildCommentsString(const SourceLocation& location,
bool prefer_single_line) {
std::vector<std::string> lines(ExtractAndEscapeLines(location));
if (lines.empty()) {
return "";
}
if (prefer_single_line && lines.size() == 1) {
return absl::StrCat("/** ", lines[0], " */\n");
}
std::string collector("/**\n");
for (size_t i = 0; i < lines.size(); i++) {
auto& line = lines[i];
if (line.empty()) {
absl::StrAppend(&collector, " *\n");
} else {
absl::StrAppend(&collector, " * ", line, "\n");
}
}
return absl::StrCat(collector, " **/\n");
}
void EmitCommentsString(io::Printer* printer, const SourceLocation& location,
bool prefer_single_line, bool add_leading_newilne) {
std::vector<std::string> lines(ExtractAndEscapeLines(location));
if (lines.empty()) {
return;
}
if (add_leading_newilne) {
printer->Emit("\n");

@ -112,16 +112,10 @@ std::string ObjCClass(absl::string_view class_name);
// be referred to by ObjCClass.
std::string ObjCClassDeclaration(absl::string_view class_name);
// Builds HeaderDoc/appledoc style comments out of the comments in the .proto
// file.
std::string BuildCommentsString(const SourceLocation& location,
bool prefer_single_line);
// Emits HeaderDoc/appledoc style comments out of the comments in the .proto
// file.
void EmitCommentsString(io::Printer* printer, const SourceLocation& location,
bool prefer_single_line,
bool add_leading_newilne = false);
bool prefer_single_line, bool add_leading_newilne);
// Emits HeaderDoc/appledoc style comments out of the comments in the .proto
// file.

Loading…
Cancel
Save