[英]Android Studio Live Templates
I have KotlinData
and want to generate val domain
with getter function. 我有KotlinData
,想用getter函数生成val domain
。 There can be a different amount of the variables. 变量的数量可以不同。 I want to create Live Template for code generation but I can't find how to manage dynamic variables count. 我想创建用于代码生成的实时模板,但是找不到如何管理动态变量计数。
What can I use in "Live Templates" for dynamic class variables? 我可以在“动态模板”中为动态类变量使用什么?
data class KotlinData(
private val val1: Int,
private val val2: Double,
private val val3: String,
....
private val valN: String
) {
val domain
get() = KotlinDataDomain(
val1 = val1,
val2 = val2,
val3 = val3,
....
valN = valN
)
}
You can create a groovy script in which you can do any logic you want with your file and after that link that groovy script with the newly created Live template: https://intellij-support.jetbrains.com/hc/en-us/community/posts/115000661530-Advanced-Live-Templates-with-Groovy-scripting 您可以创建一个groovy脚本,在其中可以对文件执行任何逻辑,然后在该groovy脚本与新创建的Live模板之间进行链接: https : //intellij-support.jetbrains.com/hc/en-us/ community / posts / 115000661530-带有Groovy脚本的高级实时模板
But yes, maybe it is better and faster to write a small plugin. 但是,是的,也许编写一个小插件会更好,更快。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.