Beispiel #1
0
 @Nullable
 private static String getExprText(PsiExpression expr, PsiLocalVariable localVariable) {
   final String exprText = expr != null ? expr.getText() : null;
   if (localVariable != null) {
     final PsiExpression initializer = localVariable.getInitializer();
     return initializer != null ? initializer.getText() : exprText;
   } else {
     return exprText;
   }
 }
Beispiel #2
0
  protected void doAction() {
    final JavaRefactoringSettings settings = JavaRefactoringSettings.getInstance();
    settings.INTRODUCE_PARAMETER_REPLACE_FIELDS_WITH_GETTERS =
        myPanel.getReplaceFieldsWithGetters();
    if (myCbDeclareFinal != null && myCbDeclareFinal.isEnabled()) {
      settings.INTRODUCE_PARAMETER_CREATE_FINALS = Boolean.valueOf(myCbDeclareFinal.isSelected());
    }

    myPanel.saveSettings(settings);

    myNameSuggestionsManager.nameSelected();

    boolean isDeleteLocalVariable = false;

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

    final IntroduceParameterProcessor processor =
        new IntroduceParameterProcessor(
            myProject,
            myMethodToReplaceIn,
            myMethodToSearchFor,
            parameterInitializer,
            myExpression,
            myLocalVar,
            isDeleteLocalVariable,
            getParameterName(),
            myPanel.isReplaceAllOccurences(),
            myPanel.getReplaceFieldsWithGetters(),
            isDeclareFinal(),
            myPanel.isGenerateDelegate(),
            getSelectedType(),
            myPanel.getParametersToRemove());
    invokeRefactoring(processor);
    myParameterNameField.requestFocusInWindow();
  }