private static void changeSignature(GrClosableBlock block, GrIntroduceParameterSettings settings) {
    final String name = settings.getName();
    final FieldConflictsResolver fieldConflictsResolver = new FieldConflictsResolver(name, block);

    final GrParameter[] parameters = block.getParameters();
    for (int i = settings.parametersToRemove().size() - 1; i >= 0; i--) {
      try {
        PsiParameter param = parameters[settings.parametersToRemove().getInt(i)];
        param.delete();
      }
      catch (IncorrectOperationException e) {
        LOG.error(e);
      }
    }

    final PsiType type = settings.getSelectedType();
    final String typeText = type == null ? null : type.getCanonicalText();
    final GroovyPsiElementFactory factory = GroovyPsiElementFactory.getInstance(settings.getProject());
    GrParameter parameter = factory.createParameter(name, typeText, block);
    parameter.getModifierList().setModifierProperty(PsiModifier.FINAL, settings.declareFinal());

    final GrParameterList parameterList = block.getParameterList();
    final PsiParameter anchorParameter = GroovyIntroduceParameterUtil.getAnchorParameter(parameterList, block.isVarArgs());
    parameter = (GrParameter)parameterList.addAfter(parameter, anchorParameter);

    if (block.getArrow() == null) {
      final PsiElement arrow = block.addAfter(factory.createClosureFromText("{->}").getArrow().copy(), parameterList);
      final PsiElement child = block.getFirstChild().getNextSibling();
      if (PsiImplUtil.isWhiteSpaceOrNls(child)) {
        final String text = child.getText();
        child.delete();
        block.addAfter(factory.createLineTerminator(text), arrow);
      }
    }
    JavaCodeStyleManager.getInstance(parameter.getProject()).shortenClassReferences(parameter);

    fieldConflictsResolver.fix();
  }
private static void changeSignature(GrClosableBlock block, GrIntroduceParameterSettings settings)