private @Nullable FormattingModel createTemplateFormattingModelInternal(@NotNull PsiFile file,
                                                                          CodeStyleSettings settings,
                                                                          XmlFormattingPolicy xmlFormattingPolicy,
                                                                          List<? extends PsiElement> elements,
                                                                          Indent indent) throws FragmentedTemplateException {
    if (elements.size() == 0) return null;
    List<Block> templateBlocks = new ArrayList<>();
    for (PsiElement element : elements) {
      if (element instanceof PsiErrorElement) throw new FragmentedTemplateException((PsiErrorElement)element);
      if (!isMarkupLanguageElement(element) && !FormatterUtil.containsWhiteSpacesOnly(element.getNode())) {
        templateBlocks.add(createTemplateLanguageBlock(element.getNode(), settings, xmlFormattingPolicy, indent, null, null));
      }
    }
    if (templateBlocks.size() == 0) return null;
    Block topBlock = templateBlocks.size() == 1 ? templateBlocks.get(0) : createCompositeTemplateBlock(templateBlocks, xmlFormattingPolicy);
    return new DocumentBasedFormattingModel(topBlock, file.getProject(), settings, file.getFileType(), file);
  }
private @Nullable FormattingModel createTemplateFormattingModelInternal(@NotNull PsiFile file,
                                                                          CodeStyleSettings settings,
                                                                          XmlFormattingPolicy xmlFormattingPolicy,
                                                                          List<? extends PsiElement> elements,
                                                                          Indent indent)