private static @Nullable Integer getIndex(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;
    }
private static @Nullable Integer getIndex(PsiExpression indexExpression)