private void markRpc(ProtoType declaringType, Rpc rpc) { if (marks.contains(ProtoMember.get(declaringType, rpc.name()))) { markOptions(rpc.options()); mark(rpc.requestType()); mark(rpc.responseType()); } } }
private void markEnum(EnumType wireEnum) { markOptions(wireEnum.options()); if (marks.containsAllMembers(wireEnum.type())) { for (EnumConstant constant : wireEnum.constants()) { if (marks.contains(ProtoMember.get(wireEnum.type(), constant.name()))) { markOptions(constant.options()); } } } }
public Field getField(ProtoMember protoMember) { Type type = getType(protoMember.type()); if (!(type instanceof MessageType)) return null; Field field = ((MessageType) type).field(protoMember.member()); if (field == null) { field = ((MessageType) type).extensionField(protoMember.member()); } return field; }
private void markMessage(MessageType message) { markFields(message.type(), message.fields()); for (OneOf oneOf : message.oneOfs()) { markFields(message.type(), oneOf.fields()); } }
private void markService(Service service) { markOptions(service.options()); if (marks.containsAllMembers(service.type())) { for (Rpc rpc : service.rpcs()) { markRpc(service.type(), rpc); } } }
private void markType(Type type) { markOptions(type.options()); if (marks.containsAllMembers(type.type())) { if (type instanceof MessageType) { markMessage((MessageType) type); } else if (type instanceof EnumType) { markEnum((EnumType) type); } } }
void linkOptions(Linker linker) { linker = linker.withContext(this); options.link(linker); deprecated = options().get(DEPRECATED); packed = options().get(PACKED); // We allow any package name to be used as long as it ends with '.redacted'. redacted = options().optionMatches(".*\\.redacted", "true"); }
Field retainAll(Schema schema, MarkSet markSet) { // For map types only the value can participate in pruning as the key will always be scalar. if (type.isMap() && !markSet.contains(type.valueType())) return null; if (!markSet.contains(type)) return null; Field result = new Field(packageName, location, label, name, documentation, tag, defaultValue, elementType, options.retainAll(schema, markSet), extension); result.type = type; result.deprecated = deprecated; result.packed = packed; result.redacted = redacted; return result; }
void validate(Linker linker) { linker = linker.withContext(this); linker.validateImport(location(), type()); } }
private void markRoots() { for (ProtoFile protoFile : schema.protoFiles()) { markRoots(protoFile); } }
/** * Returns the service with the fully qualified name {@code name}, or null if this schema defines * no such service. */ public Service getService(ProtoType protoType) { return getService(protoType.toString()); }
void validate(Linker linker) { linker = linker.withContext(this); linker.validateImport(location(), requestType); linker.validateImport(location(), responseType); }
Rpc retainAll(Schema schema, MarkSet markSet) { if (!markSet.contains(requestType) || !markSet.contains(responseType)) return null; Rpc result = new Rpc(location, name, documentation, requestTypeElement, responseTypeElement, requestStreaming, responseStreaming, options.retainAll(schema, markSet)); result.requestType = requestType; result.responseType = responseType; return result; }
void linkOptions(Linker linker) { linker = linker.withContext(this); for (Rpc rpc : rpcs) { rpc.linkOptions(linker); } options.link(linker); }
void link(Linker linker) { linker = linker.withContext(this); for (Rpc rpc : rpcs) { rpc.link(linker); } }
void validate(Linker linker) { linker = linker.withContext(this); for (Rpc rpc : rpcs) { rpc.validate(linker); } }