private static void execute(final GrMethod method, final Collection<GrReferenceExpression> usagesToConvert) {
    GroovyPsiElementFactory factory = GroovyPsiElementFactory.getInstance(method.getProject());

    StringBuilder builder = new StringBuilder(method.getTextLength());
    String modifiers = method.getModifierList().getText();
    if (modifiers.trim().isEmpty()) {
      modifiers = GrModifier.DEF;
    }
    builder.append(modifiers).append(' ');
    builder.append(method.getName()).append("={");
    GrParameterList parameterList = method.getParameterList();
    builder.append(parameterList.getParametersRange().shiftLeft(
      parameterList.getTextRange().getStartOffset()
    ).subSequence(
      parameterList.getText()
    ));
    builder.append(" ->");
    final GrOpenBlock block = method.getBlock();
    builder.append(block.getText().substring(1));
    final GrVariableDeclaration variableDeclaration =
      GroovyPsiElementFactory.getInstance(method.getProject()).createFieldDeclarationFromText(builder.toString());
    method.replace(variableDeclaration);

    for (GrReferenceExpression element : usagesToConvert) {
      final PsiElement qualifier = element.getQualifier();
      final StringBuilder text = new StringBuilder(qualifier.getText());
      element.setQualifier(null);
      text.append('.').append(element.getText());
      element.replace(factory.createExpressionFromText(text.toString()));
    }
  }
private static void execute(final GrMethod method, final Collection<GrReferenceExpression> usagesToConvert)