Skip to content

Commit

Permalink
fix(proto_indexer): properly handle comments that end with an empty c…
Browse files Browse the repository at this point in the history
…ommented line (#5427)
  • Loading branch information
wcalandro committed Nov 5, 2022
1 parent d746a50 commit e979b1e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion kythe/cxx/indexer/proto/file_descriptor_walker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ Location FileDescriptorWalker::LocationOfLeadingComments(
comment_location.end = entity_location.begin - line_offset_of_entity - 1;
int next_line_number = entity_start_line - 1;
absl::string_view bottom_line = line_index_.GetLine(next_line_number);
while (RE2::FullMatch(ToStringPiece(bottom_line), R"(\s*\*/?\s*)")) {
while (
RE2::FullMatch(ToStringPiece(bottom_line), R"((\s*\*/?\s*)|(\s*//\n))")) {
comment_location.begin -= bottom_line.size();
--next_line_number;
bottom_line = line_index_.GetLine(next_line_number);
Expand Down
6 changes: 4 additions & 2 deletions kythe/cxx/indexer/proto/testdata/basic/doc.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@ syntax = "proto2";

package proto_kythe_test;

//- @+8"DocComment" defines/binding DocCommentMessage
//- @+10"DocComment" defines/binding DocCommentMessage
//- DocCommentComment.node/kind doc
//- DocCommentComment documents DocCommentMessage
//- DocCommentComment.text
//- "A doc comment is a piece of text which documents a code element.\nDoc comments can have html code in them."
//- "A doc comment is a piece of text which documents a code element.\nDoc comments can have html code in them.\n\n"

// A doc comment is a piece of text which documents a code element.
// Doc comments can have html code in them.
//
//
message DocComment {

//- Type1Comment.node/kind doc
Expand Down

0 comments on commit e979b1e

Please sign in to comment.