private static PsiField convertToField(final PsiMethod method) {
    final Project project = method.getProject();
    final PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(project);
    final JavaCodeStyleManager codeStyleManager = JavaCodeStyleManager.getInstance(project);

    final String fieldName = codeStyleManager.propertyNameToVariableName(method.getName(), VariableKind.STATIC_FIELD);
    final PsiType returnType = method.getReturnType();
    assert returnType != null;
    final PsiField field = elementFactory.createField(fieldName, returnType);
    final PsiStatement returnStatement = PsiTreeUtil.findChildOfType(method, PsiStatement.class);
    if (returnStatement != null) {
      field.setInitializer(((PsiReturnStatement)returnStatement).getReturnValue());
    }
    return field;
  }
private static PsiField convertToField(final PsiMethod method)