KotlinPoet类不存在时如何使用FunSpec.overriding?

KotlinPoet类不存在时如何使用FunSpec.overriding?,kotlin,annotation-processing,kotlinpoet,Kotlin,Annotation Processing,Kotlinpoet,我有一个包名和一个类名为Strings,但我的注释处理器中没有专门的类。我需要使用: FunSpec.overriding(getOnlyElement(methodsIn(//stuck here))) 粘贴在此处的应该是一组可执行元素s?我该怎么做 我也检查过了,但运气不太好。首先,您需要使用包和类名称获得类型元素(您需要一个处理环境实例) 然后,您只需访问类型元素中的封闭元素: val typeElement = getTypeElement(processingEnv, package

我有一个包名和一个类名为
String
s,但我的注释处理器中没有专门的类。我需要使用:

FunSpec.overriding(getOnlyElement(methodsIn(//stuck here)))
粘贴在此处的
应该是一组
可执行元素
s?我该怎么做


我也检查过了,但运气不太好。

首先,您需要使用
包和
名称获得
类型元素
(您需要一个
处理环境
实例)

然后,您只需访问
类型元素
中的
封闭元素

val typeElement = getTypeElement(processingEnv, packageName, className)

FunSpec.overriding(getOnlyElement(methodsIn(typeElement.enclosedElements)))

请注意:使用时根本不需要访问processenvironment,只需直接访问
elementUtils
即可。这就是让我困惑的事情:)thnx
val typeElement = getTypeElement(processingEnv, packageName, className)

FunSpec.overriding(getOnlyElement(methodsIn(typeElement.enclosedElements)))