[FIR] Set publishedApiEffectiveVisibility on deserialized declarations
#KT-58641 Fixed
This commit is contained in:
committed by
Space Team
parent
2581139b82
commit
ee91ee9403
+12
-6
@@ -14,25 +14,31 @@ import org.jetbrains.kotlin.fir.symbols.impl.FirClassLikeSymbol
|
||||
open class FirDeclarationRendererWithAttributes : FirDeclarationRenderer() {
|
||||
override fun FirDeclaration.renderDeclarationAttributes() {
|
||||
if (attributes.isNotEmpty()) {
|
||||
val attributes = getAttributesWithValues().mapNotNull { (klass, value) ->
|
||||
value?.let { klass to value.renderAsDeclarationAttributeValue() }
|
||||
}.joinToString { (name, value) -> "$name=$value" }
|
||||
val attributes = getAttributesWithValues()
|
||||
.mapNotNull { (klass, value) -> value?.let { klass to value.renderAsDeclarationAttributeValue() } }
|
||||
.ifEmpty { return }
|
||||
.joinToString { (name, value) -> "$name=$value" }
|
||||
printer.print("[$attributes] ")
|
||||
}
|
||||
}
|
||||
|
||||
private fun FirDeclaration.getAttributesWithValues(): List<Pair<String, Any?>> {
|
||||
val attributesMap = FirDeclarationDataRegistry.allValuesThreadUnsafeForRendering()
|
||||
return attributesMap.entries
|
||||
.map { it.key.substringAfterLast(".") to it.value }
|
||||
return attributeTypesToIds()
|
||||
.sortedBy { it.first }
|
||||
.map { (klass, index) -> klass to attributes[index] }
|
||||
}
|
||||
|
||||
protected open fun attributeTypesToIds(): List<Pair<String, Int>> {
|
||||
val attributeMap = FirDeclarationDataRegistry.allValuesThreadUnsafeForRendering()
|
||||
return attributeMap.entries
|
||||
.map { it.key.substringAfterLast(".") to it.value }
|
||||
}
|
||||
|
||||
private fun Any.renderAsDeclarationAttributeValue() = when (this) {
|
||||
is FirCallableSymbol<*> -> callableId.toString()
|
||||
is FirClassLikeSymbol<*> -> classId.asString()
|
||||
is FirProperty -> symbol.callableId.toString()
|
||||
is Lazy<*> -> value.toString()
|
||||
else -> toString()
|
||||
}
|
||||
}
|
||||
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.fir.renderer
|
||||
|
||||
class FirDeclarationRendererWithFilteredAttributes : FirDeclarationRendererWithAttributes() {
|
||||
override fun attributeTypesToIds(): List<Pair<String, Int>> {
|
||||
return super.attributeTypesToIds().filter { it.first !in IGNORED_ATTRIBUTES }
|
||||
}
|
||||
|
||||
private companion object {
|
||||
private val IGNORED_ATTRIBUTES = setOf("FirVersionRequirementsTableKey", "SourceElementKey")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user