private boolean convertLocalToField(
      PsiLocalVariable local, PsiClass aClass, Editor editor, boolean isStatic) {
    final PsiExpression[] occurences =
        CodeInsightUtil.findReferenceExpressions(RefactoringUtil.getVariableScope(local), local);
    if (editor != null) {
      RefactoringUtil.highlightAllOccurrences(myProject, occurences, editor);
    }

    final BaseExpressionToFieldHandler.Settings settings =
        showRefactoringDialog(aClass, local, occurences, isStatic);
    if (settings == null) return true;
    // LocalToFieldDialog dialog = new LocalToFieldDialog(project, aClass, local, isStatic);
    final PsiClass destinationClass = settings.getDestinationClass();
    boolean rebindNeeded = false;
    if (destinationClass != null) {
      aClass = destinationClass;
      rebindNeeded = true;
    }

    final PsiClass aaClass = aClass;
    final boolean rebindNeeded1 = rebindNeeded;
    final Runnable runnable =
        new IntroduceFieldRunnable(rebindNeeded1, local, aaClass, settings, isStatic, occurences);
    CommandProcessor.getInstance()
        .executeCommand(
            myProject,
            new Runnable() {
              public void run() {
                ApplicationManager.getApplication().runWriteAction(runnable);
              }
            },
            REFACTORING_NAME,
            null);
    return false;
  }
 public IntroduceFieldRunnable(
     boolean rebindNeeded,
     PsiLocalVariable local,
     PsiClass aClass,
     BaseExpressionToFieldHandler.Settings settings,
     boolean isStatic,
     PsiExpression[] occurrences) {
   myVariableName = local.getName();
   myFieldName = settings.getFieldName();
   myRebindNeeded = rebindNeeded;
   myLocal = local;
   myProject = local.getProject();
   myDestinationClass = aClass;
   mySettings = settings;
   myInitializerPlace = settings.getInitializerPlace();
   myOccurences = occurrences;
 }
    public void run() {
      try {
        final boolean rebindNeeded2 = !myVariableName.equals(myFieldName) || myRebindNeeded;
        final PsiReference[] refs;
        if (rebindNeeded2) {
          refs =
              ReferencesSearch.search(myLocal, GlobalSearchScope.projectScope(myProject), false)
                  .toArray(new PsiReference[0]);
        } else {
          refs = null;
        }

        final PsiMethod enclosingConstructor =
            BaseExpressionToFieldHandler.getEnclosingConstructor(myDestinationClass, myLocal);
        myField =
            mySettings.isIntroduceEnumConstant()
                ? EnumConstantsUtil.createEnumConstant(myDestinationClass, myLocal, myFieldName)
                : createField(
                    myLocal,
                    mySettings.getForcedType(),
                    myFieldName,
                    myInitializerPlace == IN_FIELD_DECLARATION);
        myField = (PsiField) myDestinationClass.add(myField);
        BaseExpressionToFieldHandler.setModifiers(myField, mySettings);
        if (!mySettings.isIntroduceEnumConstant()) {
          VisibilityUtil.fixVisibility(myOccurences, myField, mySettings.getFieldVisibility());
        }

        myLocal.normalizeDeclaration();
        PsiDeclarationStatement declarationStatement =
            (PsiDeclarationStatement) myLocal.getParent();
        final BaseExpressionToFieldHandler.InitializationPlace finalInitializerPlace;
        if (myLocal.getInitializer() == null) {
          finalInitializerPlace = IN_FIELD_DECLARATION;
        } else {
          finalInitializerPlace = myInitializerPlace;
        }
        final PsiElementFactory factory = JavaPsiFacade.getInstance(myProject).getElementFactory();

        switch (finalInitializerPlace) {
          case IN_FIELD_DECLARATION:
            declarationStatement.delete();
            break;

          case IN_CURRENT_METHOD:
            PsiStatement statement = createAssignment(myLocal, myFieldName, factory);
            myAssignmentStatement = (PsiStatement) declarationStatement.replace(statement);
            break;

          case IN_CONSTRUCTOR:
            myAssignmentStatement =
                addInitializationToConstructors(myLocal, myField, enclosingConstructor, factory);
            break;
          case IN_SETUP_METHOD:
            myAssignmentStatement = addInitializationToSetUp(myLocal, myField, factory);
        }

        if (enclosingConstructor != null && myInitializerPlace == IN_CONSTRUCTOR) {
          PsiStatement statement = createAssignment(myLocal, myFieldName, factory);
          myAssignmentStatement = (PsiStatement) declarationStatement.replace(statement);
        }

        if (rebindNeeded2) {
          for (final PsiReference reference : refs) {
            if (reference != null) {
              // expr = RefactoringUtil.outermostParenthesizedExpression(expr);
              RefactoringUtil.replaceOccurenceWithFieldRef(
                  (PsiExpression) reference, myField, myDestinationClass);
              // replaceOccurenceWithFieldRef((PsiExpression)reference, field, aaClass);
            }
          }
          // RefactoringUtil.renameVariableReferences(local, pPrefix + fieldName,
          // GlobalSearchScope.projectScope(myProject));
        }
      } catch (IncorrectOperationException e) {
        LOG.error(e);
      }
    }