public String protoToString() { StringBuilder sb = new StringBuilder(); appendLine(sb, "syntax = \"%s\";", proto.getSyntax()); for (Import importValue : proto.getImports()) { appendLine(sb, "import \"%s\";", importValue.getValue()); } appendLine(sb, "package %s;\n", proto.getPackage().getValue()); for (Message message : proto.getMessages()) { messageToString(message, sb); } for (Enum enumValue : proto.getEnums()) { enumToString(enumValue, sb); } for (Service service : proto.getServices()) { serviceToString(service, sb); } return sb.toString(); }
@Override public void compile(Module module) { module.getProtos() .forEach(proto -> proto.getServices() .forEach(service -> process(module, service))); }
@Override public void compile(Module module) { module.getProtos() .forEach(proto -> proto.getServices() .forEach(service -> process(module, service))); }
private void walk(Proto container) { List<Service> services = container.getServices(); for (Processor<Service> serviceProcessor : serviceProcessors) { for (Service service : services) { serviceProcessor.run(context, service); walk(service); } } walk((UserTypeContainer) container); }
private void walk(Proto container) { List<Service> services = container.getServices(); for (Processor<Service> serviceProcessor : serviceProcessors) { for (Service service : services) { serviceProcessor.run(context, service); walk(service); } } walk((UserTypeContainer) container); }
private List<JsonTreeNode> processProto(Proto proto) { List<JsonTreeNode> result = new ArrayList<>(); proto.getServices() .forEach(service -> result.add(ImmutableJsonTreeNode.builder() .label(service.getName()) .data(ImmutableNodeData.builder() .type(NodeType.SERVICE) .ref(service.getCanonicalName()) .build()) .build())); result.addAll(processContainer(proto)); return result; }
private List<JsonTreeNode> processProto(Proto proto) { List<JsonTreeNode> result = new ArrayList<>(); proto.getServices() .forEach(service -> result.add(ImmutableJsonTreeNode.builder() .label(service.getName()) .data(ImmutableNodeData.builder() .type(NodeType.SERVICE) .ref(service.getCanonicalName()) .build()) .build())); result.addAll(processContainer(proto)); return result; }
@Override public void compile(Module module) { String moduleOutput = module.getOutput(); processModule(module, moduleOutput); for (Proto proto : module.getProtos()) { processProto(moduleOutput, proto); for (Service service : proto.getServices()) { processService(moduleOutput, service); } processUserTypes(module, proto); } }
@Override public void compile(Module module) { String moduleOutput = module.getOutput(); processModule(module, moduleOutput); for (Proto proto : module.getProtos()) { processProto(moduleOutput, proto); for (Service service : proto.getServices()) { processService(moduleOutput, service); } processUserTypes(module, proto); } }
public String protoToString() { StringBuilder sb = new StringBuilder(); appendLine(sb, "syntax = \"%s\";", proto.getSyntax()); for (Import importValue : proto.getImports()) { appendLine(sb, "import \"%s\";", importValue.getValue()); } appendLine(sb, "package %s;\n", proto.getPackage().getValue()); for (Message message : proto.getMessages()) { messageToString(message, sb); } for (Enum enumValue : proto.getEnums()) { enumToString(enumValue, sb); } for (Service service : proto.getServices()) { serviceToString(service, sb); } return sb.toString(); }
List<Service> services = proto.getServices(); for (Service type : services) { type.setProto(proto);
List<Service> services = proto.getServices(); for (Service type : services) { type.setProto(proto);
private void resolveTypeReferences(ProtoContext context) { Proto proto = context.getProto(); Deque<String> scopeLookupList = createScopeLookupList(proto); for (Service service : proto.getServices()) { for (ServiceMethod method : service.getMethods()) { String argTypeName = method.getArgTypeName(); FieldType argType = resolveFieldType(method, context, scopeLookupList, argTypeName); if (!(argType instanceof Message)) { String format = "Cannot use '%s' as a service method argument type: not a message"; throw new ParserException(method, format, argType.getName()); } method.setArgType((Message) argType); String returnTypeName = method.getReturnTypeName(); FieldType returnType = resolveFieldType(method, context, scopeLookupList, returnTypeName); if (!(returnType instanceof Message)) { String format = "Cannot use '%s' as a service method return type: not a message"; throw new ParserException(method, format, returnType.getName()); } method.setReturnType((Message) returnType); } } resolveTypeReferences(context, scopeLookupList, proto); }
private void resolveTypeReferences(ProtoContext context) { Proto proto = context.getProto(); Deque<String> scopeLookupList = createScopeLookupList(proto); for (Service service : proto.getServices()) { for (ServiceMethod method : service.getMethods()) { String argTypeName = method.getArgTypeName(); FieldType argType = resolveFieldType(method, context, scopeLookupList, argTypeName); if (!(argType instanceof Message)) { String format = "Cannot use '%s' as a service method argument type: not a message"; throw new ParserException(method, format, argType.getName()); } method.setArgType((Message) argType); String returnTypeName = method.getReturnTypeName(); FieldType returnType = resolveFieldType(method, context, scopeLookupList, returnTypeName); if (!(returnType instanceof Message)) { String format = "Cannot use '%s' as a service method return type: not a message"; throw new ParserException(method, format, returnType.getName()); } method.setReturnType((Message) returnType); } } resolveTypeReferences(context, scopeLookupList, proto); }