@Override
 protected void moveOffsetAfter(boolean success) {
   if (getLocalVariable() != null && getLocalVariable().isValid()) {
     myEditor.getCaretModel().moveToOffset(getLocalVariable().getTextOffset());
     myEditor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE);
   } else if (getExprMarker() != null) {
     final RangeMarker exprMarker = getExprMarker();
     if (exprMarker.isValid()) {
       myEditor.getCaretModel().moveToOffset(exprMarker.getStartOffset());
       myEditor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE);
     }
   }
   super.moveOffsetAfter(success);
   if (myLocalMarker != null && !isRestart()) {
     myLocalMarker.dispose();
   }
   if (success) {
     performPostIntroduceTasks();
     final String refactoringId = getRefactoringId();
     if (refactoringId != null) {
       final RefactoringEventData afterData = new RefactoringEventData();
       afterData.addElement(getVariable());
       myProject
           .getMessageBus()
           .syncPublisher(RefactoringEventListener.REFACTORING_EVENT_TOPIC)
           .refactoringDone(refactoringId, afterData);
     }
   }
 }
  protected boolean ensureValid() {
    final String newName = getInputName();
    if (getLocalVariable() == null && myExpr == null
        || newName == null
        || getLocalVariable() != null && !getLocalVariable().isValid()
        || myExpr != null && !myExpr.isValid()) {
      super.moveOffsetAfter(false);
      return false;
    }
    if (getLocalVariable() != null) {
      new WriteCommandAction(myProject, getCommandName(), getCommandName()) {
        @Override
        protected void run(@NotNull Result result) throws Throwable {
          getLocalVariable().setName(myLocalName);
        }
      }.execute();
    }

    if (!isIdentifier(
        newName, myExpr != null ? myExpr.getLanguage() : getLocalVariable().getLanguage()))
      return false;
    return true;
  }