Light Classes: Fix AIOOBE on KtParameter -> PsiParameter conversion

EA-88058 Fixed
This commit is contained in:
Alexey Sedunov
2017-06-29 18:14:09 +03:00
parent d69caea725
commit 28c5978d81
@@ -85,6 +85,7 @@ fun KtParameter.toPsiParameters(): Collection<PsiParameter> {
val paramList = getNonStrictParentOfType<KtParameterList>() ?: return emptyList()
val paramIndex = paramList.parameters.indexOf(this)
if (paramIndex < 0) return emptyList()
val owner = paramList.parent
val lightParamIndex = if (owner is KtDeclaration && owner.isExtensionDeclaration()) paramIndex + 1 else paramIndex
@@ -95,9 +96,7 @@ fun KtParameter.toPsiParameters(): Collection<PsiParameter> {
else -> null
} ?: return emptyList()
return methods.mapNotNull {
if (it.parameterList.parametersCount > lightParamIndex) it.parameterList.parameters[lightParamIndex] else null
}
return methods.mapNotNull { it.parameterList.parameters.getOrNull(lightParamIndex) }
}
private fun KtParameter.toAnnotationLightMethod(): PsiMethod? {