protected void performIntroduce() {
    boolean isDeleteLocalVariable = false;

    PsiExpression parameterInitializer = myExpr;
    if (getLocalVariable() != null) {
      if (myPanel.isUseInitializer()) {
        parameterInitializer = getLocalVariable().getInitializer();
      }
      isDeleteLocalVariable = myPanel.isDeleteLocalVariable();
    }

    final TIntArrayList parametersToRemove = myPanel.getParametersToRemove();

    final IntroduceParameterProcessor processor =
        new IntroduceParameterProcessor(
            myProject,
            myMethod,
            myMethodToSearchFor,
            parameterInitializer,
            myExpr,
            (PsiLocalVariable) getLocalVariable(),
            isDeleteLocalVariable,
            getInputName(),
            myPanel.isReplaceAllOccurences(),
            myPanel.getReplaceFieldsWithGetters(),
            myMustBeFinal || myPanel.isGenerateFinal(),
            isGenerateDelegate(),
            getType(),
            parametersToRemove);
    final Runnable runnable =
        new Runnable() {
          public void run() {
            final Runnable performRefactoring =
                new Runnable() {
                  public void run() {
                    processor.setPrepareSuccessfulSwingThreadCallback(
                        new Runnable() {
                          @Override
                          public void run() {}
                        });
                    processor.run();
                    normalizeParameterIdxAccordingToRemovedParams(parametersToRemove);
                    final PsiParameter parameter = getParameter();
                    if (parameter != null) {
                      InplaceIntroduceParameterPopup.super.saveSettings(parameter);
                    }
                  }
                };
            if (ApplicationManager.getApplication().isUnitTestMode()) {
              performRefactoring.run();
            } else {
              ApplicationManager.getApplication().invokeLater(performRefactoring);
            }
          }
        };
    CommandProcessor.getInstance().executeCommand(myProject, runnable, getCommandName(), null);
  }
Esempio n. 2
0
 @Override
 public boolean isReplaceAllOccurrences() {
   return myPanel.isReplaceAllOccurences();
 }