void (@NotNull PsiMethodCallExpression expression) { super.visitMethodCallExpression(expression); PsiExpressionList argumentList = expression.getArgumentList(); if (argumentList.isEmpty()) return; final PsiExpression[] args = argumentList.getExpressions(); PsiExpression varargsExpression = PsiUtil.skipParenthesizedExprDown(ArrayUtil.getLastElement(args)); final PsiConditionalExpression conditional = ObjectUtils.tryCast(varargsExpression, PsiConditionalExpression.class); if (conditional == null) return; final PsiMethod method = expression.resolveMethod(); if (method == null || !method.isVarArgs()) return; final PsiParameter[] params = method.getParameterList().getParameters(); if (args.length != params.length) return; final PsiExpression thenExpression = conditional.getThenExpression(); final PsiExpression elseExpression = conditional.getElseExpression(); if (thenExpression == null || elseExpression == null) return; final PsiType thenType = thenExpression.getType(); final PsiType elseType = elseExpression.getType(); boolean isThenArray = thenType instanceof PsiArrayType; if (isThenArray == elseType instanceof PsiArrayType) return; final PsiExpression nonArray = isThenArray ? elseExpression : thenExpression; final PsiExpression array = isThenArray ? thenExpression : elseExpression; PsiClassType varargsType = ObjectUtils.tryCast(varargsExpression.getType(), PsiClassType.class); if (varargsType == null) return; String typeName = varargsType.getName(); final String replacementText = String.format("new %s[]{%s}", typeName, nonArray.getText()); final LocalQuickFix[] fix = PsiAdapter.isPrimitiveArrayType(array.getType()) ? LocalQuickFix.EMPTY_ARRAY : new LocalQuickFix[]{new WrapInArrayInitializerFix(replacementText, typeName)}; holder.registerProblem(nonArray, JavaBundle.message("inspection.suspicious.ternary.in.varargs.description"), ProblemHighlightType.WARNING, fix); }