From 713f73e41402eb7dd4e3a28c361a0015008d44ac Mon Sep 17 00:00:00 2001 From: Nicolay Mitropolsky Date: Wed, 20 Mar 2019 20:39:43 +0300 Subject: [PATCH] Uast: `getMaybeLightElement` returns class for annotation primary constructor --- .../uast/kotlin/internal/kotlinInternalUastUtils.kt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/internal/kotlinInternalUastUtils.kt b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/internal/kotlinInternalUastUtils.kt index b6a19d63bd9..2918e2bfaa4 100644 --- a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/internal/kotlinInternalUastUtils.kt +++ b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/internal/kotlinInternalUastUtils.kt @@ -268,6 +268,11 @@ internal fun PsiElement.getMaybeLightElement(): PsiElement? { val lightElement = toLightElements().firstOrNull() if (lightElement != null) return lightElement + if (this is KtPrimaryConstructor) { + // annotations don't have constructors (but in Kotlin they do), so resolving to the class here + (this.parent as? KtClassOrObject)?.takeIf { it.isAnnotation() }?.toLightClass()?.let { return it } + } + when (val uElement = this.toUElement()) { is UDeclaration -> uElement.javaPsi is UDeclarationsExpression -> uElement.declarations.firstOrNull()?.javaPsi