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:
committed by
Roman Golyshev
parent
b30a9e1d3e
commit
28ec74648e
@@ -164,6 +164,7 @@ extra["versions.org.springframework"] = "4.2.0.RELEASE"
|
|||||||
extra["versions.jflex"] = "1.7.0"
|
extra["versions.jflex"] = "1.7.0"
|
||||||
extra["versions.markdown"] = "0.1.25"
|
extra["versions.markdown"] = "0.1.25"
|
||||||
extra["versions.trove4j"] = "1.0.20181211"
|
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.
|
// 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"
|
extra["versions.ktor-network"] = "1.0.1"
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ plugins {
|
|||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
maven("https://jetbrains.bintray.com/markdown")
|
maven("https://jetbrains.bintray.com/markdown")
|
||||||
|
maven("https://jetbrains.bintray.com/intellij-third-party-dependencies")
|
||||||
}
|
}
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
@@ -103,6 +104,10 @@ dependencies {
|
|||||||
testRuntime(intellijPluginDep("java"))
|
testRuntime(intellijPluginDep("java"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Platform[193].orHigher {
|
||||||
|
implementation(commonDep("org.jetbrains.intellij.deps.completion", "completion-ranking-kotlin"))
|
||||||
|
}
|
||||||
|
|
||||||
compileOnly(commonDep("org.jetbrains", "markdown"))
|
compileOnly(commonDep("org.jetbrains", "markdown"))
|
||||||
compileOnly(commonDep("com.google.code.findbugs", "jsr305"))
|
compileOnly(commonDep("com.google.code.findbugs", "jsr305"))
|
||||||
compileOnly(intellijPluginDep("IntelliLang"))
|
compileOnly(intellijPluginDep("IntelliLang"))
|
||||||
|
|||||||
+24
@@ -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)
|
||||||
|
}
|
||||||
+14
@@ -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()
|
||||||
|
}
|
||||||
@@ -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"/>
|
<trafficLightRendererContributor implementation="org.jetbrains.kotlin.idea.core.script.ScriptTrafficLightRendererContributor"/>
|
||||||
<fileTypeUsageSchemaDescriptor schema="Gradle Script" implementationClass="org.jetbrains.kotlin.idea.core.script.KotlinGradleScriptFileTypeSchemaDetector"/>
|
<fileTypeUsageSchemaDescriptor schema="Gradle Script" implementationClass="org.jetbrains.kotlin.idea.core.script.KotlinGradleScriptFileTypeSchemaDetector"/>
|
||||||
|
|
||||||
|
<completion.ml.model implementation="org.jetbrains.kotlin.idea.completion.ml.KotlinMLRankingProvider"/>
|
||||||
</extensions>
|
</extensions>
|
||||||
</idea-plugin>
|
</idea-plugin>
|
||||||
|
|||||||
Reference in New Issue
Block a user