private int writeReferenceTag(Writer writer, PsiReference ref) throws IOException {
    PsiFile refFile = Objects.requireNonNull(ref.resolve()).getContainingFile();
    PsiDirectoryFactory psiDirectoryFactory = PsiDirectoryFactory.getInstance(myProject);
    String refPackageName = psiDirectoryFactory.getQualifiedName(refFile.getContainingDirectory(), false);
    String psiPackageName = psiDirectoryFactory.getQualifiedName(myPsiFile.getContainingDirectory(), false);

    StringBuilder fileName = new StringBuilder();
    if (!psiPackageName.equals(refPackageName)) {
      StringTokenizer tokens = new StringTokenizer(psiPackageName, ".");
      while(tokens.hasMoreTokens()) {
        tokens.nextToken();
        fileName.append("../");
      }

      StringTokenizer refTokens = new StringTokenizer(refPackageName, ".");
      while(refTokens.hasMoreTokens()) {
        String token = refTokens.nextToken();
        fileName.append(token);
        fileName.append('/');
      }
    }
    fileName.append(ExportToHTMLManager.getHTMLFileName(refFile));
    writer.write("<a href=\""+fileName+"\">");
    return ref.getElement().getTextRange().getEndOffset();
  }
private int writeReferenceTag(Writer writer, PsiReference ref)