本文整理汇总了Java中com.google.protobuf.DescriptorProtos.FileDescriptorProto.getDependencyList方法的典型用法代码示例。如果您正苦于以下问题:Java FileDescriptorProto.getDependencyList方法的具体用法?Java FileDescriptorProto.getDependencyList怎么用?Java FileDescriptorProto.getDependencyList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.protobuf.DescriptorProtos.FileDescriptorProto
的用法示例。
在下文中一共展示了FileDescriptorProto.getDependencyList方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateFile
import com.google.protobuf.DescriptorProtos.FileDescriptorProto; //导入方法依赖的package包/类
public void generateFile(String protoPath) {
try {
if (pojoTypes == null) {
pojoTypes = Maps.newHashMap();
}
} finally {
if (!new File(protoPath).exists()) {
logger.warn("protoPath:" + protoPath
+ " not exist, it may be in the third party jars, so it can't be generate");
return;
}
FileDescriptorSet fileDescriptorSet = commondProtoc.invoke(protoPath);
for (FileDescriptorProto fdp : fileDescriptorSet.getFileList()) {
Pair<String, String> packageClassName = this.packageClassName(fdp.getOptions());
if (packageClassName == null) {
continue;
}
ProtocolStringList dependencyList = fdp.getDependencyList();
for (Iterator<String> it = dependencyList.iterator(); it.hasNext();) {
String dependencyPath = discoveryRoot + "/" + it.next();
generateFile(dependencyPath);
}
doPrint(fdp, packageClassName.getLeft(), packageClassName.getRight());
}
}
}
示例2: descriptorFromProto
import com.google.protobuf.DescriptorProtos.FileDescriptorProto; //导入方法依赖的package包/类
/**
* Recursively constructs file descriptors for all dependencies of the supplied proto and returns
* a {@link FileDescriptor} for the supplied proto itself. For maximal efficiency, reuse the
* descriptorCache argument across calls.
*/
private static FileDescriptor descriptorFromProto(
FileDescriptorProto descriptorProto,
ImmutableMap<String, FileDescriptorProto> descriptorProtoIndex,
Map<String, FileDescriptor> descriptorCache) throws DescriptorValidationException {
// First, check the cache.
String descritorName = descriptorProto.getName();
if (descriptorCache.containsKey(descritorName)) {
return descriptorCache.get(descritorName);
}
// Then, fetch all the required dependencies recursively.
ImmutableList.Builder<FileDescriptor> dependencies = ImmutableList.builder();
for (String dependencyName : descriptorProto.getDependencyList()) {
if (!descriptorProtoIndex.containsKey(dependencyName)) {
throw new IllegalArgumentException("Could not find dependency: " + dependencyName);
}
FileDescriptorProto dependencyProto = descriptorProtoIndex.get(dependencyName);
dependencies.add(descriptorFromProto(dependencyProto, descriptorProtoIndex, descriptorCache));
}
// Finally, construct the actual descriptor.
FileDescriptor[] empty = new FileDescriptor[0];
return FileDescriptor.buildFrom(descriptorProto, dependencies.build().toArray(empty));
}
示例3: decompile
import com.google.protobuf.DescriptorProtos.FileDescriptorProto; //导入方法依赖的package包/类
public void decompile(FileDescriptorProto fileDescriptor) throws IOException {
if (fileDescriptor.hasPackage()) {
indentedFormat("package %s;", fileDescriptor.getPackage());
absolutePackage = "." + fileDescriptor.getPackage() + ".";
}
for (String dependency : fileDescriptor.getDependencyList()) {
indentedFormat("import \"%s\";", dependency);
}
if (fileDescriptor.hasOptions()) {
decompileOptions(fileDescriptor.getOptions());
}
decompileMembers(fileDescriptor.getEnumTypeList(),
fileDescriptor.getMessageTypeList(),
Collections.<FieldDescriptorProto>emptyList(),
Collections.<DescriptorProto.ExtensionRange>emptyList(),
fileDescriptor.getExtensionList());
for (ServiceDescriptorProto serviceDescriptor : fileDescriptor.getServiceList()) {
decompile(serviceDescriptor);
}
newline();
flush();
}