Add KDoc to IrAttributeContainer
This commit is contained in:
+7
-1
@@ -11,7 +11,13 @@ package org.jetbrains.kotlin.ir.declarations
|
|||||||
import org.jetbrains.kotlin.ir.IrElement
|
import org.jetbrains.kotlin.ir.IrElement
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A non-leaf IR tree element.
|
* 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.
|
||||||
|
* @property attributeOwnerIdBeforeInline original element before inlining. Useful only with IR
|
||||||
|
* 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
|
* @sample org.jetbrains.kotlin.ir.generator.IrTree.attributeContainer
|
||||||
*/
|
*/
|
||||||
interface IrAttributeContainer : IrElement {
|
interface IrAttributeContainer : IrElement {
|
||||||
|
|||||||
@@ -170,6 +170,16 @@ object IrTree : AbstractTreeBuilder() {
|
|||||||
+listField("sealedSubclasses", classSymbolType, mutability = Var)
|
+listField("sealedSubclasses", classSymbolType, mutability = Var)
|
||||||
}
|
}
|
||||||
val attributeContainer: ElementConfig by element(Declaration) {
|
val attributeContainer: ElementConfig by element(Declaration) {
|
||||||
|
kDoc = """
|
||||||
|
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`.
|
||||||
|
@property attributeOwnerIdBeforeInline original element before inlining. Useful only with IR
|
||||||
|
inliner. `null` if the element wasn't inlined. Unlike [attributeOwnerId], doesn't have the
|
||||||
|
idempotence invariant and can contain a chain of declarations.
|
||||||
|
""".trimIndent()
|
||||||
|
|
||||||
+field("attributeOwnerId", attributeContainer)
|
+field("attributeOwnerId", attributeContainer)
|
||||||
+field("attributeOwnerIdBeforeInline", attributeContainer, nullable = true) // null <=> this element wasn't inlined
|
+field("attributeOwnerIdBeforeInline", attributeContainer, nullable = true) // null <=> this element wasn't inlined
|
||||||
}
|
}
|
||||||
|
|||||||
+1
@@ -40,6 +40,7 @@ class ElementConfig(
|
|||||||
|
|
||||||
var generationCallback: (TypeSpec.Builder.() -> Unit)? = null
|
var generationCallback: (TypeSpec.Builder.() -> Unit)? = null
|
||||||
var suppressPrint = false
|
var suppressPrint = false
|
||||||
|
var kDoc: String? = null
|
||||||
|
|
||||||
override val element get() = this
|
override val element get() = this
|
||||||
override val args get() = emptyMap<NamedTypeParameterRef, TypeRef>()
|
override val args get() = emptyMap<NamedTypeParameterRef, TypeRef>()
|
||||||
|
|||||||
+1
@@ -42,6 +42,7 @@ class Element(
|
|||||||
val generationCallback = config.generationCallback
|
val generationCallback = config.generationCallback
|
||||||
val suppressPrint = config.suppressPrint
|
val suppressPrint = config.suppressPrint
|
||||||
val propertyName = config.propertyName
|
val propertyName = config.propertyName
|
||||||
|
val kDoc = config.kDoc
|
||||||
|
|
||||||
override fun toString() = name
|
override fun toString() = name
|
||||||
|
|
||||||
|
|||||||
+7
-3
@@ -180,9 +180,13 @@ fun printElements(generationPath: File, model: Model) = sequence {
|
|||||||
|
|
||||||
private fun TypeSpec.Builder.generateElementKDoc(element: Element) {
|
private fun TypeSpec.Builder.generateElementKDoc(element: Element) {
|
||||||
addKdoc(buildString {
|
addKdoc(buildString {
|
||||||
append("A ")
|
if (element.kDoc != null) {
|
||||||
append(if (element.isLeaf) "leaf" else "non-leaf")
|
appendLine(element.kDoc)
|
||||||
appendLine(" IR tree element.")
|
} else {
|
||||||
|
append("A ")
|
||||||
|
append(if (element.isLeaf) "leaf" else "non-leaf")
|
||||||
|
appendLine(" IR tree element.")
|
||||||
|
}
|
||||||
|
|
||||||
append("@sample ${element.propertyName}")
|
append("@sample ${element.propertyName}")
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user