Search in sources :

Example 1 with ConfigHelper

use of com.google.api.codegen.configgen.ConfigHelper in project toolkit by googleapis.

the class DiscoGapicGeneratorApi method loadConfigFromFiles.

private static ConfigProto loadConfigFromFiles(List<String> configFileNames) {
    DiagCollector diagCollector = new SimpleDiagCollector();
    ConfigYamlReader yamlReader = new ConfigYamlReader();
    MessageGenerator messageGenerator = new MessageGenerator(ConfigProto.newBuilder());
    for (File file : pathsToFiles(configFileNames)) {
        ConfigHelper helper = new ConfigHelper(diagCollector, file.getName());
        ConfigNode configNode = yamlReader.generateConfigNode(file, helper);
        if (configNode == null) {
            continue;
        }
        messageGenerator.visit(configNode.getChild());
    }
    ConfigProto configProto = (ConfigProto) messageGenerator.getValue();
    if (configProto == null || configProto.equals(ConfigProto.getDefaultInstance())) {
        return null;
    }
    return configProto;
}
Also used : MessageGenerator(com.google.api.codegen.configgen.MessageGenerator) SimpleDiagCollector(com.google.api.tools.framework.model.SimpleDiagCollector) DiagCollector(com.google.api.tools.framework.model.DiagCollector) ConfigHelper(com.google.api.codegen.configgen.ConfigHelper) ConfigNode(com.google.api.codegen.configgen.nodes.ConfigNode) File(java.io.File) SimpleDiagCollector(com.google.api.tools.framework.model.SimpleDiagCollector) ConfigYamlReader(com.google.api.codegen.configgen.ConfigYamlReader)

Example 2 with ConfigHelper

use of com.google.api.codegen.configgen.ConfigHelper in project toolkit by googleapis.

the class ProtoConfigMerger method createMerger.

private ConfigMerger createMerger(Model model, String fileName) {
    ConfigHelper helper = new ConfigHelper(model.getDiagReporter().getDiagCollector(), fileName);
    String packageName = GapicProductConfig.getPackageName(model);
    if (packageName == null) {
        helper.error(model.getLocation(), "Failed to determine package name.");
        return null;
    }
    CollectionMerger collectionMerger = new CollectionMerger();
    RetryMerger retryMerger = new RetryMerger();
    PageStreamingMerger pageStreamingMerger = new PageStreamingMerger(new ProtoPageStreamingTransformer(), helper);
    MethodMerger methodMerger = new MethodMerger(retryMerger, pageStreamingMerger, new ProtoMethodTransformer());
    LanguageSettingsMerger languageSettingsMerger = new LanguageSettingsMerger();
    InterfaceTransformer interfaceTranformer = new ProtoInterfaceTransformer();
    InterfaceMerger interfaceMerger = new InterfaceMerger(collectionMerger, retryMerger, methodMerger, interfaceTranformer);
    return new ConfigMerger(languageSettingsMerger, interfaceMerger, packageName, helper);
}
Also used : ProtoInterfaceTransformer(com.google.api.codegen.configgen.ProtoInterfaceTransformer) InterfaceTransformer(com.google.api.codegen.configgen.InterfaceTransformer) ConfigHelper(com.google.api.codegen.configgen.ConfigHelper) ProtoInterfaceTransformer(com.google.api.codegen.configgen.ProtoInterfaceTransformer) ProtoPageStreamingTransformer(com.google.api.codegen.configgen.ProtoPageStreamingTransformer) ProtoMethodTransformer(com.google.api.codegen.configgen.ProtoMethodTransformer)

Aggregations

ConfigHelper (com.google.api.codegen.configgen.ConfigHelper)2 ConfigYamlReader (com.google.api.codegen.configgen.ConfigYamlReader)1 InterfaceTransformer (com.google.api.codegen.configgen.InterfaceTransformer)1 MessageGenerator (com.google.api.codegen.configgen.MessageGenerator)1 ProtoInterfaceTransformer (com.google.api.codegen.configgen.ProtoInterfaceTransformer)1 ProtoMethodTransformer (com.google.api.codegen.configgen.ProtoMethodTransformer)1 ProtoPageStreamingTransformer (com.google.api.codegen.configgen.ProtoPageStreamingTransformer)1 ConfigNode (com.google.api.codegen.configgen.nodes.ConfigNode)1 DiagCollector (com.google.api.tools.framework.model.DiagCollector)1 SimpleDiagCollector (com.google.api.tools.framework.model.SimpleDiagCollector)1 File (java.io.File)1