[IR] Unescape identifiers in tree generator more accurately
Simply removing all backticks makes kdocs with code blocks ugly
This commit is contained in:
committed by
Space Team
parent
c3cfe7ddf7
commit
b3e5612f79
+2
-2
@@ -14,9 +14,9 @@ import org.jetbrains.kotlin.ir.IrElement
|
||||
* Represents an IR element that can be copied, but must remember its original element. It is
|
||||
* useful, for example, to keep track of generated names for anonymous declarations.
|
||||
* @property attributeOwnerId original element before copying. Always satisfies the following
|
||||
* invariant: this.attributeOwnerId == this.attributeOwnerId.attributeOwnerId.
|
||||
* invariant: `this.attributeOwnerId == this.attributeOwnerId.attributeOwnerId`.
|
||||
* @property originalBeforeInline original element before inlining. Useful only with IR
|
||||
* inliner. null if the element wasn't inlined. Unlike [attributeOwnerId], doesn't have the
|
||||
* inliner. `null` if the element wasn't inlined. Unlike [attributeOwnerId], doesn't have the
|
||||
* idempotence invariant and can contain a chain of declarations.
|
||||
* @sample org.jetbrains.kotlin.ir.generator.IrTree.attributeContainer
|
||||
*/
|
||||
|
||||
+9
-1
@@ -23,7 +23,7 @@ fun printTypeCommon(generationPath: File, packageName: String, type: TypeSpec):
|
||||
.addType(type)
|
||||
.build()
|
||||
.toString()
|
||||
.replace("`", "")
|
||||
.unbacktickIdentifiers("data", "value", "operator", "constructor", "delegate", "receiver", "field")
|
||||
.replace("public ", "")
|
||||
.replace(":\\s*Unit".toRegex(), "")
|
||||
.replace("import kotlin\\..*\\n".toRegex(), "")
|
||||
@@ -35,6 +35,14 @@ fun printTypeCommon(generationPath: File, packageName: String, type: TypeSpec):
|
||||
return GeneratedFile(getPathForFile(generationPath, packageName, type.name!!), text)
|
||||
}
|
||||
|
||||
private fun String.unbacktickIdentifiers(vararg identifiers: String): String {
|
||||
var result = this
|
||||
for (identifier in identifiers) {
|
||||
result = result.replace("`$identifier`", identifier)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
fun getPathForFile(generationPath: File, packageName: String, typeName: String): File {
|
||||
val dir = generationPath.resolve(packageName.replace(".", "/"))
|
||||
return File(dir, "$typeName.kt")
|
||||
|
||||
Reference in New Issue
Block a user