void (@NotNull PsiArrayAccessExpression expression) { PsiNewExpression arrayExpression = tryCast(PsiUtil.skipParenthesizedExprDown(expression.getArrayExpression()), PsiNewExpression.class); if (arrayExpression == null || !arrayExpression.isArrayCreation()) return; PsiArrayInitializerExpression initializer = arrayExpression.getArrayInitializer(); if (initializer == null) return; Integer value = getIndex(expression.getIndexExpression()); if (value == null) return; PsiExpression[] initializers = initializer.getInitializers(); if (value >= initializers.length) return; myHolder.registerProblem(expression, InspectionGadgetsBundle.message("inspection.only.one.element.used.array"), new InlineSingleElementAccessFix(initializers[value].getText())); }