TreeElement (@NotNull TreeElement currentLeaf, @NotNull CharSequence text) { TemplateDataElementType.TemplateAwareElementType elementType = (TemplateDataElementType.TemplateAwareElementType)currentLeaf.getElementType(); TreeElement newElement = elementType.createTreeElement(text); RangeCollectorImpl collector = currentLeaf.getUserData(OUTER_ELEMENT_RANGES); if (collector == null) collector = new RangeCollectorImpl(myTemplateDataElementType); newElement.putUserData(OUTER_ELEMENT_RANGES, collector); return newElement; }