<commit_before>/*
 * Copyright (C) 2017-2018 <NAME>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package uk.co.reecedunn.intellij.plugin.intellij.lang

// region BaseX

private class BaseXProduct(id: String, name: String, implementation: Implementation) :
    Product(id, name, implementation) {

    override fun toString(): String = name

    override fun supportsFeature(version: Version, feature: XQueryFeature): Boolean = true

    override fun conformsTo(productVersion: Version, ref: Version): Boolean = when (ref) {
        XmlSchema.REC_1_0_20041028, XmlSchema.REC_1_1_20120405 -> true
        XQuery.REC_1_0_20070123 -> true // Recognises 1.0, processes as 3.0/3.1.
        XQuery.REC_3_0_20140408 -> productVersion.value >= 7.7 // Full implementation.
        XQuery.CR_3_1_20151217 -> productVersion.value in 8.2..8.5
        XQuery.REC_3_1_20170321 -> productVersion.value >= 8.6
        FullText.REC_1_0_20110317, FullText.REC_3_0_20151124 -> true
        UpdateFacility.REC_1_0_20110317 -> true
        UpdateFacility.NOTE_3_0_20170124 -> productVersion.value >= 8.5
        FunctionsAndOperators.REC_3_0_20140408 -> productVersion.value >= 7.7
        FunctionsAndOperators.REC_3_1_20170321 -> productVersion.value >= 8.6
        else -> ref.kind === implementation && ref.value <= productVersion.value
    }

    @Suppress("PropertyName")
    val FLAVOURS_XQUERY: List<Versioned> = listOf(BaseX, XQuery, FullText, UpdateFacility)
    @Suppress("PropertyName")
    val FLAVOURS_UNSUPPORTED: List<Versioned> = listOf()

    override fun flavoursForXQueryVersion(productVersion: Version, version: String): List<Versioned> = when (version) {
        "3.0", "3.1" -> FLAVOURS_XQUERY
        else -> FLAVOURS_UNSUPPORTED
    }
}

object BaseX : Implementation("basex", "BaseX", "http://www.basex.org/") {
    val VERSION_6_1: Version = ProductVersion("6.1", this, "Update Facility, Full Text, fuzzy")
    val VERSION_7_7: Version = ProductVersion("7.7", this, "XQuery 3.0 REC")
    val VERSION_7_8: Version = ProductVersion("7.8", this, "update")
    val VERSION_8_4: Version = ProductVersion("8.4", this, "non-deterministic")
    val VERSION_8_5: Version = ProductVersion("8.5", this, "update {}")
    val VERSION_8_6: Version = ProductVersion("8.6", this, "XQuery 3.1 REC")
    val VERSION_9_0: Version = ProductVersion("9.0", this)

    override val versions: List<Version> = listOf(
        VERSION_6_1,
        VERSION_7_7,
        VERSION_7_8,
        VERSION_8_4,
        VERSION_8_5,
        VERSION_8_6,
        VERSION_9_0
    )

    val BASEX: Product = BaseXProduct("basex", "BaseX", this)

    override val products: List<Product> = listOf(BASEX)

    override fun supportsDialect(dialect: Versioned): Boolean =
        dialect === this || dialect === FullText || dialect === UpdateFacility || dialect === XQuery

    override fun staticContext(product: Product?, productVersion: Version?, xqueryVersion: Specification?): String? {
        return when (xqueryVersion) {
            XQuery.REC_1_0_20070123, XQuery.REC_1_0_20101214 ->
                "res://basex.org/static-context/xquery.xqy"
            XQuery.REC_3_0_20140408 ->
                "res://basex.org/static-context/xquery.xqy"
            XQuery.REC_3_1_20170321, XQuery.CR_3_1_20151217 ->
                "res://basex.org/static-context/xquery.xqy"
            else -> null
        }
    }
}

// endregion
// region eXist-db

private class EXistDBProduct(id: String, name: String, implementation: Implementation) :
    Product(id, name, implementation) {

    override fun toString(): String = name
<commit_msg>Add BaseX 9.1 to the implementations.<commit_after>/*
 * Copyright (C) 2017-2018 <NAME>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package uk.co.reecedunn.intellij.plugin.intellij.lang

// region BaseX

private class BaseXProduct(id: String, name: String, implementation: Implementation) :
    Product(id, name, implementation) {

    override fun toString(): String = name

    override fun supportsFeature(version: Version, feature: XQueryFeature): Boolean = true

    override fun conformsTo(productVersion: Version, ref: Version): Boolean = when (ref) {
        XmlSchema.REC_1_0_20041028, XmlSchema.REC_1_1_20120405 -> true
        XQuery.REC_1_0_20070123 -> true // Recognises 1.0, processes as 3.0/3.1.
        XQuery.REC_3_0_20140408 -> productVersion.value >= 7.7 // Full implementation.
        XQuery.CR_3_1_20151217 -> productVersion.value in 8.2..8.5
        XQuery.REC_3_1_20170321 -> productVersion.value >= 8.6
        FullText.REC_1_0_20110317, FullText.REC_3_0_20151124 -> true
        UpdateFacility.REC_1_0_20110317 -> true
        UpdateFacility.NOTE_3_0_20170124 -> productVersion.value >= 8.5
        FunctionsAndOperators.REC_3_0_20140408 -> productVersion.value >= 7.7
        FunctionsAndOperators.REC_3_1_20170321 -> productVersion.value >= 8.6
        else -> ref.kind === implementation && ref.value <= productVersion.value
    }

    @Suppress("PropertyName")
    val FLAVOURS_XQUERY: List<Versioned> = listOf(BaseX, XQuery, FullText, UpdateFacility)
    @Suppress("PropertyName")
    val FLAVOURS_UNSUPPORTED: List<Versioned> = listOf()

    override fun flavoursForXQueryVersion(productVersion: Version, version: String): List<Versioned> = when (version) {
        "3.0", "3.1" -> FLAVOURS_XQUERY
        else -> FLAVOURS_UNSUPPORTED
    }
}

object BaseX : Implementation("basex", "BaseX", "http://www.basex.org/") {
    val VERSION_6_1: Version = ProductVersion("6.1", this, "Update Facility, Full Text, fuzzy")
    val VERSION_7_7: Version = ProductVersion("7.7", this, "XQuery 3.0 REC")
    val VERSION_7_8: Version = ProductVersion("7.8", this, "update")
    val VERSION_8_4: Version = ProductVersion("8.4", this, "non-deterministic")
    val VERSION_8_5: Version = ProductVersion("8.5", this, "update {}")
    val VERSION_8_6: Version = ProductVersion("8.6", this, "XQuery 3.1 REC")
    val VERSION_9_0: Version = ProductVersion("9.0", this)
    val VERSION_9_1: Version = ProductVersion("9.1", this, "ternary if, ?:, if without else")

    override val versions: List<Version> = listOf(
        VERSION_6_1,
        VERSION_7_7,
        VERSION_7_8,
        VERSION_8_4,
        VERSION_8_5,
        VERSION_8_6,
        VERSION_9_0,
        VERSION_9_1
    )

    val BASEX: Product = BaseXProduct("basex", "BaseX", this)

    override val products: List<Product> = listOf(BASEX)

    override fun supportsDialect(dialect: Versioned): Boolean =
        dialect === this || dialect === FullText || dialect === UpdateFacility || dialect === XQuery

    override fun staticContext(product: Product?, productVersion: Version?, xqueryVersion: Specification?): String? {
        return when (xqueryVersion) {
            XQuery.REC_1_0_20070123, XQuery.REC_1_0_20101214 ->
                "res://basex.org/static-context/xquery.xqy"
            XQuery.REC_3_0_20140408 ->
                "res://basex.org/static-context/xquery.xqy"
            XQuery.REC_3_1_20170321, XQuery.CR_3_1_20151217 ->
                "res://basex.org/static-context/xquery.xqy"
            else -> null
        }
    }
}

// endregion
// region eXist-db

private class EXistDBProduct(id: String, name: String, implementation: Implementation) :
    Product(id, name, implementation) {

    override fun toString(): String = name

{'fraction_non_alphanumeric': 0.11205351809819615, 'fraction_numerical': 0.06116354079560387, 'mean_word_length': 3.3154639175257734, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 59, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, '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': '536597', 'n_tokens_mistral': 2917, 'n_tokens_neox': 2654, 'n_words': 654}