public static boolean isExtractable(PsiExpression expression) {
    if (expression instanceof PsiMethodReferenceExpression) {
      return true;
    }
    else if (!(expression instanceof PsiAssignmentExpression)) {
      if (!(expression instanceof PsiReferenceExpression)) {
        return true;
      }
      else {
        if (!(expression.getParent() instanceof PsiMethodCallExpression)) {
          final PsiElement resolve = ((PsiReferenceExpression)expression).resolve();
          if (!(resolve instanceof PsiClass) && !(resolve instanceof PsiPackage)) {
            return true;
          }
        }
      }
    }
    return false;
  }
public static boolean isExtractable(PsiExpression expression)