[IR] KotlinLikeDumper: unify printing custom/non-standard modifiers
This commit is contained in:
committed by
teamcityserver
parent
57cb8f97e9
commit
90fdfbde68
@@ -235,7 +235,7 @@ private class KotlinLikeDumper(val p: Printer, val options: KotlinLikeDumpOption
|
|||||||
}
|
}
|
||||||
p(modality, defaultModality) { name.toLowerCase() }
|
p(modality, defaultModality) { name.toLowerCase() }
|
||||||
p(isExternal, "external")
|
p(isExternal, "external")
|
||||||
p(isFakeOverride, "fake")
|
p(isFakeOverride, customModifier("fake"))
|
||||||
p(isOverride, "override")
|
p(isOverride, "override")
|
||||||
p(isLateinit, "lateinit")
|
p(isLateinit, "lateinit")
|
||||||
p(isTailrec, "tailrec")
|
p(isTailrec, "tailrec")
|
||||||
@@ -272,8 +272,8 @@ private class KotlinLikeDumper(val p: Printer, val options: KotlinLikeDumpOption
|
|||||||
p(isVararg, "vararg")
|
p(isVararg, "vararg")
|
||||||
p(isCrossinline, "crossinline")
|
p(isCrossinline, "crossinline")
|
||||||
p(isNoinline, "noinline")
|
p(isNoinline, "noinline")
|
||||||
p(isHidden, "hidden")
|
p(isHidden, customModifier("hidden"))
|
||||||
p(isAssignable, "var")
|
p(isAssignable, customModifier("var"))
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun IrTypeParametersContainer.printTypeParametersWithNoIndent(postfix: String = "") {
|
private fun IrTypeParametersContainer.printTypeParametersWithNoIndent(postfix: String = "") {
|
||||||
@@ -436,7 +436,7 @@ private class KotlinLikeDumper(val p: Printer, val options: KotlinLikeDumpOption
|
|||||||
p.printIndent()
|
p.printIndent()
|
||||||
|
|
||||||
// TODO no tests, looks like there are no irText tests for isStatic flag
|
// TODO no tests, looks like there are no irText tests for isStatic flag
|
||||||
p(declaration.isStatic, commentBlock("static"))
|
p(declaration.isStatic, customModifier("static"))
|
||||||
p.printWithNoIndent("init ")
|
p.printWithNoIndent("init ")
|
||||||
declaration.body.accept(this, declaration)
|
declaration.body.accept(this, declaration)
|
||||||
|
|
||||||
@@ -491,7 +491,7 @@ private class KotlinLikeDumper(val p: Printer, val options: KotlinLikeDumpOption
|
|||||||
declaration.printValueParametersWithNoIndent()
|
declaration.printValueParametersWithNoIndent()
|
||||||
declaration.printWhereClauseIfNeededWithNoIndent()
|
declaration.printWhereClauseIfNeededWithNoIndent()
|
||||||
p.printWithNoIndent(" ")
|
p.printWithNoIndent(" ")
|
||||||
p(declaration.isPrimary, commentBlock("primary"))
|
p(declaration.isPrimary, customModifier("primary"))
|
||||||
declaration.body?.accept(this, declaration)
|
declaration.body?.accept(this, declaration)
|
||||||
p.printlnWithNoIndent()
|
p.printlnWithNoIndent()
|
||||||
}
|
}
|
||||||
@@ -733,10 +733,12 @@ private class KotlinLikeDumper(val p: Printer, val options: KotlinLikeDumpOption
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (declaration.isStatic || declaration.isFinal) {
|
if (declaration.isStatic || declaration.isFinal) {
|
||||||
p.printWithNoIndent("/*")
|
p.printWithNoIndent(CUSTOM_MODIFIER_START)
|
||||||
p(declaration.isStatic, "static")
|
p(declaration.isStatic, "static")
|
||||||
p(declaration.isFinal, "final")
|
p(declaration.isFinal, "final")
|
||||||
p.printWithNoIndent("field*/ ")
|
p.printWithNoIndent("field")
|
||||||
|
p.printWithNoIndent(CUSTOM_MODIFIER_END)
|
||||||
|
p.printWithNoIndent(" ")
|
||||||
}
|
}
|
||||||
|
|
||||||
p.printWithNoIndent(if (declaration.isFinal) "val " else "var ")
|
p.printWithNoIndent(if (declaration.isFinal) "val " else "var ")
|
||||||
@@ -1384,8 +1386,16 @@ private class KotlinLikeDumper(val p: Printer, val options: KotlinLikeDumpOption
|
|||||||
|
|
||||||
private fun commentBlock(text: String) = "/* $text */"
|
private fun commentBlock(text: String) = "/* $text */"
|
||||||
|
|
||||||
|
// TODO it's not valid kotlin unless it's commented
|
||||||
|
// ^^^ it's applied to all usages of this function
|
||||||
|
private fun customModifier(text: String): String {
|
||||||
|
return CUSTOM_MODIFIER_START + text + CUSTOM_MODIFIER_END
|
||||||
|
}
|
||||||
|
|
||||||
private companion object {
|
private companion object {
|
||||||
private const val INAPPLICABLE = false
|
private const val INAPPLICABLE = false
|
||||||
private val INAPPLICABLE_N = null
|
private val INAPPLICABLE_N = null
|
||||||
|
private const val CUSTOM_MODIFIER_START = "/* "
|
||||||
|
private const val CUSTOM_MODIFIER_END = " */"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user