private static boolean doTrimComma(Document document, int forwardOffset, int backwardOffset) {
    CharSequence charSequence = document.getCharsSequence();
    if (backwardOffset <= 0) return true;
    if (charSequence.charAt(backwardOffset - 1) == ',') {
      int offsetAfter = skipWhitespaces(charSequence, forwardOffset);
      if (offsetAfter >= charSequence.length()) return true;
      char ch = charSequence.charAt(offsetAfter);

      if (ch == ']' || ch == '}') {
        document.deleteString(backwardOffset - 1, backwardOffset);
      }
      if (ch != '/') return true;
    }
    return false;
  }
private static boolean doTrimComma(Document document, int forwardOffset, int backwardOffset)