use of com.google.api.codegen.common.GeneratedResult in project toolkit by googleapis.
the class DiscoConfigGeneratorApp method generateConfig.
private Map<String, Doc> generateConfig(String outputPath) {
Document document = setupDocument(options.get(DiscoGapicGeneratorApp.DISCOVERY_DOC), getDiagCollector());
ViewModel viewModel = new DiscoConfigTransformer().generateConfig(new DiscoApiModel(document, ""), outputPath);
Map<String, GeneratedResult<Doc>> generatedConfig = new CommonSnippetSetRunner(new CommonRenderingUtil(), true).generate(viewModel);
return GeneratedResult.extractBodies(generatedConfig);
}
use of com.google.api.codegen.common.GeneratedResult in project toolkit by googleapis.
the class LegacyGapicGenerator method generate.
private Map<String, GeneratedResult<Doc>> generate(String snippetFileName) {
// Establish required stage for generation.
model.establishStage(Merged.KEY);
if (model.getDiagReporter().getDiagCollector().getErrorCount() > 0) {
return ImmutableMap.of();
}
// Run the generator for each service.
Map<String, GeneratedResult<Doc>> generated = new TreeMap<>();
for (Interface modelInterface : ProtoModels.getInterfaces(model, context.getApiConfig())) {
if (context.getApiConfig().getInterfaceConfig(modelInterface) == null) {
continue;
}
String subPath;
if (modelInterface == null) {
subPath = pathMapper.getOutputPath(null, context.getApiConfig());
} else {
subPath = pathMapper.getOutputPath(modelInterface.getFullName(), context.getApiConfig());
}
Map<String, GeneratedResult<Doc>> result = generator.generate(modelInterface, snippetFileName, context);
for (Map.Entry<String, GeneratedResult<Doc>> resEntry : result.entrySet()) {
String resSubPath = Strings.isNullOrEmpty(subPath) ? resEntry.getKey() : subPath + "/" + resEntry.getKey();
generated.put(resSubPath, resEntry.getValue());
}
}
// Return result.
if (model.getDiagReporter().getDiagCollector().getErrorCount() > 0) {
return ImmutableMap.of();
}
return generated;
}
use of com.google.api.codegen.common.GeneratedResult in project toolkit by googleapis.
the class PackageGeneratorApp method process.
@Override
protected void process() throws Exception {
model.establishStage(Merged.KEY);
if (model.getDiagReporter().getDiagCollector().getErrorCount() > 0) {
for (Diag diag : model.getDiagReporter().getDiagCollector().getDiags()) {
System.err.println(diag.toString());
}
return;
}
Map<String, GeneratedResult<Doc>> results = generate(model);
ToolUtil.writeFiles(GeneratedResult.extractBodies(results), options.get(OUTPUT_DIR));
}
Aggregations