[LL FIR] extract shortening rendering for tests to a separate file
So it can be reused from other tests ^KT-57966 fixed
This commit is contained in:
committed by
Space Team
parent
3b85715f0f
commit
bb7037aa8e
+2
-10
@@ -6,6 +6,7 @@
|
||||
package org.jetbrains.kotlin.analysis.api.impl.base.test.cases.references
|
||||
|
||||
import org.jetbrains.kotlin.analysis.api.components.ShortenOption
|
||||
import org.jetbrains.kotlin.analysis.api.impl.base.test.cases.references.ShorteningResultsRenderer.renderShorteningResults
|
||||
import org.jetbrains.kotlin.analysis.test.framework.base.AbstractAnalysisApiBasedSingleModuleTest
|
||||
import org.jetbrains.kotlin.analysis.test.framework.services.expressionMarkerProvider
|
||||
import org.jetbrains.kotlin.analysis.test.framework.utils.executeOnPooledThreadInReadAction
|
||||
@@ -36,16 +37,7 @@ abstract class AbstractReferenceShortenerTest : AbstractAnalysisApiBasedSingleMo
|
||||
shortenings.forEach { (name, shortening) ->
|
||||
appendLine("with ${name}:")
|
||||
if (shortening.isEmpty) return@forEach
|
||||
shortening.getTypesToShorten().forEach { userType ->
|
||||
userType.element?.text?.let {
|
||||
appendLine("[type] $it")
|
||||
}
|
||||
}
|
||||
shortening.getQualifiersToShorten().forEach { qualifier ->
|
||||
qualifier.element?.text?.let {
|
||||
appendLine("[qualifier] $it")
|
||||
}
|
||||
}
|
||||
renderShorteningResults(shortening)
|
||||
}
|
||||
}
|
||||
testServices.assertions.assertEqualsToTestDataFileSibling(actual)
|
||||
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright 2010-2023 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.analysis.api.impl.base.test.cases.references
|
||||
|
||||
import org.jetbrains.kotlin.analysis.api.components.ShortenCommand
|
||||
|
||||
internal object ShorteningResultsRenderer {
|
||||
fun StringBuilder.renderShorteningResults(shortening: ShortenCommand) {
|
||||
if (shortening.isEmpty) {
|
||||
appendLine("EMPTY_SHORTENINGS")
|
||||
return
|
||||
}
|
||||
|
||||
shortening.getTypesToShorten().forEach { userType ->
|
||||
userType.element?.text?.let {
|
||||
appendLine("[type] $it")
|
||||
}
|
||||
}
|
||||
shortening.getQualifiersToShorten().forEach { qualifier ->
|
||||
qualifier.element?.text?.let {
|
||||
appendLine("[qualifier] $it")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user