本文整理汇总了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);
}
示例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);
}
示例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;
}
示例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();
}
示例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);
}
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
}
}