use of com.google.api.codegen.GeneratedResult in project toolkit by googleapis.
the class CommonGapicProvider method generateSnip.
@Nullable
private List<GeneratedResult> generateSnip(String snippetFileName) {
// Establish required stage for generation.
model.establishStage(Merged.KEY);
if (model.getDiagCollector().getErrorCount() > 0) {
return null;
}
// Run the generator for each service.
List<GeneratedResult> generated = new ArrayList<>();
for (ElementT element : view.getElementIterable(model)) {
GeneratedResult result = generator.generate(element, snippetFileName, context);
String subPath;
// where the element is an Iterable<> instead of a ProtoElement.
if (element instanceof ProtoElement) {
subPath = pathMapper.getOutputPath(((ProtoElement) element).getFullName(), context.getApiConfig());
} else {
subPath = pathMapper.getOutputPath(null, context.getApiConfig());
}
if (!Strings.isNullOrEmpty(subPath)) {
subPath = subPath + "/" + result.getFilename();
} else {
subPath = result.getFilename();
}
GeneratedResult outputResult = GeneratedResult.create(result.getDoc(), subPath);
generated.add(outputResult);
}
// Return result.
if (model.getDiagCollector().getErrorCount() > 0) {
return null;
}
return generated;
}
use of com.google.api.codegen.GeneratedResult in project toolkit by googleapis.
the class CommonGapicProvider method generate.
@Nullable
@Override
public Map<String, Doc> generate(String snippetFileName) {
Map<String, Doc> docs = new TreeMap<>();
List<GeneratedResult> generatedOutput = generateSnip(snippetFileName);
if (generatedOutput == null) {
return docs;
}
for (GeneratedResult result : generatedOutput) {
if (!result.getDoc().isWhitespace()) {
docs.put(result.getFilename(), result.getDoc());
}
}
return docs;
}
Aggregations