use of com.google.cloud.discotoproto3converter.disco.Document in project disco-to-proto3-converter by googleapis.
the class ConverterApp method convert.
public void convert(String discoveryDocPath, String previousProtoPath, String outputFilePath, String serviceIgnorelist, String messageIgnorelist, String relativeLinkPrefix, String enumsAsStrings, String outputComments) throws IOException {
ProtoFile newProtoFile = null;
if (discoveryDocPath != null) {
Document document = createDocument(discoveryDocPath);
DocumentToProtoConverter converter = new DocumentToProtoConverter(document, Paths.get(discoveryDocPath).getFileName().toString(), new HashSet<>(Arrays.asList(serviceIgnorelist.split(","))), new HashSet<>(Arrays.asList(messageIgnorelist.split(","))), relativeLinkPrefix, Boolean.valueOf(enumsAsStrings));
newProtoFile = converter.getProtoFile();
}
ProtoFile previousProtoFile = null;
if (previousProtoPath != null) {
ProtoParser parser = new ProtoParser(readProtoFile(previousProtoPath));
previousProtoFile = new ProtoParser(readProtoFile(previousProtoPath)).getProtoFile();
}
if (newProtoFile != null) {
ProtoFile mergedProtoFile = newProtoFile;
if (previousProtoFile != null) {
// TODO: merge previousProtoFile and newProtoFile and assign to mergedProtoFile
}
try (PrintWriter pw = makeDefaultDirsAndWriter(outputFilePath)) {
writer.writeToFile(pw, mergedProtoFile, Boolean.valueOf(outputComments));
}
} else if (previousProtoFile != null) {
try (PrintWriter pw = makeDefaultDirsAndWriter(outputFilePath)) {
writer.writeToFile(pw, previousProtoFile, Boolean.valueOf(outputComments));
}
}
}
Aggregations