Search in sources :

Example 1 with ExtractClosureFromMethodProcessor

use of org.jetbrains.plugins.groovy.refactoring.extract.closure.ExtractClosureFromMethodProcessor in project intellij-community by JetBrains.

the class GrIntroduceParameterDialog method doOKAction.

@Override
public void doOKAction() {
    saveSettings();
    super.doOKAction();
    final GrParametersOwner toReplaceIn = myInfo.getToReplaceIn();
    final GrExpression expr = GroovyIntroduceParameterUtil.findExpr(myInfo);
    final GrVariable var = GroovyIntroduceParameterUtil.findVar(myInfo);
    final StringPartInfo stringPart = findStringPart();
    if (myTypeComboBox.isClosureSelected() || expr == null && var == null && stringPart == null) {
        GrIntroduceParameterSettings settings = new ExtractClosureHelperImpl(myInfo, getEnteredName(), myDeclareFinalCheckBox.isSelected(), getParametersToRemove(), myDelegateViaOverloadingMethodCheckBox.isSelected(), getReplaceFieldsWithGetter(), myForceReturnCheckBox.isSelected(), false, myTypeComboBox.getSelectedType() == null);
        if (toReplaceIn instanceof GrMethod) {
            invokeRefactoring(new ExtractClosureFromMethodProcessor(settings));
        } else {
            invokeRefactoring(new ExtractClosureFromClosureProcessor(settings));
        }
    } else {
        GrIntroduceParameterSettings settings = new GrIntroduceExpressionSettingsImpl(myInfo, getEnteredName(), myDeclareFinalCheckBox.isSelected(), getParametersToRemove(), myDelegateViaOverloadingMethodCheckBox.isSelected(), getReplaceFieldsWithGetter(), expr, var, myTypeComboBox.getSelectedType(), var != null, true, myForceReturnCheckBox.isSelected());
        if (toReplaceIn instanceof GrMethod) {
            invokeRefactoring(new GrIntroduceParameterProcessor(settings));
        } else {
            invokeRefactoring(new GrIntroduceClosureParameterProcessor(settings));
        }
    }
}
Also used : GrVariable(org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariable) ExtractClosureFromClosureProcessor(org.jetbrains.plugins.groovy.refactoring.extract.closure.ExtractClosureFromClosureProcessor) ExtractClosureFromMethodProcessor(org.jetbrains.plugins.groovy.refactoring.extract.closure.ExtractClosureFromMethodProcessor) GrParametersOwner(org.jetbrains.plugins.groovy.lang.psi.api.statements.GrParametersOwner) ExtractClosureHelperImpl(org.jetbrains.plugins.groovy.refactoring.extract.closure.ExtractClosureHelperImpl) GrMethod(org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMethod) GrExpression(org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression) StringPartInfo(org.jetbrains.plugins.groovy.refactoring.introduce.StringPartInfo)

Aggregations

GrParametersOwner (org.jetbrains.plugins.groovy.lang.psi.api.statements.GrParametersOwner)1 GrVariable (org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariable)1 GrExpression (org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression)1 GrMethod (org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMethod)1 ExtractClosureFromClosureProcessor (org.jetbrains.plugins.groovy.refactoring.extract.closure.ExtractClosureFromClosureProcessor)1 ExtractClosureFromMethodProcessor (org.jetbrains.plugins.groovy.refactoring.extract.closure.ExtractClosureFromMethodProcessor)1 ExtractClosureHelperImpl (org.jetbrains.plugins.groovy.refactoring.extract.closure.ExtractClosureHelperImpl)1 StringPartInfo (org.jetbrains.plugins.groovy.refactoring.introduce.StringPartInfo)1