如何通过自定义 Intellij Idea 插件修改 class 源以注释 Kotlin class

How to modify class source to annotate Kotlin class by custom Intellij Idea plugin

如何编写修改 Kotlin class 以使用 @RunWith(MockitoJUnitRunner.class) 注释的 IntelliJ 插件?

我试过以下代码:

KtPsiFactory(ktFile.project).createAnnotationEntry("@RunWith(MockitoJUnitRunner.class)")

但它抛出

0 declarations in @RunWith(MockitoJUnitRunner.class) val x java.lang.AssertionError: 0 declarations in @RunWith(MockitoJUnitRunner.class) val x at org.jetbrains.kotlin.psi.KtPsiFactory.createDeclaration(KtPsiFactory.kt:288)

但是它适用于 @Ignore

啊..应该是@RunWith(MockitoJUnitRunner::class)