private @NotNull TreeElement insertOuterElementFromRange(@NotNull TreeElement currentLeaf,
                                                           int currentLeafOffset,
                                                           @NotNull TextRange outerElementRange,
                                                           @NotNull CharSequence sourceCode,
                                                           @NotNull TreePatcher templateTreePatcher,
                                                           @NotNull CharTable charTable) {
    CharSequence outerElementText = outerElementRange.subSequence(sourceCode);
    if (currentLeaf instanceof LazyParseableElement) {
      StringBuilder builder = new StringBuilder(currentLeaf.getText());
      builder.insert(outerElementRange.getStartOffset() - currentLeafOffset, outerElementText);
      TreeElement newElement = newLazyParseable(currentLeaf, builder.toString());
      currentLeaf.rawInsertAfterMe(newElement);
      currentLeaf.rawRemove();
      return newElement;
    }

    final OuterLanguageElementImpl newLeaf =
      myTemplateDataElementType.createOuterLanguageElement(charTable.intern(outerElementText), myTemplateDataElementType.myOuterElementType);
    templateTreePatcher.insert(currentLeaf.getTreeParent(), currentLeaf, newLeaf);
    return newLeaf;
  }
private @NotNull TreeElement insertOuterElementFromRange(@NotNull TreeElement currentLeaf,
                                                           int currentLeafOffset,
                                                           @NotNull TextRange outerElementRange,
                                                           @NotNull CharSequence sourceCode,
                                                           @NotNull TreePatcher templateTreePatcher,
                                                           @NotNull CharTable charTable)