private void writeString(Writer writer, CharSequence charArray, int start, int length, @NotNull PsiFile psiFile) throws IOException {
    for (int i = start; i < start + length; i++) {
      char c = charArray.charAt(i);
      if (c == '<') {
        writeChar(writer, "&lt;");
      }
      else if (c == '>') {
        writeChar(writer, "&gt;");
      }
      else if (c == '&') {
        writeChar(writer, "&amp;");
      }
      else if (c == '\"') {
        writeChar(writer, "&quot;");
      }
      else if (c == '\t') {
        int tabSize = CodeStyle.getIndentOptions(psiFile).TAB_SIZE;
        if (tabSize <= 0) tabSize = 1;
        int nSpaces = tabSize - myColumn % tabSize;
        for (int j = 0; j < nSpaces; j++) {
          writeChar(writer, " ");
        }
      }
      else if (c == '\n' || c == '\r') {
        if (c == '\r' && i + 1 < start + length && charArray.charAt(i + 1) == '\n') {
          //noinspection AssignmentToForLoopParameter
          i++;
        }
        else if (c == '\n') {
          writeChar(writer, " ");
        }

        writeLineSeparatorAndNumber(writer, i);
      }
      else {
        writer.write(c);
        myColumn++;
      }
    }
  }
private void writeString(Writer writer, CharSequence charArray, int start, int length, @NotNull PsiFile psiFile)