/** Handles shorthand notation for collect and expands to an explicit collect expression. */
  private Expression collectShorthandStdOp(
      String opname, Expression srcExpr, Type cType, Type elemType) throws SemanticException {
    Expression res = null;
    // (1) predefined OCL operation

    // find operation on element type
    Type[] params = new Type[fArgExprs.length];
    params[0] = elemType;
    for (int i = 1; i < fArgExprs.length; i++) params[i] = fArgExprs[i].type();
    if (!ExpStdOp.exists(opname, params)) {
      String msg =
          "Undefined operation `"
              + elemType
              + "."
              + opname
              + "' in shorthand notation for collect.";
      // maybe the user just confused . with ->, check for
      // operation on collection and give a hint.
      params[0] = cType;
      if (ExpStdOp.exists(opname, params))
        msg +=
            " However, there is an operation `"
                + cType
                + "->"
                + opname
                + "'. Maybe you wanted to use `->' instead of `.'?";
      throw new SemanticException(fOp, msg);
    }
    // transform c.op(...) into c->collect($e | $e.op(...))
    fArgExprs[0] = new ExpVariable("$e", elemType);
    try {
      Expression eOp = ExpStdOp.create(opname, fArgExprs);
      res = genImplicitCollect(srcExpr, eOp, elemType);
    } catch (ExpInvalidException ex) {
      // shouldn't fail because we already checked the
      // existence above
      throw new RuntimeException("collectShorthand failed: " + ex.getMessage());
    }
    return res;
  }