Commit a2484208 authored by Sergio Campamá's avatar Sergio Campamá Committed by Thomas Van Lenten

Fixes extra whitespace on generated comments. (#1950)

Fixes extra whitespace on generated comments.
parent cd561ddd
......@@ -77,7 +77,7 @@ NS_ASSUME_NONNULL_BEGIN
* @param descriptor The descriptor to look for a registered extension on.
* @param fieldNumber The field number of the extension to look for.
*
* @return The registered GPBExtensionDescripto or nil if none was found.
* @return The registered GPBExtensionDescriptor or nil if none was found.
**/
- (nullable GPBExtensionDescriptor *)extensionForDescriptor:(GPBDescriptor *)descriptor
fieldNumber:(NSInteger)fieldNumber;
......
......@@ -850,14 +850,17 @@ string BuildCommentsString(const SourceLocation& location,
string final_comments;
string epilogue;
bool add_leading_space = false;
if (prefer_single_line && lines.size() == 1) {
prefix = "/** ";
suffix = " */\n";
} else {
prefix = " * ";
prefix = "* ";
suffix = "\n";
final_comments += "/**\n";
epilogue = " **/\n";
add_leading_space = true;
}
for (int i = 0; i < lines.size(); i++) {
......@@ -868,7 +871,12 @@ string BuildCommentsString(const SourceLocation& location,
// Decouple / from * to not have inline comments inside comments.
line = StringReplace(line, "/*", "/\\*", true);
line = StringReplace(line, "*/", "*\\/", true);
final_comments += prefix + line + suffix;
line = prefix + line;
StripWhitespace(&line);
// If not a one line, need to add the first space before *, as
// StripWhitespace would have removed it.
line = (add_leading_space ? " " : "") + line;
final_comments += line + suffix;
}
final_comments += epilogue;
return final_comments;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment