constructorInvocation method

Parser<InvocationExpressionNode> constructorInvocation()
inherited

Constructor invocation (new Foo(...) or const Foo(...)).

Implementation

Parser<InvocationExpressionNode> constructorInvocation() =>
    seq4(
      [ref0(newToken), ref0(constToken)].toChoiceParser(),
      ref0(namedType),
      (ref1(token, '.') & ref0(identifier))
          .map((l) => l[1] as String)
          .optional(),
      ref0(argumentList),
    ).map4((_, type, ctorName, args) {
      ExpressionNode target = IdentifierNode(type.name);
      if (ctorName != null) {
        target = PropertyAccessNode(target: target, propertyName: ctorName);
      }
      return InvocationExpressionNode(
        target: target,
        typeArguments: type.typeArguments,
        arguments: args,
      );
    });