@Override
  protected PsiVariable createFieldToStartTemplateOn(String[] names, PsiType psiType) {
    PsiVariable variable = introduceVariable();

    final PsiVariable restoredVar = getVariable();
    if (restoredVar != null) {
      variable = restoredVar;
    }

    if (variable == null) return null;

    if (isReplaceAllOccurrences()) {
      List<RangeMarker> occurrences = new ArrayList<>();
      ReferencesSearch.search(variable).forEach(reference -> {
        occurrences.add(createMarker(reference.getElement()));
      });
      setOccurrenceMarkers(occurrences);
      myOccurrences = new PsiExpression[occurrences.size()];
    }

    final PsiIdentifier identifier = variable.getNameIdentifier();
    if (identifier != null) {
      myEditor.getCaretModel().moveToOffset(identifier.getTextOffset());
    }
    try {
      myDeleteSelf = false;
      restoreState(variable);
    }
    finally {
      myDeleteSelf = true;
    }
    initOccurrencesMarkers();
    return variable;
  }
@Override
  protected PsiVariable createFieldToStartTemplateOn(String[] names, PsiType psiType)