TypeConversionDescriptor (final PsiMethod method, final PsiElement context, PsiType collectionType, PsiArrayType arrayType) { @NonNls final String methodName = method.getName(); return switch (methodName) { case "toArray" -> { if (method.getParameterList().isEmpty()) { yield new TypeConversionDescriptor("$qualifier$.toArray()", "$qualifier$"); } yield new TypeConversionDescriptor("$qualifier$.toArray($expr$)", "$qualifier$"); } case "size" -> new TypeConversionDescriptor("$qualifier$.size()", "$qualifier$.length"); case "get" -> { if (TypeConversionUtil.isAssignable(collectionType, arrayType.getComponentType())) { yield new TypeConversionDescriptor("$qualifier$.get($i$)", "$qualifier$[$i$]", PsiTreeUtil.getParentOfType(context, PsiMethodCallExpression.class)); } yield null; } case "set" -> { if (TypeConversionUtil.isAssignable(arrayType.getComponentType(), collectionType)) { yield new TypeConversionDescriptor("$qualifier$.set($i$, $val$)", "$qualifier$[$i$] = $val$"); } yield null; } default -> null; }; }