/*
 * @author max
 */
package com.intellij.lang.xml;

import com.intellij.formatting.FormattingModel;
import com.intellij.formatting.FormattingModelBuilder;
import com.intellij.lang.ASTNode;
import com.intellij.psi.PsiElement;
import com.intellij.psi.codeStyle.CodeStyleSettings;
import com.intellij.psi.formatter.FormattingDocumentModelImpl;
import com.intellij.psi.formatter.PsiBasedFormattingModel;
import com.intellij.psi.formatter.xml.XmlBlock;
import com.intellij.psi.formatter.xml.XmlPolicy;
import com.intellij.psi.impl.source.SourceTreeToPsiMap;
import com.intellij.psi.impl.source.tree.TreeElement;
import com.intellij.psi.impl.source.tree.TreeUtil;
import org.jetbrains.annotations.NotNull;

public class XmlFormattingModelBuilder implements FormattingModelBuilder {
  @NotNull
    public FormattingModel createModel(final PsiElement element, final CodeStyleSettings settings) {
    final ASTNode root = TreeUtil.getFileElement((TreeElement)SourceTreeToPsiMap.psiElementToTree(element));
    final FormattingDocumentModelImpl documentModel = FormattingDocumentModelImpl.createOn(element.getContainingFile());
    return new PsiBasedFormattingModel(element.getContainingFile(),
                                       new XmlBlock(root, null, null, new XmlPolicy(settings, documentModel), null, null),
                                       documentModel);
  }
}
@@ -273,16 +273,65 @@
 ttings;%0A
+import com.intellij.psi.formatter.FormatterUtil;%0A
 import c
@@ -436,32 +436,90 @@
 ormattingModel;%0A
+import com.intellij.psi.formatter.XmlFormatterUtilHelper;%0A
 import com.intel
@@ -878,16 +878,93 @@
 ilder %7B%0A
+  static %7B%0A    FormatterUtil.addHelper(new XmlFormatterUtilHelper());%0A  %7D%0A  %0A
   @NotNu
@@ -966,18 +966,16 @@
 NotNull%0A
-  
   public

Fix EnterActionTest