@NotNull
  protected String generateStringToInsert(@NotNull final Editor editor, int caretOffset, int maxRBraceCount) {
    assert maxRBraceCount > 0;

    CharSequence text = editor.getDocument().getCharsSequence();
    int bracesToInsert = 0;
    for (int i = caretOffset - 1; i >= 0 && bracesToInsert < maxRBraceCount; --i) {
      final char c = text.charAt(i);
      if (c == '{') {
        ++bracesToInsert;
      }
      else if (isStopChar(c)) {
        break;
      }
    }
    return StringUtil.repeatSymbol('}', Math.max(bracesToInsert, 1));
  }
@NotNull
  protected String generateStringToInsert(@NotNull final Editor editor, int caretOffset, int maxRBraceCount)