我的源代码中有一些protobuf文件,例如common.proto。
看起来ctags不会为消息生成标签。如何生成消息的标记,以便可以搜索消息中存在的字段。
答案 0 :(得分:1)
$ cat input.proto
package TestPackage;
message Message1 {
required string field1 = 1 [default="; required string thisIsNotAField = 1;"];
//optional string commentedField2 = 2;
/* optional string commentedField3 = 3; */
}
message Message2 {
message NestedMessage {
required string field2 = 2;
}
enum Enum1 {
YES = 1;
NO = 2;
}
repeated NestedMessage field3 = 3;
optional Enum1 field4 = 4;
}
message Message3 {
required Message2.NestedMessage field5 = 5;
required .TestPackage.Message2.Enum1 field6 = 6;
extensions 7 to 8;
}
extend Message3 {
optional Message2 . NestedMessage field7 = 7;
repeated int32 field8 = 8 [packed=true];
}
service Service1 {
rpc Method1(Message1) returns(Message2);
}
$ ./ctags -o - input.proto
Enum1 Units/simple-protobuf.d/input.proto /^ enum Enum1 {$/;" g
Message1 Units/simple-protobuf.d/input.proto /^message Message1 {$/;" m
Message2 Units/simple-protobuf.d/input.proto /^message Message2 {$/;" m
Message3 Units/simple-protobuf.d/input.proto /^message Message3 {$/;" m
NO Units/simple-protobuf.d/input.proto /^ NO = 2;$/;" e
NestedMessage Units/simple-protobuf.d/input.proto /^ message NestedMessage {$/;" m
Service1 Units/simple-protobuf.d/input.proto /^service Service1 {$/;" s
TestPackage Units/simple-protobuf.d/input.proto /^package TestPackage;$/;" p
YES Units/simple-protobuf.d/input.proto /^ YES = 1;$/;" e
field1 Units/simple-protobuf.d/input.proto /^ required string field1 = 1 [default="; required string thisIsNotAField = 1;"];$/;" f
field2 Units/simple-protobuf.d/input.proto /^ required string field2 = 2;$/;" f
field3 Units/simple-protobuf.d/input.proto /^ repeated NestedMessage field3 = 3;$/;" f
field4 Units/simple-protobuf.d/input.proto /^ optional Enum1 field4 = 4;$/;" f
field5 Units/simple-protobuf.d/input.proto /^ required Message2.NestedMessage field5 = 5;$/;" f
field6 Units/simple-protobuf.d/input.proto /^ required .TestPackage.Message2.Enum1 field6 = 6;$/;" f
field7 Units/simple-protobuf.d/input.proto /^ optional Message2 . NestedMessage field7 = 7;$/;" f
field8 Units/simple-protobuf.d/input.proto /^ repeated int32 field8 = 8 [packed=true];$/;" f