[K2, CLI] Support endOffset in Kotlin CLI

Duplicated messages in testdata appeared because default renderer
renders diagnostic spans ambiguously. It shows only start position.
In fact, there are 3 failures, 2 of them distinguish only by the
diagnostic end offset. See youtrack for more information.

The issue about inconvenient rendering is KT-64989.

#KT-64608
This commit is contained in:
Evgeniy.Zhelenskiy
2024-01-12 03:08:09 +01:00
committed by Space Team
parent 6404cede07
commit f05c972efb
12 changed files with 154 additions and 28 deletions
@@ -12,6 +12,7 @@ import com.intellij.openapi.project.Project
import org.jetbrains.kotlin.analyzer.AnalysisResult
import org.jetbrains.kotlin.cli.common.CLITool
import org.jetbrains.kotlin.cli.common.ExitCode
import org.jetbrains.kotlin.cli.common.messages.MessageRenderer
import org.jetbrains.kotlin.cli.jvm.K2JVMCompiler
import org.jetbrains.kotlin.cli.metadata.K2MetadataCompiler
import org.jetbrains.kotlin.compiler.plugin.ComponentRegistrar
@@ -59,6 +60,7 @@ class AnalysisHandlerExtensionTest : TestCaseWithTmpdir() {
klass: KClass<out ComponentRegistrar>,
expectedExitCode: ExitCode = ExitCode.OK,
extras: List<String> = emptyList(),
messageRenderer: MessageRenderer? = null,
) {
val mainKt = tmpdir.resolve(src.name).apply {
writeText(src.content)
@@ -70,7 +72,7 @@ class AnalysisHandlerExtensionTest : TestCaseWithTmpdir() {
"-d", tmpdir.resolve("out").absolutePath
)
val (output, exitCode) = CompilerTestUtil.executeCompiler(compiler, args + outputPath + extras)
val (output, exitCode) = CompilerTestUtil.executeCompiler(compiler, args + outputPath + extras, messageRenderer)
assertEquals(expectedExitCode, exitCode, output)
}