Skip to content

Commit 279d373

Browse files
demiurg906Space Team
authored and
Space Team
committed
[Test] Render isPublicApi attribute in AA tests
^KT-74040
1 parent 73172e0 commit 279d373

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
@@ -17,6 +17,7 @@ import org.jetbrains.kotlin.analysis.api.impl.base.test.cases.symbols.SymbolTest
1717
import org.jetbrains.kotlin.analysis.api.impl.base.test.cases.symbols.SymbolTestDirectives.DO_NOT_CHECK_SYMBOL_RESTORE_K1
1818
import org.jetbrains.kotlin.analysis.api.impl.base.test.cases.symbols.SymbolTestDirectives.DO_NOT_CHECK_SYMBOL_RESTORE_K2
1919
import org.jetbrains.kotlin.analysis.api.impl.base.test.cases.symbols.SymbolTestDirectives.PRETTY_RENDERER_OPTION
20+
import org.jetbrains.kotlin.analysis.api.impl.base.test.cases.symbols.SymbolTestDirectives.RENDER_IS_PUBLIC_API
2021
import org.jetbrains.kotlin.analysis.api.renderer.declarations.KaDeclarationRenderer
2122
import org.jetbrains.kotlin.analysis.api.renderer.declarations.impl.KaDeclarationRendererForDebug
2223
import org.jetbrains.kotlin.analysis.api.renderer.declarations.renderers.KaClassifierBodyRenderer
@@ -376,8 +377,12 @@ abstract class AbstractSymbolTest : AbstractAnalysisApiBasedTest() {
376377
}
377378

378379
protected open fun KaSession.renderSymbolForComparison(symbol: KaSymbol, directives: RegisteredDirectives): String {
379-
val renderExpandedTypes = directives[PRETTY_RENDERER_OPTION].any { it == PrettyRendererOption.FULLY_EXPANDED_TYPES }
380-
return with(DebugSymbolRenderer(renderExtra = true, renderExpandedTypes = renderExpandedTypes)) { render(useSiteSession, symbol) }
380+
val renderer = DebugSymbolRenderer(
381+
renderExtra = true,
382+
renderExpandedTypes = directives[PRETTY_RENDERER_OPTION].any { it == PrettyRendererOption.FULLY_EXPANDED_TYPES },
383+
renderIsPublicApi = RENDER_IS_PUBLIC_API in directives
384+
)
385+
return with(renderer) { render(useSiteSession, symbol) }
381386
}
382387
}
383388

@@ -411,6 +416,8 @@ object SymbolTestDirectives : SimpleDirectivesContainer() {
411416
val TARGET_FILE_NAME by stringDirective(description = "The name of the main file")
412417

413418
val ILLEGAL_PSI by stringDirective(description = "Symbol should not be created for this PSI element")
419+
420+
val RENDER_IS_PUBLIC_API by directive(description = "Render `isPublicApi` attribute for symbols")
414421
}
415422

416423
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
@@ -44,6 +44,7 @@ public class DebugSymbolRenderer(
4444
public val renderExtra: Boolean = false,
4545
public val renderTypeByProperties: Boolean = false,
4646
public val renderExpandedTypes: Boolean = false,
47+
public val renderIsPublicApi: Boolean = false,
4748
) {
4849

4950
public fun render(analysisSession: KaSession, symbol: KaSymbol): String = prettyPrint {
@@ -100,6 +101,12 @@ public class DebugSymbolRenderer(
100101
renderComputedValue("javaSetterName", printer, currentSymbolStack) { symbol.javaSetterName }
101102
renderComputedValue("setterDeprecationStatus", printer, currentSymbolStack) { symbol.setterDeprecationStatus }
102103
}
104+
105+
if (renderIsPublicApi) {
106+
if (symbol is KaDeclarationSymbol) {
107+
renderComputedValue("isPublicApi", printer, currentSymbolStack) { isPublicApi(symbol) }
108+
}
109+
}
103110
}
104111
} finally {
105112
currentSymbolStack -= symbol
@@ -517,4 +524,4 @@ public class DebugSymbolRenderer(
517524
}
518525

519526
private val PrettyPrinter.printer: PrettyPrinter
520-
get() = this
527+
get() = this

0 commit comments

Comments
 (0)