@Override
  public void visit(Tree.InvocationExpression invocation) {
    if (annotationConstructor != null) {

      final AnnotationInvocation prevInstantiation = this.instantiation;
      if (this.checkingArguments) {
        this.instantiation = new AnnotationInvocation();
      }

      this.checkingInvocationPrimary = true;
      invocation.getPrimary().visit(this);
      this.checkingInvocationPrimary = false;

      if (invocation.getPositionalArgumentList() != null) {
        invocation.getPositionalArgumentList().visit(this);
      }
      if (invocation.getNamedArgumentList() != null) {
        invocation.getNamedArgumentList().visit(this);
      }
      InvocationAnnotationTerm invocationTerm = new InvocationAnnotationTerm();
      invocationTerm.setInstantiation(instantiation);
      if (this.checkingArguments) {
        if (this.nestedInvocations == null) {
          this.nestedInvocations = new ArrayList<AnnotationInvocation>();
        }
        this.nestedInvocations.add(this.instantiation);
        this.instantiation = prevInstantiation;
      }
      this.term = invocationTerm;
    } else {
      super.visit(invocation);
    }
  }
 @Override
 public void visit(Tree.InvocationExpression that) {
   ProducedType ort = requiredType;
   ProducedReference onat = namedArgTarget;
   PositionalArgumentList pal = that.getPositionalArgumentList();
   if (pal != null) {
     int pos;
     if (node == pal) {
       // TODO: this is wrong!!
       //      we need to look at the offset and
       //      determine if we are at the start
       //      or end of the parameter list!
       pos = pal.getPositionalArguments().size();
     } else {
       pos = pal.getPositionalArguments().size();
       for (int i = 0; i < pos; i++) {
         Tree.PositionalArgument pa = pal.getPositionalArguments().get(i);
         if (node.getStartIndex() >= pa.getStartIndex()
             && node.getStopIndex() <= pa.getStopIndex()) {
           pos = i;
           break;
         }
       }
     }
     ProducedReference pr = getTarget(that);
     if (pr != null) {
       List<Parameter> params = getParameters(pr);
       if (params != null && params.size() > pos) {
         Parameter param = params.get(pos);
         requiredType = pr.getTypedParameter(param).getFullType();
         if (param.isSequenced()) {
           requiredType = that.getUnit().getIteratedType(requiredType);
         }
       }
     }
   }
   NamedArgumentList nal = that.getNamedArgumentList();
   if (nal != null) {
     namedArgTarget = getTarget(that);
     if (namedArgTarget != null) {
       List<Parameter> params = getParameters(namedArgTarget);
       if (params != null && !params.isEmpty()) {
         Parameter param = params.get(params.size() - 1);
         if (param.isSequenced()) {
           requiredType = namedArgTarget.getTypedParameter(param).getFullType();
           requiredType = that.getUnit().getIteratedType(requiredType);
         }
       }
     }
   }
   super.visit(that);
   requiredType = ort;
   namedArgTarget = onat;
 }
 private static ProducedReference getTarget(Tree.InvocationExpression that) {
   Tree.Primary p = that.getPrimary();
   if (p instanceof Tree.MemberOrTypeExpression) {
     return ((Tree.MemberOrTypeExpression) p).getTarget();
   } else {
     return null;
   }
 }