override fun completeStringUnsafe()

in src/main/kotlin/jetbrains/buildServer/server/querylang/autocompl/ParameterValueFinder.kt [39:56]


    override fun completeStringUnsafe(prefix: String, limit: Int): List<StringInfo<T>> {
        val wordRegex = """[\w.\-_]*?""".toRegex()
        val withQuoteRegex = """"[\s\S]*?""".toRegex()
        val paramOnlyRegex = """$wordRegex|$withQuoteRegex""".toRegex()
        val withValueRegex = """(([\w.\-_]+?)|("[\s\S]+?"))\s*=\s*($withQuoteRegex|$wordRegex)""".toRegex()
        return when {
            prefix.matches(withValueRegex) -> {
                val paramName = prefix.substringBefore("=").trim().removeQuotationMarks()
                val paramValue = prefix.substringAfter("=").trimStart().removeStartMarks()
                val vars = completeParamValue(paramName, paramValue, limit)
                vars.map {StringInfo(paramName.escape1() + "=" + it.str, it.meta)}
            }
            prefix.matches(paramOnlyRegex) || prefix.isEmpty() ->
                completeParamName(prefix.removeStartMarks(), limit)
                    .map {StringInfo(it.str.escape1(), it.meta)}
            else -> listOf()
        }
    }