when finding usages of parameter of annotation class primary constructor, search also for light method generated from that parameter

#KT-9399 Fixed
This commit is contained in:
Dmitry Jemerov
2016-06-03 20:42:46 +02:00
parent 5161b6bfe0
commit 7e2ce2d4e0
7 changed files with 29 additions and 0 deletions
@@ -112,6 +112,13 @@ object LightClassUtil {
return getPsiMethodWrapper(function)
}
/**
* Returns the light method generated from the parameter of an annotation class.
*/
fun getLightClassMethod(parameter: KtParameter): PsiMethod? {
return getPsiMethodWrapper(parameter)
}
fun getLightClassMethods(function: KtFunction): List<PsiMethod> {
return getPsiMethodWrappers(function, true)
}
@@ -49,6 +49,7 @@ fun KtDeclaration.toLightElements(): List<PsiNamedElement> =
is KtParameter -> ArrayList<PsiNamedElement>().let { elements ->
toPsiParameters().toCollection(elements)
LightClassUtil.getLightClassPropertyMethods(this).toCollection(elements)
toAnnotationLightMethod()?.let { elements.add(it) }
elements
}
@@ -96,6 +97,14 @@ fun KtParameter.toPsiParameters(): Collection<PsiParameter> {
}
}
private fun KtParameter.toAnnotationLightMethod(): PsiMethod? {
val parent = ownerFunction as? KtPrimaryConstructor ?: return null
val containingClass = parent.getContainingClassOrObject()
if (!containingClass.isAnnotation()) return null
return LightClassUtil.getLightClassMethod(this)
}
fun KtTypeParameter.toPsiTypeParameters(): List<PsiTypeParameter> {
val paramList = getNonStrictParentOfType<KtTypeParameterList>()
if (paramList == null) return listOf()