[AA] Test shortener for the whole file with different options
This commit is contained in:
committed by
teamcity
parent
67c3849538
commit
88f2bf85eb
+12
-3
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.analysis.api.impl.base.test.cases.references
|
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.api.impl.base.test.cases.references.ShorteningResultsRenderer.renderShorteningResults
|
||||||
import org.jetbrains.kotlin.analysis.test.framework.base.AbstractAnalysisApiBasedSingleModuleTest
|
import org.jetbrains.kotlin.analysis.test.framework.base.AbstractAnalysisApiBasedSingleModuleTest
|
||||||
import org.jetbrains.kotlin.analysis.test.framework.utils.executeOnPooledThreadInReadAction
|
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) {
|
override fun doTestByFileStructure(ktFiles: List<KtFile>, module: TestModule, testServices: TestServices) {
|
||||||
val file = ktFiles.first()
|
val file = ktFiles.first()
|
||||||
|
|
||||||
val shortening = executeOnPooledThreadInReadAction {
|
val shortenings = executeOnPooledThreadInReadAction {
|
||||||
analyseForTest(file) {
|
analyseForTest(file) {
|
||||||
collectPossibleReferenceShortenings(file)
|
ShortenOption.values().map { option ->
|
||||||
|
val shorteningsForOption = collectPossibleReferenceShortenings(file, file.textRange, { option }, { option })
|
||||||
|
|
||||||
|
Pair(option.name, shorteningsForOption)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val actual = buildString {
|
val actual = buildString {
|
||||||
renderShorteningResults(shortening)
|
shortenings.forEach { (name, shortening) ->
|
||||||
|
appendLine("with ${name}:")
|
||||||
|
if (shortening.isEmpty) return@forEach
|
||||||
|
renderShorteningResults(shortening)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
testServices.assertions.assertEqualsToTestDataFileSibling(actual)
|
testServices.assertions.assertEqualsToTestDataFileSibling(actual)
|
||||||
}
|
}
|
||||||
|
|||||||
+8
@@ -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
|
[type] A.B
|
||||||
[qualifier] C.D.Companion.foo()
|
[qualifier] C.D.Companion.foo()
|
||||||
|
|||||||
Reference in New Issue
Block a user