Optimize KotlinUFunctionCallExpression.isAnnotationArgumentArrayExpression

This commit is contained in:
Natalia Selezneva
2019-01-17 15:03:03 +03:00
parent 6ca22fbf34
commit 869fb46c0b
2 changed files with 12 additions and 6 deletions
@@ -204,13 +204,16 @@ class KotlinUFunctionCallExpression(
}
private fun isAnnotationArgumentArrayInitializer(): Boolean {
val resolvedCall = resolvedCall ?: return false
// KtAnnotationEntry (or KtCallExpression when annotation is nested) -> KtValueArgumentList -> KtValueArgument -> arrayOf call
return when (val elementAt2 = psi.parents.elementAtOrNull(2)) {
val isAnnotationArgument = when (val elementAt2 = psi.parents.elementAtOrNull(2)) {
is KtAnnotationEntry -> true
is KtCallExpression -> elementAt2.getParentOfType<KtAnnotationEntry>(true, KtDeclaration::class.java) != null
else -> false
} && CompileTimeConstantUtils.isArrayFunctionCall(resolvedCall)
}
if (!isAnnotationArgument) return false
val resolvedCall = resolvedCall ?: return false
return CompileTimeConstantUtils.isArrayFunctionCall(resolvedCall)
}
override fun convertParent(): UElement? = super.convertParent().let { result ->
@@ -148,13 +148,16 @@ class KotlinUFunctionCallExpression(
}
private fun isAnnotationArgumentArrayInitializer(): Boolean {
val resolvedCall = resolvedCall ?: return false
// KtAnnotationEntry (or KtCallExpression when annotation is nested) -> KtValueArgumentList -> KtValueArgument -> arrayOf call
return when (val elementAt2 = psi.parents.elementAtOrNull(2)) {
val isAnnotationArgument = when (val elementAt2 = psi.parents.elementAtOrNull(2)) {
is KtAnnotationEntry -> true
is KtCallExpression -> elementAt2.getParentOfType<KtAnnotationEntry>(true, KtDeclaration::class.java) != null
else -> false
} && CompileTimeConstantUtils.isArrayFunctionCall(resolvedCall)
}
if (!isAnnotationArgument) return false
val resolvedCall = resolvedCall ?: return false
return CompileTimeConstantUtils.isArrayFunctionCall(resolvedCall)
}
override fun convertParent(): UElement? = super.convertParent().let { result ->