Example usage for org.aspectj.weaver Shadow getIWorld

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

Introduction

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

Prototype

public abstract World getIWorld();

Source Link

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);/*  w  ww . j a  v a  2 s .  co  m*/
        }
        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;//from  w  w w.  j av a  2s .co  m

    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() });
    }
}