/** * Resolves a interface by a partial name within a given package context, following PB (== C++) * conventions. */ @Nullable public Interface resolveInterface(String inPackage, String name) { for (String cand : nameCandidates(inPackage, name)) { Interface endpointInterface = lookupInterface(cand); if (endpointInterface != null) { return endpointInterface; } } return null; }
/** * Resolves a interface by a partial name within a given package context, following PB (== C++) * conventions. */ @Nullable public Interface resolveInterface(String inPackage, String name) { for (String cand : nameCandidates(inPackage, name)) { Interface endpointInterface = lookupInterface(cand); if (endpointInterface != null) { return endpointInterface; } } return null; }
/** * If rerouteToGrpcInterface is set, then looks up that interface and returns it, otherwise * returns the value of defaultInterface. */ public static Interface getTargetInterface( Interface defaultInterface, String rerouteToGrpcInterface) { Interface targetInterface = defaultInterface; if (!Strings.isNullOrEmpty(rerouteToGrpcInterface)) { targetInterface = defaultInterface.getModel().getSymbolTable().lookupInterface(rerouteToGrpcInterface); if (targetInterface == null) { throw new IllegalArgumentException( "reroute_to_grpc_interface not found: " + rerouteToGrpcInterface); } } return targetInterface; }
@Override public ProtoInterfaceModel getInterface(String interfaceName) { return new ProtoInterfaceModel(protoModel.getSymbolTable().lookupInterface(interfaceName)); }
/** Gets the interfaces for the apis in the service config. */ public static List<Interface> getInterfaces(Model model) { return model .getServiceConfig() .getApisList() .stream() .map(api -> model.getSymbolTable().lookupInterface(api.getName())) .collect(ImmutableList.toImmutableList()); } }
@Override public List<MethodModel> getMethods() { ImmutableList.Builder<MethodModel> methods = ImmutableList.builder(); for (Method method : protoInterface.getMethods()) { methods.add(new ProtoMethodModel(method)); } SymbolTable symbolTable = protoInterface.getModel().getSymbolTable(); for (Mixin mixin : protoInterface.getConfig().getMixinsList()) { Interface mixinInterface = symbolTable.lookupInterface(mixin.getName()); for (Method method : mixinInterface.getMethods()) { methods.add(new ProtoMethodModel(method)); } } return methods.build(); }
private static Map<Interface, Interface> createGrpcRerouteMap( Model model, GapicProductConfig productConfig) { HashMap<Interface, Interface> grpcRerouteMap = new HashMap<>(); for (Interface apiInterface : ProtoModels.getInterfaces(model)) { InterfaceConfig interfaceConfig = productConfig.getInterfaceConfig(apiInterface); if (interfaceConfig == null) { continue; } if (!apiInterface.isReachable()) { continue; } for (MethodConfig methodConfig : interfaceConfig.getMethodConfigs()) { String reroute = methodConfig.getRerouteToGrpcInterface(); if (!Strings.isNullOrEmpty(reroute)) { Interface targetInterface = model.getSymbolTable().lookupInterface(reroute); grpcRerouteMap.put(targetInterface, apiInterface); } } } return grpcRerouteMap; }
private static ImmutableMap<String, Interface> getInterfacesFromProtoFile( DiagCollector diagCollector, List<ProtoFile> sourceProtos, SymbolTable symbolTable) { // Maps name of interfaces to found interfaces from proto. ImmutableMap.Builder<String, Interface> protoInterfaces = ImmutableMap.builder(); // Parse proto file for interfaces. for (ProtoFile file : sourceProtos) { for (DescriptorProtos.ServiceDescriptorProto service : file.getProto().getServiceList()) { String serviceFullName = String.format("%s.%s", file.getProto().getPackage(), service.getName()); Interface apiInterface = symbolTable.lookupInterface(serviceFullName); if (apiInterface == null) { diagCollector.addDiag( Diag.error(SimpleLocation.TOPLEVEL, "interface not found: %s", service.getName())); continue; } protoInterfaces.put(serviceFullName, apiInterface); } } return protoInterfaces.build(); }
private Interface getInterface(String interfaceName) { Interface endpointInterface = model.getSymbolTable().lookupInterface(interfaceName); Assert.assertNotNull(endpointInterface); return endpointInterface; }
Interface apiInterface = symbolTable.lookupInterface(interfaceConfigProto.getName()); if (apiInterface == null || !apiInterface.isReachable()) { diagCollector.addDiag(
Interface iface = lookupInterface(id); if (iface != null) { return iface;
Interface iface = lookupInterface(id); if (iface != null) { return iface;
/** Returns a base package name for an API's client. */ @Nullable public static String getPackageName(Model model) { if (model.getServiceConfig().getApisCount() > 0) { Api api = model.getServiceConfig().getApis(0); Interface apiInterface = model.getSymbolTable().lookupInterface(api.getName()); if (apiInterface != null) { return apiInterface.getFile().getFullName(); } } return null; } }
symbolTable.lookupInterface(configProto.getInterfaces(0).getName()).getFile(); defaultPackage = file.getProto().getPackage(); } else {
Interface iface = model.getSymbolTable().lookupInterface(api.getName()); if (iface != null) {
Interface iface = model.getSymbolTable().lookupInterface(api.getName()); if (iface != null) {