private static void writeDocument(@NotNull Document document, @NotNull Writer writer, String lineSeparator) throws IOException {
    XMLOutputter xmlOutputter = createOutputter(lineSeparator);
    try {
      xmlOutputter.output(document, writer);
    }
    catch (NullPointerException e) {
      getLogger().error(e);
      printDiagnostics(document.getRootElement(), "");
    }
  }
private static void writeDocument(@NotNull Document document, @NotNull Writer writer, String lineSeparator)