Example usage for org.aspectj.weaver Shadow getSourceLocation

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

Introduction

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

Prototype

public abstract ISourceLocation getSourceLocation();

Source Link

Usage

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  .ja  v a 2 s  . 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() });
    }
}