String (PsiMethodCallExpression toArrayCandidate) { // collection.toArray() or collection.toArray(new Type[0]) or collection.toArray(new Type[collection.size()]); PsiExpression[] args = toArrayCandidate.getArgumentList().getExpressions(); if (args.length == 0) return ""; if (args.length != 1 || !(args[0] instanceof PsiNewExpression newArray)) return null; PsiType arrayType = newArray.getType(); if (arrayType == null) return null; String name = arrayType.getCanonicalText(); PsiExpression[] dimensions = newArray.getArrayDimensions(); if (dimensions.length != 1) return null; PsiExpression qualifier = toArrayCandidate.getMethodExpression().getQualifierExpression(); if (ExpressionUtils.isZero(dimensions[0]) || (qualifier != null && CollectionUtils.isCollectionOrMapSize(dimensions[0], qualifier))) { return name + "::new"; } return null; }