[Analysis API] Check all possible combinations of arguments in tests for KtType.asPsiType()
This commit is contained in:
committed by
Space Team
parent
bf0150108d
commit
50d526fe91
+16
-3
@@ -8,9 +8,11 @@ package org.jetbrains.kotlin.analysis.api.impl.base.test.cases.components.psiTyp
|
||||
import org.jetbrains.kotlin.analysis.api.analyze
|
||||
import org.jetbrains.kotlin.analysis.api.impl.base.test.cases.components.psiTypeProvider.AnalysisApiPsiTypeProviderTestUtils.findLightDeclarationContext
|
||||
import org.jetbrains.kotlin.analysis.api.impl.base.test.cases.components.psiTypeProvider.AnalysisApiPsiTypeProviderTestUtils.getContainingKtLightClass
|
||||
import org.jetbrains.kotlin.analysis.api.types.KtTypeMappingMode
|
||||
import org.jetbrains.kotlin.analysis.test.framework.base.AbstractAnalysisApiBasedTest
|
||||
import org.jetbrains.kotlin.analysis.test.framework.services.expressionMarkerProvider
|
||||
import org.jetbrains.kotlin.analysis.utils.printer.parentOfType
|
||||
import org.jetbrains.kotlin.analysis.utils.printer.prettyPrint
|
||||
import org.jetbrains.kotlin.psi.KtDeclaration
|
||||
import org.jetbrains.kotlin.psi.KtExpression
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
@@ -35,11 +37,22 @@ abstract class AbstractAnalysisApiExpressionPsiTypeProviderTest : AbstractAnalys
|
||||
val actual = analyze(mainFile) {
|
||||
val returnType = declarationAtCaret.getKtType()
|
||||
if (returnType != null) {
|
||||
val psiType = returnType.asPsiType(psiContext, allowErrorTypes = false)
|
||||
buildString {
|
||||
prettyPrint {
|
||||
appendLine("KtType: ${returnType.render(position = Variance.INVARIANT)}")
|
||||
appendLine("PsiType: $psiType")
|
||||
for (allowErrorTypes in listOf(false, true)) {
|
||||
for (typeMappingMode in KtTypeMappingMode.entries) {
|
||||
for (isAnnotationMethod in listOf(false, true)) {
|
||||
val psiType = returnType.asPsiType(psiContext, allowErrorTypes, typeMappingMode, isAnnotationMethod)
|
||||
appendLine("asPsiType(allowErrorTypes=$allowErrorTypes, mode=$typeMappingMode, isAnnotationMethod=$isAnnotationMethod):")
|
||||
withIndent {
|
||||
appendLine(psiType.toString())
|
||||
}
|
||||
appendLine()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
"null"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user