Integer (PsiExpression indexExpression) { PsiLiteralExpression literal = tryCast(PsiUtil.skipParenthesizedExprDown(indexExpression), PsiLiteralExpression.class); if (literal == null) return null; Integer value = tryCast(literal.getValue(), Integer.class); if (value == null || value < 0) return null; return value; }