[AA] split some SymbolByPsi tests on SingleSymbolByPsi to avoid redundant declarations

^KT-54311
This commit is contained in:
Dmitrii Gridin
2022-10-17 14:05:51 +02:00
committed by Space Team
parent 804a92546c
commit a38e1747c3
41 changed files with 936 additions and 1070 deletions
@@ -10,11 +10,12 @@ import org.jetbrains.kotlin.analysis.test.framework.services.expressionMarkerPro
import org.jetbrains.kotlin.idea.references.mainReference
import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.psi.KtNameReferenceExpression
import org.jetbrains.kotlin.psi.KtReferenceExpression
import org.jetbrains.kotlin.test.services.TestServices
abstract class AbstractSymbolByReferenceTest : AbstractSymbolTest() {
override fun KtAnalysisSession.collectSymbols(ktFile: KtFile, testServices: TestServices): SymbolsData {
val referenceExpression = testServices.expressionMarkerProvider.getElementOfTypeAtCaret<KtNameReferenceExpression>(ktFile)
val referenceExpression = testServices.expressionMarkerProvider.getElementOfTypeAtCaret<KtReferenceExpression>(ktFile)
return SymbolsData(
listOfNotNull(referenceExpression.mainReference.resolveToSymbol())
)
@@ -10,6 +10,7 @@ import org.jetbrains.kotlin.analysis.api.components.KtDeclarationRendererOptions
import org.jetbrains.kotlin.analysis.api.impl.base.test.cases.symbols.SymbolTestDirectives.DO_NOT_CHECK_SYMBOL_RESTORE
import org.jetbrains.kotlin.analysis.api.impl.base.test.cases.symbols.SymbolTestDirectives.DO_NOT_CHECK_SYMBOL_RESTORE_K1
import org.jetbrains.kotlin.analysis.api.impl.base.test.cases.symbols.SymbolTestDirectives.DO_NOT_CHECK_SYMBOL_RESTORE_K2
import org.jetbrains.kotlin.analysis.api.impl.base.test.cases.symbols.SymbolTestDirectives.PRETTY_RENDERING_MODE
import org.jetbrains.kotlin.analysis.api.symbols.*
import org.jetbrains.kotlin.analysis.api.symbols.pointers.KtSymbolPointer
import org.jetbrains.kotlin.analysis.test.framework.base.AbstractAnalysisApiSingleFileTest
@@ -45,7 +46,8 @@ abstract class AbstractSymbolTest : AbstractAnalysisApiSingleFileTest() {
?: DO_NOT_CHECK_SYMBOL_RESTORE_K1.takeIf { configurator.frontendKind == FrontendKind.Fe10 && it in directives }
?: DO_NOT_CHECK_SYMBOL_RESTORE_K2.takeIf { configurator.frontendKind == FrontendKind.Fir && it in directives }
val prettyRenderOptions = when (prettyRenderMode) {
val renderMode = directives[PRETTY_RENDERING_MODE].singleOrNull()
val prettyRenderOptions = when (renderMode ?: prettyRenderMode) {
PrettyRenderingMode.RENDER_SYMBOLS_LINE_BY_LINE -> renderingOptions
PrettyRenderingMode.RENDER_SYMBOLS_NESTED -> renderingOptions.copy(renderClassMembers = true)
}
@@ -161,6 +163,8 @@ object SymbolTestDirectives : SimpleDirectivesContainer() {
val DO_NOT_CHECK_SYMBOL_RESTORE_K2 by directive(
description = "Symbol restoring for some symbols in current test is not supported yet in K2",
)
val PRETTY_RENDERING_MODE by enumDirective(description = "Explicit rendering mode") { PrettyRenderingMode.valueOf(it) }
}
enum class PrettyRenderingMode {