private void addVariable(PsiReference reference,
                           PsiElement selectedElement,
                           TemplateBuilderImpl builder,
                           int offset) {
    PsiElement element = reference.getElement();
    if (element == selectedElement && checkRangeContainsOffset(offset, reference.getRangeInElement(), element)) {
      Expression expression = createTemplateExpression(selectedElement);
      builder.replaceElement(reference.getElement(), getRangeToRename(reference), PRIMARY_VARIABLE_NAME, expression,
                             shouldStopAtLookupExpression(expression));
    }
    else {
      builder.replaceElement(reference.getElement(), getRangeToRename(reference), OTHER_VARIABLE_NAME, PRIMARY_VARIABLE_NAME, false);
    }
  }
private void addVariable(PsiReference reference,
                           PsiElement selectedElement,
                           TemplateBuilderImpl builder,
                           int offset)