本文整理汇总了Java中com.google.protobuf.DescriptorProtos.DescriptorProto.Builder方法的典型用法代码示例。如果您正苦于以下问题:Java DescriptorProto.Builder方法的具体用法?Java DescriptorProto.Builder怎么用?Java DescriptorProto.Builder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.protobuf.DescriptorProtos.DescriptorProto
的用法示例。
在下文中一共展示了DescriptorProto.Builder方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: makeCanonicalProto
import com.google.protobuf.DescriptorProtos.DescriptorProto; //导入方法依赖的package包/类
private FileDescriptorProto makeCanonicalProto(final FileDescriptor fileDescriptor) {
final FileDescriptorProto.Builder protoBuilder =
FileDescriptorProto.newBuilder(fileDescriptor.toProto());
for (final FieldDescriptorProto.Builder field : protoBuilder.getExtensionBuilderList()) {
makeCanonicalField(field, fileDescriptor.findExtensionByName(field.getName()));
}
for (final DescriptorProto.Builder message : protoBuilder.getMessageTypeBuilderList()) {
makeCanonicalMessage(message, fileDescriptor.findMessageTypeByName(message.getName()));
}
// for (EnumDescriptorProto.Builder enumProto :
// protoBuilder.getEnumTypeBuilderList()) {
// makeCanonicalEnum(enumProto,
// fileDescriptor.findEnumTypeByName(enumProto.getName()));
// }
for (final ServiceDescriptorProto.Builder serviceProto : protoBuilder.getServiceBuilderList()) {
makeCanonicalService(serviceProto, fileDescriptor.findServiceByName(serviceProto.getName()));
}
// TODO: incorporate options' tree walking into canonicalization to eliminate double walking
return OptionResolver.newBuilder().setCustomOptionsAsExtensions(false)
.resolveAllOptionsFor(fileDescriptor, protoBuilder).build();
}
示例2: buildAllOptions
import com.google.protobuf.DescriptorProtos.DescriptorProto; //导入方法依赖的package包/类
private void buildAllOptions(final FileDescriptorProto.Builder proto) {
if (!buildOptions(proto.getOptionsBuilder())) {
proto.clearOptions();
}
for (final FieldDescriptorProto.Builder extensionProto : proto.getExtensionBuilderList()) {
if (!buildOptions(extensionProto.getOptionsBuilder())) {
extensionProto.clearOptions();
}
}
for (final EnumDescriptorProto.Builder enumProto : proto.getEnumTypeBuilderList()) {
buildAllOptions(enumProto);
}
for (final ServiceDescriptorProto.Builder serviceProto : proto.getServiceBuilderList()) {
buildAllOptions(serviceProto);
}
for (final DescriptorProto.Builder messageProto : proto.getMessageTypeBuilderList()) {
buildAllOptions(messageProto);
}
}
示例3: makeCanonicalProto
import com.google.protobuf.DescriptorProtos.DescriptorProto; //导入方法依赖的package包/类
private FileDescriptorProto makeCanonicalProto(final FileDescriptor file) {
final FileDescriptorProto.Builder protoBuilder = FileDescriptorProto.newBuilder(file.toProto());
for (final FieldDescriptorProto.Builder field : protoBuilder.getExtensionBuilderList()) {
makeCanonicalField(field, file.findExtensionByName(field.getName()));
}
for (final DescriptorProto.Builder message : protoBuilder.getMessageTypeBuilderList()) {
makeCanonicalMessage(message, file.findMessageTypeByName(message.getName()));
}
// for (EnumDescriptorProto.Builder enumProto :
// protoBuilder.getEnumTypeBuilderList()) {
// makeCanonicalEnum(enumProto,
// file.findEnumTypeByName(enumProto.getName()));
// }
for (final ServiceDescriptorProto.Builder serviceProto : protoBuilder.getServiceBuilderList()) {
makeCanonicalService(serviceProto, file.findServiceByName(serviceProto.getName()));
}
return OptionResolver.newBuilder().setCustomOptionsAsExtensions(reparseCustomOptions)
.resolveAllOptionsFor(file, protoBuilder).build();
}
示例4: makeProtoRefsRelative
import com.google.protobuf.DescriptorProtos.DescriptorProto; //导入方法依赖的package包/类
@SuppressWarnings("null")
public static FileDescriptorProto.Builder makeProtoRefsRelative(final FileDescriptorProto proto,
final FieldTypeRefsMode fieldTypeRefsMode) {
if (fieldTypeRefsMode == FieldTypeRefsMode.AS_IS) {
return FileDescriptorProto.newBuilder(proto);
}
final FileDescriptorProto.Builder protoBuilder = FileDescriptorProto.newBuilder(proto);
final String packagePath = "." + proto.getPackage();
for (final FieldDescriptorProto.Builder field : protoBuilder.getExtensionBuilderList()) {
makeFieldRefsRelative(packagePath, field, fieldTypeRefsMode, packagePath);
}
for (final DescriptorProto.Builder message : protoBuilder.getMessageTypeBuilderList()) {
makeMessageRefsRelative(packagePath, message, fieldTypeRefsMode, packagePath);
}
return protoBuilder;
}
示例5: accept
import com.google.protobuf.DescriptorProtos.DescriptorProto; //导入方法依赖的package包/类
@Accepts
protected void accept(DescriptorProto.Builder message) {
MessageNodeInfo messageInfo =
(MessageNodeInfo) pushParent(BuilderVisitorNodeInfo.create(message, currentFile));
visitRepeated(DescriptorProto.FIELD_FIELD_NUMBER);
visitRepeated(DescriptorProto.NESTED_TYPE_FIELD_NUMBER);
visitRepeated(DescriptorProto.ENUM_TYPE_FIELD_NUMBER);
visitRepeated(DescriptorProto.EXTENSION_FIELD_NUMBER);
visit(message.getOptionsBuilder());
popExpectedParent(message);
}
示例6: processAddedFields
import com.google.protobuf.DescriptorProtos.DescriptorProto; //导入方法依赖的package包/类
public void processAddedFields(DescriptorProto.Builder message, Iterable<FieldLocation> fields) {
if (manageSourceCodeInfo) {
ProtoPathWrapper messagePath = pathFromElement(message);
if (messagePath == null) {
throw new RuntimeException(
String.format(
"Internal error - couldn't find path for proto message %s",
ProtoHelpers.getName(message)));
}
ProtoPathWrapper fieldsPath =
ProtoHelpers.buildPath(messagePath, DescriptorProto.FIELD_FIELD_NUMBER);
ProtoPathTree<SourceCodeInfo.Location> fieldsPathTree =
pathToLocation.getSubtree(fieldsPath, true);
for (FieldLocation field : fields) {
Integer fieldIndex = fieldsPathTree.size();
if (fieldIndex > 0
&& (fieldsPathTree.firstKey() != 0 || fieldsPathTree.lastKey() != (fieldIndex - 1))) {
throw new RuntimeException(
String.format(
"BuilderVisitor internal error - non-contiguous field indexes found [%d..%d]\n",
fieldsPathTree.firstKey(), fieldsPathTree.lastKey()));
}
fieldsPathTree.addDataElement(
new ProtoPathWrapper(fieldIndex), // relative path of field within this message
field.location());
elementToOriginalPath.put(
field.fieldDescriptor(), ProtoHelpers.buildPath(fieldsPath, fieldIndex));
}
}
}
示例7: processAddedFields
import com.google.protobuf.DescriptorProtos.DescriptorProto; //导入方法依赖的package包/类
private void processAddedFields(FileNodeInfo currentFile) {
if (!toBeAddedFields().isEmpty()) {
DescriptorProto.Builder message = (DescriptorProto.Builder) node();
if (currentFile != null) {
currentFile.processAddedFields(message, toBeAddedFields());
}
for (FieldLocation fieldInfo : toBeAddedFields()) {
message.addField(fieldInfo.fieldDescriptor());
}
}
}
示例8: createMessageDescriptorProto
import com.google.protobuf.DescriptorProtos.DescriptorProto; //导入方法依赖的package包/类
private DescriptorProto createMessageDescriptorProto(String messageName,
UnknownFieldSet unknownFields) {
DescriptorProto.Builder messageBuilder = DescriptorProto.newBuilder();
return messageBuilder
.setName(messageName)
.setUnknownFields(unknownFields)
.addAllEnumType(Collections.<EnumDescriptorProto>emptyList())
.addAllExtension(Collections.<FieldDescriptorProto>emptyList())
.addAllField(Collections.<FieldDescriptorProto>emptyList())
.addAllNestedType(Collections.<DescriptorProto>emptyList())
.build();
}
示例9: create
import com.google.protobuf.DescriptorProtos.DescriptorProto; //导入方法依赖的package包/类
public static BuilderVisitorNodeInfo create(
DescriptorProto.Builder node, FileNodeInfo parentFile) {
return new MessageNodeInfo(node, parentFile);
}
示例10: addMessage
import com.google.protobuf.DescriptorProtos.DescriptorProto; //导入方法依赖的package包/类
public DescriptorProto.Builder addMessage(final String messageName) {
final DescriptorProto.Builder builder = currentScope.addMessage().setName(messageName);
pushScope(new MessageScope(builder, currentScope));
symbolScopes.pushScope(messageName);
return builder;
}
示例11: addGroup
import com.google.protobuf.DescriptorProtos.DescriptorProto; //导入方法依赖的package包/类
public DescriptorProto.Builder addGroup(final String messageName) {
final DescriptorProto.Builder builder = currentScope.addMessage().setName(messageName);
pushScope(new GroupScope(builder, currentScope));
symbolScopes.pushScope(messageName);
return builder;
}
示例12: MessageScope
import com.google.protobuf.DescriptorProtos.DescriptorProto; //导入方法依赖的package包/类
protected MessageScope(final DescriptorProto.Builder protoBuilder, final Scope<?> parent) {
super(protoBuilder, parent);
}
示例13: GroupScope
import com.google.protobuf.DescriptorProtos.DescriptorProto; //导入方法依赖的package包/类
protected GroupScope(final DescriptorProto.Builder protoBuilder, final Scope<?> parent) {
super(protoBuilder, parent);
}
示例14: OneofScope
import com.google.protobuf.DescriptorProtos.DescriptorProto; //导入方法依赖的package包/类
private OneofScope(final OneofDescriptorProto.Builder protoBuilder,
final Scope<DescriptorProto.Builder> parent) {
super(protoBuilder, parent);
oneofIndex = parent.getProtoBuilder().getOneofDeclCount() - 1;
}