KT-38027 Support Code Vision feature in Kotlin // experimental status
Feature received "experimental" status due to the low performance.
The root cause is slow find-usages functionality the feature is based
on. Once the later is improved Code-Vision should be revisited.
Previous commit of KT-38027 series contains production ready state.
To launch performance check again one needs to enable Code Vision in
AbstractPerformanceProjectsTest.setUp() with the following fun:
private fun enabledCodeVision() {
val codeVisionProvider = KotlinCodeVisionProvider()
val settings = codeVisionProvider.createSettings().apply {
showUsages = true
showInheritors = true
}
InlayHintsSettings.instance().storeSettings(codeVisionProvider.key,
KotlinLanguage.INSTANCE, settings)
}
This commit is contained in:
+16
-14
@@ -6,13 +6,18 @@
|
||||
package org.jetbrains.kotlin.idea.codeInsight.codevision
|
||||
|
||||
import com.intellij.openapi.util.io.FileUtil
|
||||
import com.intellij.openapi.util.registry.Registry
|
||||
import com.intellij.testFramework.utils.inlays.InlayHintsProviderTestCase
|
||||
import org.jetbrains.kotlin.idea.codeInsight.codevision.KotlinCodeVisionProvider.KotlinCodeVisionSettings
|
||||
import org.jetbrains.kotlin.test.InTextDirectivesUtils
|
||||
import java.io.File
|
||||
|
||||
open class AbstractKotlinCodeVisionProviderTest : InlayHintsProviderTestCase() { // Abstract- prefix is just a convention for GenerateTests
|
||||
|
||||
companion object {
|
||||
const val INHERITORS_KEY = "kotlin.code-vision.inheritors"
|
||||
const val USAGES_KEY = "kotlin.code-vision.usages"
|
||||
}
|
||||
|
||||
fun doTest(testPath: String) { // named according to the convention imposed by GenerateTests
|
||||
assertThatActualHintsMatch(testPath)
|
||||
}
|
||||
@@ -27,21 +32,18 @@ open class AbstractKotlinCodeVisionProviderTest : InlayHintsProviderTestCase() {
|
||||
codeVisionProvider.usagesLimit = usagesLimit
|
||||
codeVisionProvider.inheritorsLimit = inheritorsLimit
|
||||
|
||||
val mode: KotlinCodeVisionSettings = when (InTextDirectivesUtils.findStringWithPrefixes(fileContents, "// MODE: ")) {
|
||||
"inheritors" -> inheritorsEnabled()
|
||||
"usages" -> usagesEnabled()
|
||||
"usages-&-inheritors" -> usagesAndInheritorsEnabled()
|
||||
else -> codeVisionDisabled()
|
||||
when (InTextDirectivesUtils.findStringWithPrefixes(fileContents, "// MODE: ")) {
|
||||
"inheritors" -> mode(usages = false, inheritors = true)
|
||||
"usages" -> mode(usages = true, inheritors = false)
|
||||
"usages-&-inheritors" -> mode(usages = true, inheritors = true)
|
||||
else -> mode(usages = false, inheritors = false)
|
||||
}
|
||||
|
||||
testProvider("kotlinCodeVision.kt", fileContents, codeVisionProvider, mode)
|
||||
testProvider("kotlinCodeVision.kt", fileContents, codeVisionProvider)
|
||||
}
|
||||
|
||||
private fun usagesAndInheritorsEnabled(): KotlinCodeVisionSettings = KotlinCodeVisionSettings(showUsages = true, showInheritors = true)
|
||||
|
||||
private fun inheritorsEnabled(): KotlinCodeVisionSettings = KotlinCodeVisionSettings(showUsages = false, showInheritors = true)
|
||||
|
||||
private fun usagesEnabled(): KotlinCodeVisionSettings = KotlinCodeVisionSettings(showUsages = true, showInheritors = false)
|
||||
|
||||
private fun codeVisionDisabled(): KotlinCodeVisionSettings = KotlinCodeVisionSettings(showUsages = false, showInheritors = false)
|
||||
private fun mode(usages: Boolean, inheritors: Boolean) {
|
||||
Registry.get(USAGES_KEY).setValue(usages)
|
||||
Registry.get(INHERITORS_KEY).setValue(inheritors)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user