@Override
 public void endVisit(SuperConstructorInvocation node) {
   Expression outerExpression = node.getExpression();
   if (outerExpression == null) {
     return;
   }
   node.setExpression(null);
   ITypeBinding outerExpressionType = outerExpression.getTypeBinding();
   GeneratedMethodBinding binding =
       new GeneratedMethodBinding(node.getMethodBinding().getMethodDeclaration());
   node.setMethodBinding(binding);
   node.getArguments().add(0, outerExpression);
   binding.addParameter(0, outerExpressionType);
 }
  @Override
  public boolean visit(ClassInstanceCreation node) {
    ITypeBinding newType = node.getTypeBinding().getTypeDeclaration();
    ITypeBinding declaringClass = newType.getDeclaringClass();
    if (Modifier.isStatic(newType.getModifiers()) || declaringClass == null) {
      return true;
    }

    GeneratedMethodBinding binding =
        new GeneratedMethodBinding(node.getMethodBinding().getMethodDeclaration());
    node.setMethodBinding(binding);
    addOuterArg(node, binding, declaringClass);

    for (IVariableBinding capturedVar : getCapturedVariables(node)) {
      node.getArguments().add(new SimpleName(capturedVar));
      binding.addParameter(capturedVar.getType());
    }

    assert binding.isVarargs() || node.getArguments().size() == binding.getParameterTypes().length;
    return true;
  }
  private void addOuterArg(
      ClassInstanceCreation node, GeneratedMethodBinding binding, ITypeBinding declaringClass) {
    ITypeBinding type = node.getTypeBinding().getTypeDeclaration();
    if (!OuterReferenceResolver.needsOuterParam(type)) {
      return;
    }

    Expression outerExpr = node.getExpression();
    List<IVariableBinding> path = OuterReferenceResolver.getPath(node);
    Expression outerArg = null;

    if (outerExpr != null) {
      node.setExpression(null);
      outerArg = outerExpr;
    } else if (path != null) {
      outerArg = Name.newName(fixPath(path));
    } else {
      outerArg = new ThisExpression(declaringClass);
    }

    node.getArguments().add(0, outerArg);
    binding.addParameter(0, declaringClass);
  }