Example usage for org.eclipse.jdt.internal.compiler.lookup TypeConstants HASHCODE

List of usage examples for org.eclipse.jdt.internal.compiler.lookup TypeConstants HASHCODE

Introduction

In this page you can find the example usage for org.eclipse.jdt.internal.compiler.lookup TypeConstants HASHCODE.

Prototype

null HASHCODE

To view the source code for org.eclipse.jdt.internal.compiler.lookup TypeConstants HASHCODE.

Click Source Link

Usage

From source file:org.eclipse.objectteams.otdt.internal.core.compiler.control.Dependencies.java

License:Open Source License

private static void checkMissingMethods(ReferenceBinding roleBinding, TypeDeclaration roleDecl) {
    if (roleBinding.isClass() && ((roleBinding.tagBits & TagBits.AnnotationInstantiation) != 0)) {
        InstantiationPolicy instantiationPolicy = RoleModel.getInstantiationPolicy(roleBinding);
        if (!instantiationPolicy.isAlways())
            return;
        ClassScope scope = roleDecl.scope;
        boolean missing = false;
        MethodBinding equals = roleBinding.getExactMethod(TypeConstants.EQUALS,
                new TypeBinding[] { scope.getJavaLangObject() }, scope.compilationUnitScope());
        if (equals == null || !equals.isValidBinding()
                || TypeBinding.notEquals(equals.declaringClass, roleBinding)) {
            missing = true;//w ww .  jav a2 s . com
        } else {
            MethodBinding hashCode = roleBinding.getExactMethod(TypeConstants.HASHCODE, Binding.NO_PARAMETERS,
                    scope.compilationUnitScope());
            if (hashCode == null || !hashCode.isValidBinding()
                    || TypeBinding.notEquals(hashCode.declaringClass, roleBinding))
                missing = true;
        }
        if (missing) {
            scope.problemReporter().missingEqualsHashCodeWithInstantation(scope.referenceContext,
                    instantiationPolicy);
        }
    }
    // copied abstract methods are not yet checked for callout inference (which is normally triggered from checkMethods()) 
    if (roleBinding.isClass() && roleDecl.methods != null) {
        for (AbstractMethodDeclaration method : roleDecl.methods) {
            if (((method.modifiers & ClassFileConstants.AccAbstract) != 0) && method.isCopied) {
                // inheriting abstract method in non-abstract role may require callout inference:
                CalloutImplementor coi = new CalloutImplementor(roleDecl.getRoleModel());
                MethodDeclaration callout = coi.generateInferredCallout(roleDecl, method.binding);
                if (callout != null)
                    roleDecl.scope.problemReporter().addingInferredCalloutForInherited(roleDecl, method.binding,
                            callout);
            }
        }
    }
}