private @NotNull String toString(@NotNull TemplateToken token, boolean hasChildren, @NotNull PsiElement context) {
    CodeStyleSettings.QuoteStyle quoteStyle = XmlEditUtil.quoteStyle(context.getContainingFile());
    XmlTag tag = token.getXmlTag();
    if (tag != null) {
      if (quoteStyle != CodeStyleSettings.QuoteStyle.None) {
        HtmlQuotesFormatPreprocessor.HtmlQuotesConverter.runOnElement(quoteStyle, tag);
        //hack: formatter change the document, so we have to apply changes from document back to PSI, since events are disables for the file
        Document document = token.getFile().getViewProvider().getDocument();
        token.setTemplateText(document.getText(), token.getFile());
      }

      return replaceQuotesIfNeeded(toString(token.getXmlTag(), token.getAttributes(), hasChildren, context),
                                   context.getContainingFile());
    }

    PsiFile file = token.getFile();
    if (quoteStyle != CodeStyleSettings.QuoteStyle.None) {
      HtmlQuotesFormatPreprocessor.HtmlQuotesConverter.runOnElement(quoteStyle, file);
    }
    return replaceQuotesIfNeeded(file.getText(), context.getContainingFile());
  }
private @NotNull String toString(@NotNull TemplateToken token, boolean hasChildren, @NotNull PsiElement context)