<commit_before>package org.neo4j.graphql

import graphql.language.*
import org.neo4j.kernel.internal.Version

fun <T> Iterable<T>.joinNonEmpty(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "", limit: Int = -1, truncated: CharSequence = "...", transform: ((T) -> CharSequence)? = null): String {
    return if (iterator().hasNext()) joinTo(StringBuilder(), separator, prefix, postfix, limit, truncated, transform).toString() else ""
}

abstract class CypherGenerator {
    companion object {
        val VERSION = Version.getNeo4jVersion()
        val DEFAULT_CYPHER_VERSION = "3.1"

        fun instance(): CypherGenerator {
            return Cypher31Generator()
        }
    }

    abstract fun generateQueryForField(field: Field): String

    protected fun metaData(name: String) = GraphSchemaScanner.getMetaData(name)!!

    protected fun attr(variable: String, field: String) = "`$variable`.`$field`"

    protected fun isPlural(name: String) = name.endsWith("s")

    protected fun singular(name: String) = name.substring(0, name.length - 1)

    protected fun formatValue(value: Value?): String =
            when (value) {
                is VariableReference -> "{`${value.name}`}"
            // todo turn into parameters  !!
                is IntValue -> value.value.toString()
                is FloatValue -> value.value.toString()
                is BooleanValue -> value.isValue.toString()
                is StringValue -> "\"${value.value}\""
                is EnumValue -> "\"${value.name}\""
                is ObjectValue -> "{" + value.objectFields.map { it.name + ":" + formatValue(it.value) }.joinToString(",") + "}"<commit_msg>remove cypher generator 30 and compiled runtime directive<commit_after>package org.neo4j.graphql

import graphql.language.*
import org.neo4j.kernel.internal.Version

fun <T> Iterable<T>.joinNonEmpty(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "", limit: Int = -1, truncated: CharSequence = "...", transform: ((T) -> CharSequence)? = null): String {
    return if (iterator().hasNext()) joinTo(StringBuilder(), separator, prefix, postfix, limit, truncated, transform).toString() else ""
}

abstract class CypherGenerator {
    companion object {
        val VERSION = Version.getNeo4jVersion()
        val DEFAULT_CYPHER_VERSION = "3.2"

        fun instance(): CypherGenerator {
            return Cypher31Generator()
        }
    }

    abstract fun generateQueryForField(field: Field): String

    protected fun metaData(name: String) = GraphSchemaScanner.getMetaData(name)!!

    protected fun attr(variable: String, field: String) = "`$variable`.`$field`"

    protected fun isPlural(name: String) = name.endsWith("s")

    protected fun singular(name: String) = name.substring(0, name.length - 1)

    protected fun formatValue(value: Value?): String =
            when (value) {
                is VariableReference -> "{`${value.name}`}"
            // todo turn into parameters  !!
                is IntValue -> value.value.toString()
                is FloatValue -> value.value.toString()
                is BooleanValue -> value.isValue.toString()
                is StringValue -> "\"${value.value}\""
                is EnumValue -> "\"${value.name}\""
                is ObjectValue -> "{" + value.objectFields.map { it.name + ":" + formatValue(it.value) }.joinToString(",") + "}"
{'fraction_non_alphanumeric': 0.14127262113251604, 'fraction_numerical': 0.00642148277875073, 'mean_word_length': 2.8766968325791855, 'pattern_counts': {'":': 2, '<': 7, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4436286', 'n_tokens_mistral': 975, 'n_tokens_neox': 930, 'n_words': 237}