Java 类com.google.protobuf.DescriptorProtos.SourceCodeInfo.Location 实例源码

项目:reactive-grpc    文件:ReactiveGrpcGenerator.java   
private List<ServiceContext> findServices(List<FileDescriptorProto> protos, ProtoTypeMap typeMap) {
    List<ServiceContext> contexts = new ArrayList<>();

    protos.forEach(fileProto -> {
        List<Location> locations = fileProto.getSourceCodeInfo().getLocationList();
        locations.stream()
                .filter(location -> location.getPathCount() == 2 && location.getPath(0) == FileDescriptorProto.SERVICE_FIELD_NUMBER)
                .forEach(location -> {
                    int serviceNumber = location.getPath(1);
                    ServiceContext serviceContext = buildServiceContext(fileProto.getService(serviceNumber), typeMap, locations, serviceNumber);
                    serviceContext.javaDoc = getJavaDoc(getComments(location), getServiceJavaDocPrefix());
                    serviceContext.protoName = fileProto.getName();
                    serviceContext.packageName = extractPackageName(fileProto);
                    contexts.add(serviceContext);
                });
    });

    return contexts;
}
项目:reactive-grpc    文件:ReactiveGrpcGenerator.java   
private ServiceContext buildServiceContext(ServiceDescriptorProto serviceProto, ProtoTypeMap typeMap, List<Location> locations, int serviceNumber) {
    ServiceContext serviceContext = new ServiceContext();
    serviceContext.fileName = getClassPrefix() + serviceProto.getName() + "Grpc.java";
    serviceContext.className = getClassPrefix() + serviceProto.getName() + "Grpc";
    serviceContext.serviceName = serviceProto.getName();
    serviceContext.deprecated = serviceProto.getOptions() != null && serviceProto.getOptions().getDeprecated();

    locations.stream()
            .filter(location -> location.getPathCount() == METHOD_NUMBER_OF_PATHS &&
                    location.getPath(0) == FileDescriptorProto.SERVICE_FIELD_NUMBER &&
                    location.getPath(1) == serviceNumber &&
                    location.getPath(2) == ServiceDescriptorProto.METHOD_FIELD_NUMBER)
            .forEach(location -> {
                int methodNumber = location.getPath(METHOD_NUMBER_OF_PATHS - 1);
                MethodContext methodContext = buildMethodContext(serviceProto.getMethod(methodNumber), typeMap);
                methodContext.methodNumber = methodNumber;
                methodContext.javaDoc = getJavaDoc(getComments(location), getMethodJavaDocPrefix());
                serviceContext.methods.add(methodContext);
            });
    return serviceContext;
}
项目:protobuf-el    文件:LocationBuilder.java   
public Location.Builder setAllPath(final Location.Builder builder) {
  if (builder.getPathCount() > 0) {
    builder.clearPath();
  }

  return builder.addAllPath(path);
}
项目:reactive-grpc    文件:ReactiveGrpcGenerator.java   
private String getComments(Location location) {
    return location.getLeadingComments().isEmpty() ? location.getTrailingComments() : location.getLeadingComments();
}
项目:protobuf-el    文件:LocationBuilder.java   
public Location.Builder newLocationBuilder() {
  return Location.newBuilder().addAllPath(path);
}