REPL: Fix completion for protected members

This commit is contained in:
Ilya Muradyan
2021-12-23 14:29:18 +03:00
parent 610429a278
commit bb34a74abb
3 changed files with 50 additions and 4 deletions
@@ -442,6 +442,39 @@ class ReplCompletionAndErrorsAnalysisTest : TestCase() {
}
}
@Test
fun testProtectedInheritedMemberCompletion() = test {
run {
code = """
open class Base {
private val xyz1: Float = 7.0f
protected val xyz2: Int = 42
internal val xyz3: String = ""
public val xyz4: Byte = 8
}
""".trimIndent()
doCompile
}
run {
val definition = "val c = x"
code = """
object : Base() {
fun g() {
$definition
}
}
""".trimIndent()
cursor = code.indexOf(definition) + definition.length
expect {
addCompletion("xyz2", "xyz2", "Int", "property")
addCompletion("xyz3", "xyz3", "String", "property")
addCompletion("xyz4", "xyz4", "Byte", "property")
}
}
}
@Ignore("Should be fixed by KT-39314")
@Test
fun ignore_testDefaultImportsNotFirst() = test {
@@ -14,6 +14,8 @@ import java.util.concurrent.atomic.AtomicInteger
import kotlin.reflect.KProperty
import kotlin.reflect.KProperty0
import kotlin.script.experimental.api.*
import kotlin.script.experimental.jvm.impl.KJvmCompiledScript
import kotlin.script.experimental.util.LinkedSnippet
import kotlin.system.measureTimeMillis
class TestConf {
@@ -249,8 +251,13 @@ private suspend fun evaluateInRepl(
if (doCompile) {
val codeLineForCompilation = nextCodeLine(code, lineCounter)
val timeMillis = measureTimeMillis { compiler.compile(codeLineForCompilation, newCompilationConfiguration) }
val compilationResult: ResultWithDiagnostics<LinkedSnippet<KJvmCompiledScript>>
val timeMillis = measureTimeMillis {
compilationResult = compiler.compile(codeLineForCompilation, newCompilationConfiguration)
}
if (compilationResult is ResultWithDiagnostics.Failure) {
System.err.println(compilationResult.reports.joinToString("\n", "Compilation failed:\n") { it.toString() })
}
loggingInfo?.compile?.writeValue(timeMillis)
}