@Override
  protected int doCalculateWrapPosition(@NotNull Document document,
                                        @Nullable Project project,
                                        @NotNull PsiElement element,
                                        int startOffset,
                                        int endOffset,
                                        int maxPreferredOffset,
                                        boolean isSoftWrap) {
    if (element.getNode().getElementType() == JavaDocTokenType.DOC_COMMENT_DATA) {
      CharSequence docChars = document.getCharsSequence();
      if (isInsidePreTag(element, docChars, startOffset) || isInsidePreTag(element, docChars, endOffset)) {
        return NO_LINE_WRAP;
      }
      int refStart = CharArrayUtil.indexOf(docChars, A_LINK_START, startOffset, endOffset);
      if (refStart >= 0 && refStart < maxPreferredOffset) {
        int refEnd = CharArrayUtil.indexOf(docChars, A_LINK_END, refStart, endOffset);
        if (refEnd >= 0 && refEnd < maxPreferredOffset) return refEnd + A_LINK_END.length();
        return refStart;
      }
    }
    int wrapPos = super.doCalculateWrapPosition(document, project, element, startOffset, endOffset, maxPreferredOffset, isSoftWrap);
    if (element.getNode().getElementType() == JavaTokenType.STRING_LITERAL) {
      TextRange range = element.getTextRange();
      if (range.getEndOffset() - wrapPos <= 1) {
        wrapPos = range.getEndOffset();
      }
      else if (wrapPos - range.getStartOffset() <= 1) {
        wrapPos = range.getStartOffset();
      }
    }
    else if (element.getNode().getElementType() == JavaTokenType.END_OF_LINE_COMMENT) {
      CharSequence docChars = document.getCharsSequence();
      TextRange range = element.getTextRange();
      int urlOffset = getUrlOffset(docChars, startOffset, endOffset);
      if (urlOffset >= 0) {
        int urlEnd = urlOffset;
        while (urlEnd < range.getEndOffset()) {
          if (StringUtil.isWhiteSpace(docChars.charAt(urlEnd))) {
            break;
          }
          urlEnd ++;
        }
        if (urlEnd > wrapPos)
          return urlEnd < range.getEndOffset() ? urlEnd : NO_LINE_WRAP;
      }
    }
    return wrapPos;
  }
@Override
  protected int doCalculateWrapPosition(@NotNull Document document,
                                        @Nullable Project project,
                                        @NotNull PsiElement element,
                                        int startOffset,
                                        int endOffset,
                                        int maxPreferredOffset,
                                        boolean isSoftWrap)