private static boolean referencesLocalMember(PsiMember memberToRename,
                                               String newName,
                                               PsiElementFactory elementFactory,
                                               PsiElement context) {
    if (memberToRename instanceof PsiField) {
      return ((PsiReferenceExpression)elementFactory.createExpressionFromText(newName, context)).resolve() != null;
    }

    if (memberToRename instanceof PsiMethod) {
      final PsiMethodCallExpression callExpression = (PsiMethodCallExpression)elementFactory.createExpressionFromText(newName + "()", context);
      return callExpression.getMethodExpression().multiResolve(false).length > 0;
    }
    return false;
  }
private static boolean referencesLocalMember(PsiMember memberToRename,
                                               String newName,
                                               PsiElementFactory elementFactory,
                                               PsiElement context)