Skip to content

Commit

Permalink
fix(proto_indexer): use modern presence check (#5856)
Browse files Browse the repository at this point in the history
  • Loading branch information
schroederc committed Sep 18, 2023
1 parent 5a8aab9 commit 9c7b2dd
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions kythe/cxx/indexer/proto/marked_source.cc
Expand Up @@ -151,16 +151,19 @@ std::optional<MarkedSource> GenerateMarkedSourceForDescriptor(
MarkedSource ms;
ms.set_post_child_text(" ");
if (!descriptor->real_containing_oneof() && !descriptor->is_map() &&
(descriptor->has_optional_keyword() || descriptor->is_required() ||
descriptor->is_repeated())) {
(descriptor->has_presence() || descriptor->is_repeated())) {
auto* mod = ms.add_child();
mod->set_kind(MarkedSource::MODIFIER);
if (descriptor->has_optional_keyword()) {
mod->set_pre_text("optional");
} else if (descriptor->is_required()) {
mod->set_pre_text("required");
} else if (descriptor->is_repeated()) {
mod->set_pre_text("repeated");
switch (descriptor->label()) {
case google::protobuf::FieldDescriptor::Label::LABEL_OPTIONAL:
mod->set_pre_text("optional");
break;
case google::protobuf::FieldDescriptor::Label::LABEL_REQUIRED:
mod->set_pre_text("required");
break;
case google::protobuf::FieldDescriptor::Label::LABEL_REPEATED:
mod->set_pre_text("repeated");
break;
}
}
if (const std::optional<MarkedSource> t =
Expand Down

0 comments on commit 9c7b2dd

Please sign in to comment.