当前位置: 首页>>代码示例>>Java>>正文


Java DescriptorProto.Builder方法代码示例

本文整理汇总了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();
}
 
开发者ID:protobufel,项目名称:protobuf-el,代码行数:27,代码来源:FileDescriptors.java

示例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);
  }
}
 
开发者ID:protobufel,项目名称:protobuf-el,代码行数:24,代码来源:OptionResolver.java

示例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();
}
 
开发者ID:protobufel,项目名称:protobuf-el,代码行数:25,代码来源:FileDescriptorEx.java

示例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;
}
 
开发者ID:protobufel,项目名称:protobuf-el,代码行数:21,代码来源:Misc.java

示例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);
}
 
开发者ID:googleapis,项目名称:api-compiler,代码行数:15,代码来源:BuilderVisitor.java

示例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));
    }
  }
}
 
开发者ID:googleapis,项目名称:api-compiler,代码行数:31,代码来源:FileNodeInfo.java

示例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());
    }
  }
}
 
开发者ID:googleapis,项目名称:api-compiler,代码行数:14,代码来源:MessageNodeInfo.java

示例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();
}
 
开发者ID:protobufel,项目名称:protobuf-el,代码行数:13,代码来源:DescriptorFactory.java

示例9: create

import com.google.protobuf.DescriptorProtos.DescriptorProto; //导入方法依赖的package包/类
public static BuilderVisitorNodeInfo create(
    DescriptorProto.Builder node, FileNodeInfo parentFile) {
  return new MessageNodeInfo(node, parentFile);
}
 
开发者ID:googleapis,项目名称:api-compiler,代码行数:5,代码来源:BuilderVisitorNodeInfo.java

示例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;
}
 
开发者ID:protobufel,项目名称:protobuf-el,代码行数:7,代码来源:Scopes.java

示例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;
}
 
开发者ID:protobufel,项目名称:protobuf-el,代码行数:7,代码来源:Scopes.java

示例12: MessageScope

import com.google.protobuf.DescriptorProtos.DescriptorProto; //导入方法依赖的package包/类
protected MessageScope(final DescriptorProto.Builder protoBuilder, final Scope<?> parent) {
  super(protoBuilder, parent);
}
 
开发者ID:protobufel,项目名称:protobuf-el,代码行数:4,代码来源:Scopes.java

示例13: GroupScope

import com.google.protobuf.DescriptorProtos.DescriptorProto; //导入方法依赖的package包/类
protected GroupScope(final DescriptorProto.Builder protoBuilder, final Scope<?> parent) {
  super(protoBuilder, parent);
}
 
开发者ID:protobufel,项目名称:protobuf-el,代码行数:4,代码来源:Scopes.java

示例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;
}
 
开发者ID:protobufel,项目名称:protobuf-el,代码行数:6,代码来源:Scopes.java


注:本文中的com.google.protobuf.DescriptorProtos.DescriptorProto.Builder方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。