[AA] Test shortener for the whole file with different options

This commit is contained in:
aleksandrina-streltsova
2023-06-14 09:50:29 +03:00
committed by teamcity
parent 67c3849538
commit 88f2bf85eb
2 changed files with 20 additions and 3 deletions
@@ -5,6 +5,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.utils.executeOnPooledThreadInReadAction
@@ -17,14 +18,22 @@ abstract class AbstractReferenceShortenerForWholeFileTest : AbstractAnalysisApiB
override fun doTestByFileStructure(ktFiles: List<KtFile>, module: TestModule, testServices: TestServices) {
val file = ktFiles.first()
val shortening = executeOnPooledThreadInReadAction {
val shortenings = executeOnPooledThreadInReadAction {
analyseForTest(file) {
collectPossibleReferenceShortenings(file)
ShortenOption.values().map { option ->
val shorteningsForOption = collectPossibleReferenceShortenings(file, file.textRange, { option }, { option })
Pair(option.name, shorteningsForOption)
}
}
}
val actual = buildString {
renderShorteningResults(shortening)
shortenings.forEach { (name, shortening) ->
appendLine("with ${name}:")
if (shortening.isEmpty) return@forEach
renderShorteningResults(shortening)
}
}
testServices.assertions.assertEqualsToTestDataFileSibling(actual)
}
@@ -1,2 +1,10 @@
with DO_NOT_SHORTEN:
with SHORTEN_IF_ALREADY_IMPORTED:
[type] A.B
[qualifier] C.D.Companion.foo()
with SHORTEN_AND_IMPORT:
[type] A.B
[qualifier] C.D.Companion.foo()
with SHORTEN_AND_STAR_IMPORT:
[type] A.B
[qualifier] C.D.Companion.foo()