Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(proto_indexer): add types to field MarkedSource #5837

Merged
merged 2 commits into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 21 additions & 1 deletion kythe/cxx/indexer/proto/marked_source.cc
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,27 @@ std::optional<MarkedSource> GenerateMarkedSourceForDescriptor(
full_name = descriptor->full_name();
}
MarkedSource ms;
if (GenerateMarkedSourceForDottedName(full_name, &ms)) {
auto* type = ms.add_child();
type->set_kind(MarkedSource::TYPE);
switch (descriptor->type()) {
case google::protobuf::FieldDescriptor::TYPE_MESSAGE:
if (!GenerateMarkedSourceForDottedName(
descriptor->message_type()->full_name(), type->add_child())) {
return std::nullopt;
}
break;
case google::protobuf::FieldDescriptor::TYPE_ENUM:
if (!GenerateMarkedSourceForDottedName(
descriptor->enum_type()->full_name(), type->add_child())) {
return std::nullopt;
}
break;
default:
type->set_pre_text(descriptor->type_name());
break;
}
type->set_post_text(" ");
if (GenerateMarkedSourceForDottedName(full_name, ms.add_child())) {
return ms;
}
return std::nullopt;
Expand Down
5 changes: 3 additions & 2 deletions kythe/cxx/indexer/proto/testdata/basic/message-fields.proto
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ message MessageFields {
//- FieldNameNode.subkind field
//- FieldNameNode typed Type1Node
//- FieldNameNode code FNRoot
//- FNRoot child.0 FNQualName
//- FNRoot child.1 FNIdent
//- FNRoot child.1 FNName
//- FNName child.0 FNQualName
//- FNName child.1 FNIdent
//- FNIdent.pre_text field_name
//- FNIdent.kind "IDENTIFIER"
//- FNQualName.kind "CONTEXT"
Expand Down
8 changes: 6 additions & 2 deletions kythe/cxx/indexer/proto/testdata/basic/oneof.proto
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,12 @@ message Container {
//- TextVariant childof ContainerMessage
//- TextVariant childof NamedVariantType
//- TextVariant code TVRoot
//- TVRoot child.0 TVContext
//- TVRoot child.1 TVIdent
//- TVRoot child.0 TVType
//- TVType.kind "TYPE"
//- TVType.pre_text "string"
//- TVRoot child.1 TVName
//- TVName child.0 TVContext
//- TVName child.1 TVIdent
//- TVIdent.pre_text "text"
//- TVContext child.0 TVContext0
//- TVContext child.1 TVContext1
Expand Down
11 changes: 8 additions & 3 deletions kythe/cxx/indexer/proto/testdata/basic/signatures.proto
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,23 @@ package proto_kythe_test;
message Message {
//- @R defines/binding R
//- R.code/rendered/qualified_name "proto_kythe_test.Message.R"
//- R.code/rendered/signature "R"
//- R.code/rendered/signature "string R"
required string R = 1;

//- @I defines/binding I
//- I.code/rendered/qualified_name "proto_kythe_test.Message.I"
//- I.code/rendered/signature "I"
//- I.code/rendered/signature "int32 I"
optional int32 I = 2;

//- @L defines/binding L
//- L.code/rendered/qualified_name "proto_kythe_test.Message.L"
//- L.code/rendered/signature "L"
//- L.code/rendered/signature "Message L"
repeated Message L = 3;

//- @#1E defines/binding E
//- E.code/rendered/qualified_name "proto_kythe_test.Message.E"
//- E.code/rendered/signature "Enum E"
optional Enum E = 4;
}

//- @Enum defines/binding Enum
Expand Down