Beispiel #1
0
 /** Determines if a type can access fields and methods from an outer class. */
 public static boolean hasOuterContext(ITypeBinding type) {
   if (type.getDeclaringClass() == null) {
     return false;
   }
   // Local types can't be declared static, but if the declaring method is
   // static then the local type is effectively static.
   IMethodBinding declaringMethod = type.getTypeDeclaration().getDeclaringMethod();
   if (declaringMethod != null) {
     return !BindingUtil.isStatic(declaringMethod);
   }
   return !BindingUtil.isStatic(type);
 }
Beispiel #2
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);
   }
 }
Beispiel #3
0
 private List<Statement> getFieldAdjustments(TypeDeclaration node) {
   List<Statement> adjustments = Lists.newArrayList();
   for (VariableDeclarationFragment decl : TreeUtil.getAllFields(node)) {
     IVariableBinding var = decl.getVariableBinding();
     if (BindingUtil.isStatic(var) || var.getType().isPrimitive()) {
       continue;
     }
     boolean isWeak = BindingUtil.isWeakReference(var);
     boolean isVolatile = BindingUtil.isVolatile(var);
     if (isWeak && !isVolatile) {
       adjustments.add(createReleaseStatement(var));
     } else if (!isWeak && isVolatile) {
       adjustments.add(createVolatileRetainStatement(var));
     }
   }
   return adjustments;
 }