182: KotlinElementActionsFactory: "value"-parameters in generated java-annotations is putted without explicit parameter name #KT-23644

This commit is contained in:
Nicolay Mitropolsky
2018-04-18 20:46:24 +03:00
parent de0cbf5844
commit 46ff4f2bbf
2 changed files with 54 additions and 3 deletions
@@ -436,13 +436,20 @@ class KotlinElementActionsFactory : JvmElementActionsFactory() {
override fun invoke(project: Project, editor: Editor?, file: PsiFile?) {
val target = pointer.element ?: return
val kotlinAnnotation = JavaPsiFacade.getInstance(project).findClass(
request.qualifiedName,
target.resolveScope
)?.language == KotlinLanguage.INSTANCE
val entry = target.addAnnotationEntry(
KtPsiFactory(target)
.createAnnotationEntry(
"@${request.qualifiedName}${
request.attributes.joinToString(", ", "(", ")") { p ->
"${p.name} = ${renderAttributeValue(p.value)}"
}
request.attributes.mapIndexed { i, p ->
if (!kotlinAnnotation && i == 0 && p.name == "value")
renderAttributeValue(p.value).toString()
else
"${p.name} = ${renderAttributeValue(p.value)}"
}.joinToString(", ", "(", ")")
}"
)
)