本文整理汇总了Java中com.google.protobuf.DescriptorProtos.SourceCodeInfo类的典型用法代码示例。如果您正苦于以下问题:Java SourceCodeInfo类的具体用法?Java SourceCodeInfo怎么用?Java SourceCodeInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SourceCodeInfo类属于com.google.protobuf.DescriptorProtos包,在下文中一共展示了SourceCodeInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addFieldToMessageAncestor
import com.google.protobuf.DescriptorProtos.SourceCodeInfo; //导入依赖的package包/类
protected void addFieldToMessageAncestor(
int generationsToSkip,
FieldDescriptorProto.Builder fieldDesc,
SourceCodeInfo.Location location) {
BuilderVisitorNodeInfo ancestorInfo = getAncestorInfo(generationsToSkip);
if (ancestorInfo instanceof MessageNodeInfo) {
((MessageNodeInfo) ancestorInfo).addNewField(fieldDesc, location);
setModified(true);
} else {
throw new RuntimeException(
String.format(
"Tried to add a field to a %s, but can only add to %s",
ancestorInfo.node().getClass(), DescriptorProto.Builder.class));
}
}
示例2: processDeletedChildren
import com.google.protobuf.DescriptorProtos.SourceCodeInfo; //导入依赖的package包/类
public void processDeletedChildren(Iterable<Message.Builder> elements) {
if (manageSourceCodeInfo) {
for (Message.Builder element : elements) {
ProtoPathWrapper path = pathFromElement(element);
if (path != null && !path.isEmpty()) {
ProtoPathTree<SourceCodeInfo.Location> subtree = pathToLocation.getSubtree(path);
modifiedSourceCodeInfo = true;
subtree.markForDeletion(true);
}
}
}
}
示例3: processAddedFields
import com.google.protobuf.DescriptorProtos.SourceCodeInfo; //导入依赖的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));
}
}
}
示例4: setupPathsForFile
import com.google.protobuf.DescriptorProtos.SourceCodeInfo; //导入依赖的package包/类
private void setupPathsForFile(FileDescriptorProto.Builder file) {
// Populate location map
if (file.hasSourceCodeInfo() && manageSourceCodeInfo) {
for (SourceCodeInfo.Location location : file.getSourceCodeInfo().getLocationList()) {
pathToLocation.addDataElement(new ProtoPathWrapper(location.getPathList()), location);
}
} else {
// Turn off SourceCodeInfo management if there is none.
manageSourceCodeInfo = false;
}
}
示例5: resetPathsForFile
import com.google.protobuf.DescriptorProtos.SourceCodeInfo; //导入依赖的package包/类
private void resetPathsForFile(FileDescriptorProto.Builder file) {
if (modifiedSourceCodeInfo) {
SourceCodeInfo.Builder sourceCodeInfo = file.getSourceCodeInfoBuilder();
sourceCodeInfo.clearLocation();
new LocationInfoUpdater(sourceCodeInfo).visit(pathToLocation);
modifiedSourceCodeInfo = false;
}
elementToOriginalPath.clear();
pathToLocation.clear();
}
示例6: before
import com.google.protobuf.DescriptorProtos.SourceCodeInfo; //导入依赖的package包/类
@VisitsBefore
public boolean before(ProtoPathTree<SourceCodeInfo.Location> node) {
if (node.isRootNode()) {
numDeletedChildren.push(0);
// Since the root node isn't the child of anything and there's no location info there, we're
// done - so just return here.
return true;
} else if (!node.isMarkedForDeletion()) {
// NOTE: This logic for computing the new path assumes that the only nodes that we delete
// are described by path lists ending with a 0..n index (e.g. the 2nd method of a service
// would have a path ending in 1 and the 3rd field of a message would have a path ending in
// 2, regardless of its defined field number). It also assumes that ProtoPathTree.Visitor is
// going to return the children in ascending numerical order based on their path indexes.
ProtoPathWrapper originalPath = node.getPathFromRoot();
if (!originalPath.isEmpty()) {
ArrayList<Integer> newPath = new ArrayList<>(originalPath.getDepth());
for (int i = 0; i < originalPath.getDepth(); i++) {
newPath.add(originalPath.getPathElement(i) - numDeletedChildren.get(i));
}
addUpdatedLocationInfo(sourceCodeInfo, node, new ProtoPathWrapper(newPath));
}
numDeletedChildren.push(0);
} else {
// Don't descend into a deleted node, but note that we found a deleted node, so we can
// adjust path indexes for later children.
numDeletedChildren.push(numDeletedChildren.pop() + 1);
return false;
}
return true;
}
示例7: addUpdatedLocationInfo
import com.google.protobuf.DescriptorProtos.SourceCodeInfo; //导入依赖的package包/类
private void addUpdatedLocationInfo(
SourceCodeInfo.Builder sourceCodeInfo,
ProtoPathTree<SourceCodeInfo.Location> currentPathTree,
ProtoPathWrapper newPath) {
// Add the location data from the current node, updating path numbers as we go.
for (SourceCodeInfo.Location location : currentPathTree.getDataElements()) {
sourceCodeInfo.addLocation(
location.toBuilder().clearPath().addAllPath(newPath.getPathElements()).build());
}
}
示例8: LocationBuilder
import com.google.protobuf.DescriptorProtos.SourceCodeInfo; //导入依赖的package包/类
public LocationBuilder(final SourceCodeInfo.Builder sourceBuilder,
final CommonTokenStreamEx tokens) {
location = null;
path = new Path();
currentScope = new FileScope();
this.sourceBuilder = sourceBuilder;
leadingComments = new IdentityHashMap<Token, String>();
this.tokens = tokens;
}
示例9: addFieldToMessageParent
import com.google.protobuf.DescriptorProtos.SourceCodeInfo; //导入依赖的package包/类
protected void addFieldToMessageParent(
FieldDescriptorProto.Builder fieldDesc, SourceCodeInfo.Location location) {
addFieldToMessageAncestor(0, fieldDesc, location);
}
示例10: pathToLocation
import com.google.protobuf.DescriptorProtos.SourceCodeInfo; //导入依赖的package包/类
public ProtoPathTree<SourceCodeInfo.Location> pathToLocation() {
return pathToLocation;
}
示例11: getLocationSubtree
import com.google.protobuf.DescriptorProtos.SourceCodeInfo; //导入依赖的package包/类
public ProtoPathTree<SourceCodeInfo.Location> getLocationSubtree(ProtoPathWrapper path) {
return pathToLocation.getSubtree(path);
}
示例12: LocationInfoUpdater
import com.google.protobuf.DescriptorProtos.SourceCodeInfo; //导入依赖的package包/类
public LocationInfoUpdater(SourceCodeInfo.Builder sourceCodeInfo) {
this.sourceCodeInfo = sourceCodeInfo;
}
示例13: after
import com.google.protobuf.DescriptorProtos.SourceCodeInfo; //导入依赖的package包/类
@VisitsAfter
public void after(ProtoPathTree<SourceCodeInfo.Location> node) {
if (!node.isRootNode()) {
numDeletedChildren.pop();
}
}
示例14: addNewField
import com.google.protobuf.DescriptorProtos.SourceCodeInfo; //导入依赖的package包/类
public void addNewField(
FieldDescriptorProto.Builder fieldDesc, SourceCodeInfo.Location location) {
toBeAddedFields.add(FieldLocation.create(fieldDesc, location));
}
示例15: create
import com.google.protobuf.DescriptorProtos.SourceCodeInfo; //导入依赖的package包/类
public static FieldLocation create(
FieldDescriptorProto.Builder fieldDescriptor, SourceCodeInfo.Location location) {
return new AutoValue_FieldLocation(fieldDescriptor, location);
}