Use ML completion extension point from 193 platform

- completion-ranking-kotlin jar used to be in the IDEA itself; thanks to new extension it can reside in the plugin from now on
- ML completion is turned off by default
- use `implementation` dependency because `completion-ranking-kotlin` is required during runtime
This commit is contained in:
Roman Golyshev
2019-10-17 19:00:57 +03:00
committed by Roman Golyshev
parent b30a9e1d3e
commit 28ec74648e
5 changed files with 46 additions and 0 deletions
+1
View File
@@ -164,6 +164,7 @@ extra["versions.org.springframework"] = "4.2.0.RELEASE"
extra["versions.jflex"] = "1.7.0"
extra["versions.markdown"] = "0.1.25"
extra["versions.trove4j"] = "1.0.20181211"
extra["versions.completion-ranking-kotlin"] = "0.0.2"
// NOTE: please, also change KTOR_NAME in pathUtil.kt and all versions in corresponding jar names in daemon tests.
extra["versions.ktor-network"] = "1.0.1"
+5
View File
@@ -5,6 +5,7 @@ plugins {
repositories {
maven("https://jetbrains.bintray.com/markdown")
maven("https://jetbrains.bintray.com/intellij-third-party-dependencies")
}
sourceSets {
@@ -103,6 +104,10 @@ dependencies {
testRuntime(intellijPluginDep("java"))
}
Platform[193].orHigher {
implementation(commonDep("org.jetbrains.intellij.deps.completion", "completion-ranking-kotlin"))
}
compileOnly(commonDep("org.jetbrains", "markdown"))
compileOnly(commonDep("com.google.code.findbugs", "jsr305"))
compileOnly(intellijPluginDep("IntelliLang"))
@@ -0,0 +1,24 @@
/*
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.idea.completion.ml
import com.completion.ranker.model.kotlin.MLWhiteBox
import com.intellij.internal.ml.DecisionFunction
import com.intellij.internal.ml.ModelMetadata
import com.intellij.internal.ml.completion.CompletionRankingModelBase
import com.intellij.internal.ml.completion.JarCompletionModelProvider
import com.intellij.lang.Language
@Suppress("UnstableApiUsage")
class KotlinMLRankingProvider : JarCompletionModelProvider("Kotlin", "kotlin_features") {
override fun createModel(metadata: ModelMetadata): DecisionFunction {
return object : CompletionRankingModelBase(metadata) {
override fun predict(features: DoubleArray?): Double = MLWhiteBox.makePredict(features)
}
}
override fun isLanguageSupported(language: Language): Boolean = language.id.equals("kotlin", ignoreCase = true)
}
@@ -0,0 +1,14 @@
/*
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.idea.completion.test
import org.jetbrains.kotlin.idea.completion.ml.KotlinMLRankingProvider
import org.junit.Test
class KotlinModelMetadataTest {
@Test
fun testMetadataConsistent() = KotlinMLRankingProvider().assertModelMetadataConsistent()
}
+2
View File
@@ -81,5 +81,7 @@ The Kotlin plugin provides language support in IntelliJ IDEA and Android Studio.
<trafficLightRendererContributor implementation="org.jetbrains.kotlin.idea.core.script.ScriptTrafficLightRendererContributor"/>
<fileTypeUsageSchemaDescriptor schema="Gradle Script" implementationClass="org.jetbrains.kotlin.idea.core.script.KotlinGradleScriptFileTypeSchemaDetector"/>
<completion.ml.model implementation="org.jetbrains.kotlin.idea.completion.ml.KotlinMLRankingProvider"/>
</extensions>
</idea-plugin>