/** 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); }
@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); } }
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; }