Skip to content

Commit c49acfb

Browse files
demiurg906Space Team
authored and
Space Team
committed
[Test] Render isPublicApi attribute in AA tests
^KT-74040 (cherry picked from commit 279d373)
1 parent eb8beaf commit c49acfb

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

analysis/analysis-api-impl-base/tests/org/jetbrains/kotlin/analysis/api/impl/base/test/cases/symbols/AbstractSymbolTest.kt

+9-2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import org.jetbrains.kotlin.analysis.api.impl.base.test.cases.symbols.SymbolTest
1414
import org.jetbrains.kotlin.analysis.api.impl.base.test.cases.symbols.SymbolTestDirectives.DO_NOT_CHECK_SYMBOL_RESTORE_K1
1515
import org.jetbrains.kotlin.analysis.api.impl.base.test.cases.symbols.SymbolTestDirectives.DO_NOT_CHECK_SYMBOL_RESTORE_K2
1616
import org.jetbrains.kotlin.analysis.api.impl.base.test.cases.symbols.SymbolTestDirectives.PRETTY_RENDERER_OPTION
17+
import org.jetbrains.kotlin.analysis.api.impl.base.test.cases.symbols.SymbolTestDirectives.RENDER_IS_PUBLIC_API
1718
import org.jetbrains.kotlin.analysis.api.renderer.declarations.KaDeclarationRenderer
1819
import org.jetbrains.kotlin.analysis.api.renderer.declarations.impl.KaDeclarationRendererForDebug
1920
import org.jetbrains.kotlin.analysis.api.renderer.declarations.renderers.KaClassifierBodyRenderer
@@ -330,8 +331,12 @@ abstract class AbstractSymbolTest : AbstractAnalysisApiBasedTest() {
330331
}
331332

332333
protected open fun KaSession.renderSymbolForComparison(symbol: KaSymbol, directives: RegisteredDirectives): String {
333-
val renderExpandedTypes = directives[PRETTY_RENDERER_OPTION].any { it == PrettyRendererOption.FULLY_EXPANDED_TYPES }
334-
return with(DebugSymbolRenderer(renderExtra = true, renderExpandedTypes = renderExpandedTypes)) { render(useSiteSession, symbol) }
334+
val renderer = DebugSymbolRenderer(
335+
renderExtra = true,
336+
renderExpandedTypes = directives[PRETTY_RENDERER_OPTION].any { it == PrettyRendererOption.FULLY_EXPANDED_TYPES },
337+
renderIsPublicApi = RENDER_IS_PUBLIC_API in directives
338+
)
339+
return with(renderer) { render(useSiteSession, symbol) }
335340
}
336341
}
337342

@@ -363,6 +368,8 @@ object SymbolTestDirectives : SimpleDirectivesContainer() {
363368
val PRETTY_RENDERER_OPTION by enumDirective(description = "Explicit rendering mode") { PrettyRendererOption.valueOf(it) }
364369

365370
val TARGET_FILE_NAME by stringDirective(description = "The name of the main file")
371+
372+
val RENDER_IS_PUBLIC_API by directive(description = "Render `isPublicApi` attribute for symbols")
366373
}
367374

368375
enum class PrettyRendererOption(val transformation: (KaDeclarationRenderer) -> KaDeclarationRenderer) {

analysis/analysis-api/src/org/jetbrains/kotlin/analysis/api/symbols/DebugSymbolRenderer.kt

+8-1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public class DebugSymbolRenderer(
4747
public val renderExtra: Boolean = false,
4848
public val renderTypeByProperties: Boolean = false,
4949
public val renderExpandedTypes: Boolean = false,
50+
public val renderIsPublicApi: Boolean = false,
5051
) {
5152

5253
public fun render(analysisSession: KaSession, symbol: KaSymbol): String = prettyPrint {
@@ -99,6 +100,12 @@ public class DebugSymbolRenderer(
99100
renderComputedValue("javaSetterName", printer, currentSymbolStack) { symbol.javaSetterName }
100101
renderComputedValue("setterDeprecationStatus", printer, currentSymbolStack) { symbol.setterDeprecationStatus }
101102
}
103+
104+
if (renderIsPublicApi) {
105+
if (symbol is KaDeclarationSymbol) {
106+
renderComputedValue("isPublicApi", printer, currentSymbolStack) { isPublicApi(symbol) }
107+
}
108+
}
102109
}
103110
} finally {
104111
currentSymbolStack -= symbol
@@ -516,4 +523,4 @@ public class DebugSymbolRenderer(
516523
}
517524

518525
private val PrettyPrinter.printer: PrettyPrinter
519-
get() = this
526+
get() = this

0 commit comments

Comments
 (0)