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

时间:2017-12-02 10:03:38

标签: kotlin intellij-plugin

如何编写IntelliJ插件来修改Kotlin类以使用<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" rel="stylesheet"/> <div class="container"> <div class="d-flex justify-content-end flex-row my-flex-container "> <div class="mr-auto p-2 my-flex-item"><img src="./images/webimage.png" alt="Mountain View"></div> <div class="p-2 my-flex-item hello"> <div>Quoriron</div> <div>Quoriron is a Quora clone, made with React/Redux and using Ruby-on-Rails as an APIQuoriron is a Quora clone, made with React/Redux and using Ruby-on-Rails as an APIQuoriron is a Quora clone, made with React/Redux and using Ruby-on-Rails as an API</div> <div>Powered by: React, Rails</div> </div> </div> </div>对其进行注释?

我尝试过以下代码:

@RunWith(MockitoJUnitRunner.class)

但它会抛出

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)

1 个答案:

答案 0 :(得分:2)

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