@Override
 protected void performInplaceIntroduce(IntroduceOperation operation) {
   final PsiElement statement = performRefactoring(operation);
   // put caret on identifier after "self."
   if (statement instanceof PyAssignmentStatement) {
     final List<PsiElement> occurrences = operation.getOccurrences();
     final PsiElement occurrence = findOccurrenceUnderCaret(occurrences, operation.getEditor());
     PyTargetExpression target =
         (PyTargetExpression) ((PyAssignmentStatement) statement).getTargets()[0];
     putCaretOnFieldName(operation.getEditor(), occurrence != null ? occurrence : target);
     final InplaceVariableIntroducer<PsiElement> introducer =
         new PyInplaceFieldIntroducer(target, operation, occurrences);
     introducer.performInplaceRefactoring(new LinkedHashSet<>(operation.getSuggestedNames()));
   }
 }
 public PyInplaceFieldIntroducer(
     PyTargetExpression target, IntroduceOperation operation, List<PsiElement> occurrences) {
   super(
       target,
       operation.getEditor(),
       operation.getProject(),
       "Introduce Field",
       occurrences.toArray(new PsiElement[occurrences.size()]),
       null);
   myTarget = target;
   myOperation = operation;
   if (operation.getAvailableInitPlaces().size() > 1) {
     myPanel = new PyIntroduceFieldPanel(myProject, operation.getAvailableInitPlaces());
   } else {
     myPanel = null;
   }
 }
 @Override
 protected boolean checkEnabled(IntroduceOperation operation) {
   if (PyUtil.getContainingClassOrSelf(operation.getElement()) == null) {
     CommonRefactoringUtil.showErrorHint(
         operation.getProject(),
         operation.getEditor(),
         "Cannot introduce field: not in class",
         myDialogTitle,
         getHelpId());
     return false;
   }
   if (dependsOnLocalScopeValues(operation.getElement())) {
     operation.removeAvailableInitPlace(InitPlace.CONSTRUCTOR);
     operation.removeAvailableInitPlace(InitPlace.SET_UP);
   }
   return true;
 }