Search in sources :

Example 1 with DefaultComment

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."));
}
Also used : FieldConfigNode(com.google.api.codegen.configgen.nodes.FieldConfigNode) DefaultComment(com.google.api.codegen.configgen.nodes.metadata.DefaultComment)

Example 2 with DefaultComment

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;
}
Also used : FieldConfigNode(com.google.api.codegen.configgen.nodes.FieldConfigNode) ListItemConfigNode(com.google.api.codegen.configgen.nodes.ListItemConfigNode) ListItemConfigNode(com.google.api.codegen.configgen.nodes.ListItemConfigNode) FieldConfigNode(com.google.api.codegen.configgen.nodes.FieldConfigNode) ConfigNode(com.google.api.codegen.configgen.nodes.ConfigNode) DefaultComment(com.google.api.codegen.configgen.nodes.metadata.DefaultComment)

Example 3 with DefaultComment

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."));
}
Also used : FieldConfigNode(com.google.api.codegen.configgen.nodes.FieldConfigNode) ConfigNode(com.google.api.codegen.configgen.nodes.ConfigNode) ScalarConfigNode(com.google.api.codegen.configgen.nodes.ScalarConfigNode) FieldConfigNode(com.google.api.codegen.configgen.nodes.FieldConfigNode) DefaultComment(com.google.api.codegen.configgen.nodes.metadata.DefaultComment)

Example 4 with DefaultComment

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);
}
Also used : FieldConfigNode(com.google.api.codegen.configgen.nodes.FieldConfigNode) ConfigNode(com.google.api.codegen.configgen.nodes.ConfigNode) ListItemConfigNode(com.google.api.codegen.configgen.nodes.ListItemConfigNode) FieldConfigNode(com.google.api.codegen.configgen.nodes.FieldConfigNode) DefaultComment(com.google.api.codegen.configgen.nodes.metadata.DefaultComment)

Example 5 with DefaultComment

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);
}
Also used : DefaultComment(com.google.api.codegen.configgen.nodes.metadata.DefaultComment) Comment(com.google.api.codegen.configgen.nodes.metadata.Comment) DefaultComment(com.google.api.codegen.configgen.nodes.metadata.DefaultComment) Test(org.junit.Test)

Aggregations

DefaultComment (com.google.api.codegen.configgen.nodes.metadata.DefaultComment)9 FieldConfigNode (com.google.api.codegen.configgen.nodes.FieldConfigNode)7 ConfigNode (com.google.api.codegen.configgen.nodes.ConfigNode)4 ListItemConfigNode (com.google.api.codegen.configgen.nodes.ListItemConfigNode)3 Comment (com.google.api.codegen.configgen.nodes.metadata.Comment)2 Test (org.junit.Test)2 ScalarConfigNode (com.google.api.codegen.configgen.nodes.ScalarConfigNode)1