use of com.google.api.codegen.configgen.nodes.metadata.DefaultComment in project toolkit by googleapis.
the class ConfigMerger method mergeLicenseHeader.
private void mergeLicenseHeader(ConfigNode configNode, ConfigNode prevNode) {
FieldConfigNode licenseHeaderNode = MissingFieldTransformer.insert("license_header", configNode, prevNode).generate();
if (NodeFinder.hasContent(licenseHeaderNode.getChild())) {
return;
}
FieldConfigNode copyrightFileNode = FieldConfigNode.createStringPair(NodeFinder.getNextLine(licenseHeaderNode), "copyright_file", CONFIG_DEFAULT_COPYRIGHT_FILE).setComment(new DefaultComment("The file containing the copyright line(s)."));
FieldConfigNode licenseFileNode = FieldConfigNode.createStringPair(NodeFinder.getNextLine(copyrightFileNode), "license_file", CONFIG_DEFAULT_LICENSE_FILE).setComment(new DefaultComment("The file containing the raw license header without any copyright line(s)."));
licenseHeaderNode.setChild(copyrightFileNode.insertNext(licenseFileNode)).setComment(new DefaultComment("The configuration for the license header to put on generated files."));
}
use of com.google.api.codegen.configgen.nodes.metadata.DefaultComment in project toolkit by googleapis.
the class InterfaceMerger method generateInterfaceNode.
private ListItemConfigNode generateInterfaceNode(int startLine, InterfaceModel apiInterface) {
Map<String, String> collectionNameMap = interfaceTransformer.getResourceToEntityNameMap(apiInterface);
ListItemConfigNode interfaceNode = new ListItemConfigNode(startLine);
FieldConfigNode nameNode = FieldConfigNode.createStringPair(startLine, "name", apiInterface.getFullName()).setComment(new DefaultComment("The fully qualified name of the API interface."));
interfaceNode.setChild(nameNode);
ConfigNode collectionsNode = collectionMerger.generateCollectionsNode(nameNode, collectionNameMap);
ConfigNode retryParamsDefNode = retryMerger.generateRetryDefinitionsNode(collectionsNode);
methodMerger.generateMethodsNode(interfaceNode, apiInterface, collectionNameMap);
return interfaceNode;
}
use of com.google.api.codegen.configgen.nodes.metadata.DefaultComment in project toolkit by googleapis.
the class LanguageSettingsMerger method mergeLanguageSettings.
public ConfigNode mergeLanguageSettings(final String packageName, ConfigNode configNode, ConfigNode prevNode) {
FieldConfigNode languageSettingsNode = MissingFieldTransformer.insert("language_settings", configNode, prevNode).generate();
if (NodeFinder.hasContent(languageSettingsNode.getChild())) {
return languageSettingsNode;
}
ConfigNode languageSettingsValueNode = ListTransformer.generateList(LANGUAGE_FORMATTERS.entrySet(), languageSettingsNode, (startLine, entry) -> {
ConfigNode languageNode = new FieldConfigNode(startLine, entry.getKey());
mergeLanguageSetting(languageNode, entry.getValue(), packageName);
return languageNode;
});
return languageSettingsNode.setChild(languageSettingsValueNode).setComment(new DefaultComment("The settings of generated code in a specific language."));
}
use of com.google.api.codegen.configgen.nodes.metadata.DefaultComment in project toolkit by googleapis.
the class MethodMerger method generateMethodsNode.
public void generateMethodsNode(ConfigNode parentNode, InterfaceModel apiInterface, Map<String, String> collectionNameMap) {
ConfigNode prevNode = NodeFinder.getLastChild(parentNode);
FieldConfigNode methodsNode = new FieldConfigNode(NodeFinder.getNextLine(prevNode), "methods").setComment(new DefaultComment(METHODS_COMMENT));
prevNode.insertNext(methodsNode);
generateMethodsValueNode(methodsNode, apiInterface, collectionNameMap);
}
use of com.google.api.codegen.configgen.nodes.metadata.DefaultComment in project toolkit by googleapis.
the class FieldConfigNodeTest method testComment.
@Test
public void testComment() throws Exception {
FieldConfigNode node = new FieldConfigNode(0, "foo");
Comment comment = new DefaultComment("Lorem ispum");
Truth.assertThat(node.getComment().generate()).isEqualTo("");
Truth.assertThat(node.setComment(comment)).isSameAs(node);
Truth.assertThat(node.getComment()).isSameAs(comment);
}
Aggregations