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


Java SourceCodeInfo类代码示例

本文整理汇总了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));
  }
}
 
开发者ID:googleapis,项目名称:api-compiler,代码行数:16,代码来源:BuilderVisitor.java

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

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

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

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

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

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

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

示例9: addFieldToMessageParent

import com.google.protobuf.DescriptorProtos.SourceCodeInfo; //导入依赖的package包/类
protected void addFieldToMessageParent(
    FieldDescriptorProto.Builder fieldDesc, SourceCodeInfo.Location location) {
  addFieldToMessageAncestor(0, fieldDesc, location);
}
 
开发者ID:googleapis,项目名称:api-compiler,代码行数:5,代码来源:BuilderVisitor.java

示例10: pathToLocation

import com.google.protobuf.DescriptorProtos.SourceCodeInfo; //导入依赖的package包/类
public ProtoPathTree<SourceCodeInfo.Location> pathToLocation() {
  return pathToLocation;
}
 
开发者ID:googleapis,项目名称:api-compiler,代码行数:4,代码来源:FileNodeInfo.java

示例11: getLocationSubtree

import com.google.protobuf.DescriptorProtos.SourceCodeInfo; //导入依赖的package包/类
public ProtoPathTree<SourceCodeInfo.Location> getLocationSubtree(ProtoPathWrapper path) {
  return pathToLocation.getSubtree(path);
}
 
开发者ID:googleapis,项目名称:api-compiler,代码行数:4,代码来源:FileNodeInfo.java

示例12: LocationInfoUpdater

import com.google.protobuf.DescriptorProtos.SourceCodeInfo; //导入依赖的package包/类
public LocationInfoUpdater(SourceCodeInfo.Builder sourceCodeInfo) {
  this.sourceCodeInfo = sourceCodeInfo;
}
 
开发者ID:googleapis,项目名称:api-compiler,代码行数:4,代码来源:FileNodeInfo.java

示例13: after

import com.google.protobuf.DescriptorProtos.SourceCodeInfo; //导入依赖的package包/类
@VisitsAfter
public void after(ProtoPathTree<SourceCodeInfo.Location> node) {
  if (!node.isRootNode()) {
    numDeletedChildren.pop();
  }
}
 
开发者ID:googleapis,项目名称:api-compiler,代码行数:7,代码来源:FileNodeInfo.java

示例14: addNewField

import com.google.protobuf.DescriptorProtos.SourceCodeInfo; //导入依赖的package包/类
public void addNewField(
    FieldDescriptorProto.Builder fieldDesc, SourceCodeInfo.Location location) {
  toBeAddedFields.add(FieldLocation.create(fieldDesc, location));
}
 
开发者ID:googleapis,项目名称:api-compiler,代码行数:5,代码来源:MessageNodeInfo.java

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


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