Example usage for org.aspectj.weaver Shadow getSignature

List of usage examples for org.aspectj.weaver Shadow getSignature

Introduction

In this page you can find the example usage for org.aspectj.weaver Shadow getSignature.

Prototype

public Member getSignature() 

Source Link

Document

returns the signature of the thing under this shadow

Usage

From source file:org.caesarj.compiler.aspectj.CaesarKindedPointcut.java

License:Open Source License

public FuzzyBoolean match(Shadow shadow) {
    if (shadow.getKind() != kind)
        return FuzzyBoolean.NO;

    if (!signature.matches(shadow.getSignature(), shadow.getIWorld())) {
        if (kind == Shadow.MethodCall) {
            warnOnConfusingSig(shadow);/*from w  w  w .  ja v  a 2 s  . c  om*/
        }
        return FuzzyBoolean.NO;
    }

    return FuzzyBoolean.YES;
}

From source file:org.caesarj.compiler.aspectj.CaesarKindedPointcut.java

License:Open Source License

private void warnOnConfusingSig(Shadow shadow) {
    // no warnings for declare error/warning
    if (munger instanceof Checker)
        return;/*  w ww.  ja  va  2s  .com*/

    World world = shadow.getIWorld();

    // warning never needed if the declaring type is any
    TypeX exactDeclaringType = signature.getDeclaringType().getExactType();

    ResolvedTypeX shadowDeclaringType = shadow.getSignature().getDeclaringType().resolve(world);

    if (signature.getDeclaringType().isStar() || exactDeclaringType == ResolvedTypeX.MISSING)
        return;

    // warning not needed if match type couldn't ever be the declaring type
    if (!shadowDeclaringType.isAssignableFrom(exactDeclaringType)) {
        return;
    }

    // if the method in the declaring type is *not* visible to the
    // exact declaring type then warning not needed.
    int shadowModifiers = shadow.getSignature().getModifiers(world);
    if (!ResolvedTypeX.isVisible(shadowModifiers, shadowDeclaringType, exactDeclaringType.resolve(world))) {
        return;
    }

    // PR60015 - Don't report the warning if the declaring type is object and 'this' is an interface
    if (exactDeclaringType.isInterface(world)
            && shadowDeclaringType.equals(world.resolve("java.lang.Object"))) {
        return;
    }

    SignaturePattern nonConfusingPattern = new SignaturePattern(signature.getKind(), signature.getModifiers(),
            signature.getReturnType(), TypePattern.ANY, signature.getName(), signature.getParameterTypes(),
            signature.getThrowsPattern());

    if (nonConfusingPattern.matches(shadow.getSignature(), shadow.getIWorld())) {
        shadow.getIWorld().getLint().unmatchedSuperTypeInCall.signal(
                new String[] { shadow.getSignature().getDeclaringType().toString(),
                        signature.getDeclaringType().toString() },
                this.getSourceLocation(), new ISourceLocation[] { shadow.getSourceLocation() });
    }
}