private void doRestoreState(@NotNull V psiField) {
    final PsiFile containingFile = psiField.getContainingFile();
    final RangeMarker exprMarker = getExprMarker();
    if (exprMarker != null) {
      myExpr = restoreExpression(containingFile, psiField, exprMarker, myExprText);
    }

    if (myLocalMarker != null) {
      final PsiElement refVariableElement = containingFile.findElementAt(myLocalMarker.getStartOffset());
      if (refVariableElement != null) {
        final PsiElement parent = refVariableElement.getParent();
        if (parent instanceof PsiNamedElement) {
          ((PsiNamedElement)parent).setName(myLocalName);
        }
      }

      final V localVariable = getLocalVariable();
      if (localVariable != null && localVariable.isPhysical()) {
        myLocalVariable = localVariable;
        final PsiElement nameIdentifier = localVariable.getNameIdentifier();
        if (nameIdentifier != null) {
          myLocalMarker = createMarker(nameIdentifier);
        }
      }
    }
    final List<RangeMarker> occurrenceMarkers = getOccurrenceMarkers();
    for (int i = 0; i < occurrenceMarkers.size(); i++) {
      RangeMarker marker = occurrenceMarkers.get(i);
      if (getExprMarker() != null && marker.getStartOffset() == getExprMarker().getStartOffset() && myExpr != null) {
        myOccurrences[i] = myExpr;
        continue;
      }
      final E psiExpression =
        restoreExpression(containingFile, psiField, marker, getLocalVariable() != null ? myLocalName : myExprText);
      if (psiExpression != null) {
        myOccurrences[i] = psiExpression;
      }
    }

    if (myExpr != null && myExpr.isPhysical()) {
      myExprMarker = createMarker(myExpr);
    }
    myOccurrenceMarkers = null;
    deleteTemplateField(psiField);
  }
private void doRestoreState(@NotNull V psiField)