EA-85853 - (KT-13415) AIOOBE: LightClassUtilsKt.toPsiTypeParameters
This commit is contained in:
@@ -113,14 +113,15 @@ private fun KtParameter.toAnnotationLightMethod(): PsiMethod? {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun KtTypeParameter.toPsiTypeParameters(): List<PsiTypeParameter> {
|
fun KtTypeParameter.toPsiTypeParameters(): List<PsiTypeParameter> {
|
||||||
val paramList = getNonStrictParentOfType<KtTypeParameterList>()
|
val paramList = getNonStrictParentOfType<KtTypeParameterList>() ?: return listOf()
|
||||||
if (paramList == null) return listOf()
|
|
||||||
|
|
||||||
val paramIndex = paramList.getParameters().indexOf(this)
|
val paramIndex = paramList.parameters.indexOf(this)
|
||||||
val jetDeclaration = paramList.getNonStrictParentOfType<KtDeclaration>() ?: return listOf()
|
val ktDeclaration = paramList.getNonStrictParentOfType<KtDeclaration>() ?: return listOf()
|
||||||
val lightOwners = jetDeclaration.toLightElements()
|
val lightOwners = ktDeclaration.toLightElements()
|
||||||
|
|
||||||
return lightOwners.mapNotNull { lightOwner -> (lightOwner as? PsiTypeParameterListOwner)?.typeParameters?.get(paramIndex) }
|
return lightOwners.mapNotNull { lightOwner ->
|
||||||
|
(lightOwner as? PsiTypeParameterListOwner)?.typeParameters?.getOrNull(paramIndex)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns original declaration if given PsiElement is a Kotlin light element, and element itself otherwise
|
// Returns original declaration if given PsiElement is a Kotlin light element, and element itself otherwise
|
||||||
|
|||||||
Reference in New Issue
Block a user