use of com.google.api.codegen.configgen.nodes.ConfigNode in project toolkit by googleapis.
the class MissingFieldTransformer method generate.
public FieldConfigNode generate() {
ConfigNode node = NodeFinder.findByValue(parent, name);
if (node instanceof FieldConfigNode) {
return (FieldConfigNode) node;
}
if (prev == null) {
ConfigNode next = parent.getChild();
int startLine = next.isPresent() ? next.getStartLine() : parent.getStartLine() + 1;
node = new FieldConfigNode(startLine, name);
parent.setChild(node.insertNext(next));
} else {
ConfigNode next = node.getNext();
node = new FieldConfigNode(NodeFinder.getNextLine(prev), name);
prev.insertNext(node.insertNext(next));
}
return ((FieldConfigNode) node);
}
use of com.google.api.codegen.configgen.nodes.ConfigNode in project toolkit by googleapis.
the class CollectionMerger method generateCollectionNode.
private ConfigNode generateCollectionNode(int startLine, String namePattern, String entityName) {
ConfigNode collectionNode = new ListItemConfigNode(startLine);
ConfigNode namePatternNode = FieldConfigNode.createStringPair(collectionNode.getStartLine(), "name_pattern", namePattern);
collectionNode.setChild(namePatternNode);
ConfigNode entityNameNode = FieldConfigNode.createStringPair(NodeFinder.getNextLine(namePatternNode), "entity_name", entityName);
namePatternNode.insertNext(entityNameNode);
return collectionNode;
}
use of com.google.api.codegen.configgen.nodes.ConfigNode in project toolkit by googleapis.
the class ConfigMerger method mergeConfig.
private FieldConfigNode mergeConfig(ApiModel model, FieldConfigNode configNode) {
ConfigNode typeNode = mergeType(configNode);
if (typeNode == null) {
return null;
}
ConfigNode versionNode = mergeVersion(configNode, typeNode);
if (versionNode == null) {
return null;
}
ConfigNode languageSettingsNode = languageSettingsMerger.mergeLanguageSettings(packageName, configNode, versionNode);
mergeLicenseHeader(configNode, languageSettingsNode);
interfaceMerger.mergeInterfaces(model, configNode);
return configNode;
}
use of com.google.api.codegen.configgen.nodes.ConfigNode in project toolkit by googleapis.
the class InterfaceMerger method mergeInterfaces.
public void mergeInterfaces(ApiModel model, ConfigNode configNode) {
FieldConfigNode interfacesNode = MissingFieldTransformer.append("interfaces", configNode).generate();
if (NodeFinder.hasContent(interfacesNode.getChild())) {
return;
}
ConfigNode interfacesValueNode = ListTransformer.generateList(model.getInterfaces(), interfacesNode, this::generateInterfaceNode);
interfacesNode.setChild(interfacesValueNode).setComment(new DefaultComment("A list of API interface configurations."));
}
use of com.google.api.codegen.configgen.nodes.ConfigNode in project toolkit by googleapis.
the class LanguageSettingsMerger method mergePackageNameValue.
private ConfigNode mergePackageNameValue(ConfigNode packageNameNode, LanguageFormatter languageFormatter, String packageName) {
ConfigNode packageNameValueNode = new ScalarConfigNode(packageNameNode.getStartLine(), languageFormatter.getFormattedPackageName(packageName));
packageNameNode.setChild(packageNameValueNode);
return packageNameValueNode;
}
Aggregations