Ejemplo n.º 1
0
 @Override
 public void endVisit(MethodInvocation node) {
   IMethodBinding binding = node.getMethodBinding();
   Expression receiver = node.getExpression();
   if (receiver != null && !BindingUtil.isStatic(binding)) {
     maybeAddCast(receiver, null, true);
   }
   maybeCastArguments(node.getArguments(), binding);
   if (returnValueNeedsIntCast(node)) {
     addCast(node);
   }
 }
Ejemplo n.º 2
0
 private ITypeBinding getDeclaredType(Expression expr) {
   IVariableBinding var = TreeUtil.getVariableBinding(expr);
   if (var != null) {
     return var.getVariableDeclaration().getType();
   }
   switch (expr.getKind()) {
     case CLASS_INSTANCE_CREATION:
       return typeEnv.resolveIOSType("id");
     case FUNCTION_INVOCATION:
       {
         ITypeBinding returnType =
             ((FunctionInvocation) expr).getFunctionBinding().getReturnType();
         if (returnType.isTypeVariable()) {
           return typeEnv.resolveIOSType("id");
         }
         return returnType;
       }
     case METHOD_INVOCATION:
       {
         MethodInvocation invocation = (MethodInvocation) expr;
         IMethodBinding method = invocation.getMethodBinding();
         // Object receiving the message, or null if it's a method in this class.
         Expression receiver = invocation.getExpression();
         ITypeBinding receiverType =
             receiver != null ? receiver.getTypeBinding() : method.getDeclaringClass();
         return getDeclaredReturnType(method, receiverType);
       }
     case PARENTHESIZED_EXPRESSION:
       return getDeclaredType(((ParenthesizedExpression) expr).getExpression());
     case SUPER_METHOD_INVOCATION:
       {
         SuperMethodInvocation invocation = (SuperMethodInvocation) expr;
         IMethodBinding method = invocation.getMethodBinding();
         if (invocation.getQualifier() != null) {
           // For a qualified super invocation, the statement generator will look
           // up the IMP using instanceMethodForSelector.
           if (!method.getReturnType().isPrimitive()) {
             return typeEnv.resolveIOSType("id");
           } else {
             return null;
           }
         }
         return getDeclaredReturnType(
             method, TreeUtil.getOwningType(invocation).getTypeBinding().getSuperclass());
       }
     default:
       return null;
   }
 }
Ejemplo n.º 3
0
 @Override
 public boolean visit(MethodInvocation node) {
   List<IVariableBinding> path = OuterReferenceResolver.getPath(node);
   if (path != null) {
     node.setExpression(Name.newName(fixPath(path)));
   }
   return true;
 }