FIR: add renderDeclarationOrigin to FirRender
This commit is contained in:
committed by
TeamCityServer
parent
0e98480be3
commit
d7e3c65c45
@@ -60,6 +60,7 @@ class FirRenderer(builder: StringBuilder, private val mode: RenderMode = RenderM
|
|||||||
val renderBodies: Boolean = true,
|
val renderBodies: Boolean = true,
|
||||||
val renderPropertyAccessors: Boolean = true,
|
val renderPropertyAccessors: Boolean = true,
|
||||||
val renderDeclarationAttributes: Boolean = false,
|
val renderDeclarationAttributes: Boolean = false,
|
||||||
|
val renderDeclarationOrigin: Boolean = false,
|
||||||
) {
|
) {
|
||||||
companion object {
|
companion object {
|
||||||
val Normal = RenderMode(
|
val Normal = RenderMode(
|
||||||
@@ -382,8 +383,7 @@ class FirRenderer(builder: StringBuilder, private val mode: RenderMode = RenderM
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun visitDeclaration(declaration: FirDeclaration) {
|
override fun visitDeclaration(declaration: FirDeclaration) {
|
||||||
declaration.renderDeclarationAttributesIfNeeded()
|
declaration.renderDeclarationData()
|
||||||
declaration.renderPhaseIfNeeded()
|
|
||||||
print(
|
print(
|
||||||
when (declaration) {
|
when (declaration) {
|
||||||
is FirRegularClass -> declaration.classKind.name.toLowerCaseAsciiOnly().replace("_", " ")
|
is FirRegularClass -> declaration.classKind.name.toLowerCaseAsciiOnly().replace("_", " ")
|
||||||
@@ -400,7 +400,13 @@ class FirRenderer(builder: StringBuilder, private val mode: RenderMode = RenderM
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun FirDeclaration.renderPhaseIfNeeded() {
|
private fun FirDeclaration.renderDeclarationData() {
|
||||||
|
renderDeclarationResolvePhaseIfNeeded()
|
||||||
|
renderDeclarationAttributesIfNeeded()
|
||||||
|
renderDeclarationOriginIfNeeded()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun FirDeclaration.renderDeclarationResolvePhaseIfNeeded() {
|
||||||
if (mode.renderDeclarationResolvePhase) {
|
if (mode.renderDeclarationResolvePhase) {
|
||||||
print("[${resolvePhase}] ")
|
print("[${resolvePhase}] ")
|
||||||
}
|
}
|
||||||
@@ -415,6 +421,13 @@ class FirRenderer(builder: StringBuilder, private val mode: RenderMode = RenderM
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun FirDeclaration.renderDeclarationOriginIfNeeded() {
|
||||||
|
if (mode.renderDeclarationOrigin) {
|
||||||
|
print("[$origin] ")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private fun FirDeclaration.getAttributesWithValues(): List<Pair<KClass<out FirDeclarationDataKey>, Any?>> {
|
private fun FirDeclaration.getAttributesWithValues(): List<Pair<KClass<out FirDeclarationDataKey>, Any?>> {
|
||||||
val attributesMap = FirDeclarationDataRegistry.allValuesThreadUnsafeForRendering()
|
val attributesMap = FirDeclarationDataRegistry.allValuesThreadUnsafeForRendering()
|
||||||
return attributesMap.entries.sortedBy { it.key.simpleName }.map { (klass, index) -> klass to attributes.arrayMap[index] }
|
return attributesMap.entries.sortedBy { it.key.simpleName }.map { (klass, index) -> klass to attributes.arrayMap[index] }
|
||||||
@@ -527,8 +540,7 @@ class FirRenderer(builder: StringBuilder, private val mode: RenderMode = RenderM
|
|||||||
if (constructor.isActual) {
|
if (constructor.isActual) {
|
||||||
print("actual ")
|
print("actual ")
|
||||||
}
|
}
|
||||||
constructor.renderPhaseIfNeeded()
|
constructor.renderDeclarationData()
|
||||||
constructor.renderDeclarationAttributesIfNeeded()
|
|
||||||
print("constructor")
|
print("constructor")
|
||||||
constructor.typeParameters.renderTypeParameters()
|
constructor.typeParameters.renderTypeParameters()
|
||||||
constructor.valueParameters.renderParameters()
|
constructor.valueParameters.renderParameters()
|
||||||
@@ -550,8 +562,7 @@ class FirRenderer(builder: StringBuilder, private val mode: RenderMode = RenderM
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun visitPropertyAccessor(propertyAccessor: FirPropertyAccessor) {
|
override fun visitPropertyAccessor(propertyAccessor: FirPropertyAccessor) {
|
||||||
propertyAccessor.renderPhaseIfNeeded()
|
propertyAccessor.renderDeclarationData()
|
||||||
propertyAccessor.renderDeclarationAttributesIfNeeded()
|
|
||||||
propertyAccessor.annotations.renderAnnotations()
|
propertyAccessor.annotations.renderAnnotations()
|
||||||
print(propertyAccessor.visibility.asString() + " ")
|
print(propertyAccessor.visibility.asString() + " ")
|
||||||
print(if (propertyAccessor.isInline) "inline " else "")
|
print(if (propertyAccessor.isInline) "inline " else "")
|
||||||
@@ -565,8 +576,7 @@ class FirRenderer(builder: StringBuilder, private val mode: RenderMode = RenderM
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun visitAnonymousFunction(anonymousFunction: FirAnonymousFunction) {
|
override fun visitAnonymousFunction(anonymousFunction: FirAnonymousFunction) {
|
||||||
anonymousFunction.renderPhaseIfNeeded()
|
anonymousFunction.renderDeclarationData()
|
||||||
anonymousFunction.renderDeclarationAttributesIfNeeded()
|
|
||||||
anonymousFunction.annotations.renderAnnotations()
|
anonymousFunction.annotations.renderAnnotations()
|
||||||
val label = anonymousFunction.label
|
val label = anonymousFunction.label
|
||||||
if (label != null) {
|
if (label != null) {
|
||||||
@@ -667,8 +677,7 @@ class FirRenderer(builder: StringBuilder, private val mode: RenderMode = RenderM
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun visitValueParameter(valueParameter: FirValueParameter) {
|
override fun visitValueParameter(valueParameter: FirValueParameter) {
|
||||||
valueParameter.renderPhaseIfNeeded()
|
valueParameter.renderDeclarationData()
|
||||||
valueParameter.renderDeclarationAttributesIfNeeded()
|
|
||||||
valueParameter.annotations.renderAnnotations()
|
valueParameter.annotations.renderAnnotations()
|
||||||
if (valueParameter.isCrossinline) {
|
if (valueParameter.isCrossinline) {
|
||||||
print("crossinline ")
|
print("crossinline ")
|
||||||
|
|||||||
Reference in New Issue
Block a user