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
+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()
|
||||
}
|
||||
Reference in New Issue
Block a user