看不到将 Array 类型初始化为项目中现有类型的值的正确语法,原始类型工作正常,程序员定义的类
Target(
AnnotationTarget.FIELD,
AnnotationTarget.PROPERTY_GETTER,
AnnotationTarget.VALUE_PARAMETER,
AnnotationTarget.PROPERTY)
@Retention(AnnotationRetention.SOURCE)
注释类 ConfigurableIntArray( val key: String, val text: String, val description: String, val initialValue: IntArray )
Class BlockAnnotationTester2(@field:ConfigurableIntArray(
key = UIComponentSettings.MAXIMUM_LENGTH_KEY,
text = UIComponentSettings.MAXIMUM_LENGTH_TEXT,
description = UIComponentSettings.MAXIMUM_LENGTH_DESCRIPTION,
initialValue = [2])
val unusedIntArray: IntArray = intArrayOf(1, 2, 3, 4),
for (data in memberDataIntArray)...`
addProperty(
PropertySpec.builder(TestAnnotationProcessor.INITIAL_VALUE, IntArray::class)
.initializer("intArrayOf(${data.annotation.initialValue.asList()})")
.build()
)
object Member_BlockAnnotationTester2UnusedIntArray {
const val KEY: String =
"configurable_block_detail_ui_component_maximum_length"
const val TEXT: String = "Maximum length"
var INITIAL_VALUE: IntArray = intArrayOf([2]) <-- issue
const val DESCRIPTION: String = "Maximum length of the corresponding UI
component"
}
只能让它初始化为纯文本文字或第一个值中的静态数据