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


Java FileDescriptor.getDependencies方法代码示例

本文整理汇总了Java中com.google.protobuf.Descriptors.FileDescriptor.getDependencies方法的典型用法代码示例。如果您正苦于以下问题:Java FileDescriptor.getDependencies方法的具体用法?Java FileDescriptor.getDependencies怎么用?Java FileDescriptor.getDependencies使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.protobuf.Descriptors.FileDescriptor的用法示例。


在下文中一共展示了FileDescriptor.getDependencies方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: extractDependencies

import com.google.protobuf.Descriptors.FileDescriptor; //导入方法依赖的package包/类
static Set<FileDescriptor> extractDependencies(List<FileDescriptor> fileDescriptors) {
  LinkedList<FileDescriptor> loop = new LinkedList<>(fileDescriptors);
  HashSet<FileDescriptor> fileDescriptorSet = new HashSet<>(fileDescriptors);

  while (!loop.isEmpty()) {
    FileDescriptor fileDescriptor = loop.pop();
    for (FileDescriptor dependency : fileDescriptor.getDependencies()) {
      if (!fileDescriptorSet.contains(dependency)) {
        fileDescriptorSet.add(dependency);
        loop.push(dependency);
      }
    }
  }

  return ImmutableSet.copyOf(fileDescriptorSet);
}
 
开发者ID:google,项目名称:rejoiner,代码行数:17,代码来源:ProtoRegistry.java

示例2: getDeepCanonicalFileDescriptor

import com.google.protobuf.Descriptors.FileDescriptor; //导入方法依赖的package包/类
private FileDescriptor getDeepCanonicalFileDescriptor(final FileDescriptor file,
    final boolean forceRebuild) throws DescriptorValidationException {
  if (!forceRebuild && isDeeplyCanonical(file)) {
    return file;
  }

  final FileDescriptor[] dependencies = new FileDescriptor[file.getDependencies().size()];
  int i = 0;

  for (final FileDescriptor dependency : file.getDependencies()) {
    dependencies[i++] = getDeepCanonicalFileDescriptor(dependency, forceRebuild);
  }

  final FileDescriptorProto proto = isCanonical(file) ? file.toProto() : makeCanonicalProto(file);
  return buildFileDescriptorWithReserializedProto(proto, dependencies);
}
 
开发者ID:protobufel,项目名称:protobuf-el,代码行数:17,代码来源:FileDescriptorEx.java

示例3: addDescriptorToFileSet

import com.google.protobuf.Descriptors.FileDescriptor; //导入方法依赖的package包/类
private FileDescriptorSet.Builder addDescriptorToFileSet(FileDescriptorSet.Builder builder, 
    Descriptor descriptor, Set<FileDescriptorProto> fileProtoSet) {
  List<? extends FileDescriptorProtoOrBuilder> fileList = builder.getFileOrBuilderList();
  final FileDescriptor file = descriptor.getFile();
  FileDescriptorProto proto = file.toProto();
  
  if (fileList.contains(proto)) {
    return builder;
  }
  
  builder.addFile(proto);
  
  for (FileDescriptor dependency : file.getDependencies()) {
    proto = dependency.toProto();
    
    if (!fileList.contains(proto)) {
      builder.addFile(proto);
    }
  }
  
  return builder;
}
 
开发者ID:protobufel,项目名称:protobuf-el,代码行数:23,代码来源:DescriptorFactoryTest.java

示例4: createServerReflectionResponse

import com.google.protobuf.Descriptors.FileDescriptor; //导入方法依赖的package包/类
private ServerReflectionResponse createServerReflectionResponse(
    ServerReflectionRequest request, FileDescriptor fd) {
  FileDescriptorResponse.Builder fdRBuilder = FileDescriptorResponse.newBuilder();

  Set<String> seenFiles = new HashSet<String>();
  Queue<FileDescriptor> frontier = new ArrayDeque<FileDescriptor>();
  seenFiles.add(fd.getName());
  frontier.add(fd);
  while (!frontier.isEmpty()) {
    FileDescriptor nextFd = frontier.remove();
    fdRBuilder.addFileDescriptorProto(nextFd.toProto().toByteString());
    for (FileDescriptor dependencyFd : nextFd.getDependencies()) {
      if (!seenFiles.contains(dependencyFd.getName())) {
        seenFiles.add(dependencyFd.getName());
        frontier.add(dependencyFd);
      }
    }
  }
  return ServerReflectionResponse.newBuilder()
      .setValidHost(request.getHost())
      .setOriginalRequest(request)
      .setFileDescriptorResponse(fdRBuilder)
      .build();
}
 
开发者ID:grpc,项目名称:grpc-java,代码行数:25,代码来源:ProtoReflectionService.java

示例5: addFile

import com.google.protobuf.Descriptors.FileDescriptor; //导入方法依赖的package包/类
private void addFile(FileDescriptor file) {
  // Skip the file if it's already added.
  if (!files.add(file.getFullName())) {
    return;
  }
  for (FileDescriptor dependency : file.getDependencies()) {
    addFile(dependency);
  }
  for (Descriptor message : file.getMessageTypes()) {
    addMessage(message);
  }
}
 
开发者ID:SeldonIO,项目名称:seldon-core,代码行数:13,代码来源:JsonFormat.java

示例6: getFileWithAllDependencies

import com.google.protobuf.Descriptors.FileDescriptor; //导入方法依赖的package包/类
private static Iterable<FileDescriptor> getFileWithAllDependencies(final FileDescriptor file) {
  final Set<FileDescriptor> cache = new LinkedHashSet<FileDescriptor>();

  cache.add(file);

  // we must follow the original ProtoBuf here!
  for (final FileDescriptor dependency : file.getDependencies()) {
    cache.add(dependency);
    addPublicDependencies(cache, dependency);
  }

  return cache;
}
 
开发者ID:protobufel,项目名称:protobuf-el,代码行数:14,代码来源:ExtensionRegistries.java

示例7: isDeeplyCanonical

import com.google.protobuf.Descriptors.FileDescriptor; //导入方法依赖的package包/类
private boolean isDeeplyCanonical(final FileDescriptor file) {
  if (!isCanonical(file)) {
    return false;
  }

  for (final FileDescriptor dependency : file.getDependencies()) {
    if (!isDeeplyCanonical(dependency)) {
      return false;
    }
  }

  return true;
}
 
开发者ID:protobufel,项目名称:protobuf-el,代码行数:14,代码来源:FileDescriptorEx.java

示例8: addFile

import com.google.protobuf.Descriptors.FileDescriptor; //导入方法依赖的package包/类
public FileDescriptorSetBuilder addFile(final FileDescriptor file) {
  if (!fileProtoSet.add(file.toProto())) {
    return this;
  }
  
  for (FileDescriptor dependency : file.getDependencies()) {
    addFile(dependency);
  }
  
  return this;
}
 
开发者ID:protobufel,项目名称:protobuf-el,代码行数:12,代码来源:DescriptorFactory.java

示例9: FileDescriptorIndex

import com.google.protobuf.Descriptors.FileDescriptor; //导入方法依赖的package包/类
FileDescriptorIndex(List<ServerServiceDefinition> services) {
  Queue<FileDescriptor> fileDescriptorsToProcess = new ArrayDeque<FileDescriptor>();
  Set<String> seenFiles = new HashSet<String>();
  for (ServerServiceDefinition service : services) {
    io.grpc.ServiceDescriptor serviceDescriptor = service.getServiceDescriptor();
    if (serviceDescriptor.getSchemaDescriptor() instanceof ProtoFileDescriptorSupplier) {
      FileDescriptor fileDescriptor =
          ((ProtoFileDescriptorSupplier) serviceDescriptor.getSchemaDescriptor())
              .getFileDescriptor();
      String serviceName = serviceDescriptor.getName();
      checkState(
          !serviceNames.contains(serviceName), "Service already defined: %s", serviceName);
      serviceFileDescriptors.add(fileDescriptor);
      serviceNames.add(serviceName);
      if (!seenFiles.contains(fileDescriptor.getName())) {
        seenFiles.add(fileDescriptor.getName());
        fileDescriptorsToProcess.add(fileDescriptor);
      }
    }
  }

  while (!fileDescriptorsToProcess.isEmpty()) {
    FileDescriptor currentFd = fileDescriptorsToProcess.remove();
    processFileDescriptor(currentFd);
    for (FileDescriptor dependencyFd : currentFd.getDependencies()) {
      if (!seenFiles.contains(dependencyFd.getName())) {
        seenFiles.add(dependencyFd.getName());
        fileDescriptorsToProcess.add(dependencyFd);
      }
    }
  }
}
 
开发者ID:grpc,项目名称:grpc-java,代码行数:33,代码来源:ProtoReflectionService.java


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