Example usage for org.aspectj.weaver ResolvedTypeMunger Method

List of usage examples for org.aspectj.weaver ResolvedTypeMunger Method

Introduction

In this page you can find the example usage for org.aspectj.weaver ResolvedTypeMunger Method.

Prototype

Kind Method

To view the source code for org.aspectj.weaver ResolvedTypeMunger Method.

Click Source Link

Usage

From source file:org.eclipse.ajdt.core.model.AJWorldFacade.java

License:Open Source License

public ITDInfo findITDInfoFromDeclaringType(char[] declaringTypeSignature, char[] name) {
    if (world == null || declaringTypeSignature == null) {
        return null;
    }//from  w w  w . j a v a2 s.c  om
    List<ConcreteTypeMunger> itds;
    String nameStr = new String(name);
    ResolvedType type = null;
    try {
        String sig = createAJSignature(declaringTypeSignature);
        type = world.getCoreType(UnresolvedType.forSignature(sig));
    } catch (Exception e) {
        // can't do much here
        return null;
    }
    if (type == null || type.isMissing() || type.crosscuttingMembers == null) {
        return null;
    }
    itds = type.crosscuttingMembers.getTypeMungers();

    if (itds == null) {
        return null;
    }

    for (ConcreteTypeMunger concreteTypeMunger : itds) {
        ResolvedTypeMunger munger = concreteTypeMunger.getMunger();
        if (munger == null) {
            continue;
        }
        if (munger.getKind() == ResolvedTypeMunger.Field) {
            if (munger.getSignature().getName().equals(nameStr)) {
                return ITDInfo.create(concreteTypeMunger, true);
            }
        }

        if (munger.getKind() == ResolvedTypeMunger.Method) {
            // also need to compare parameters, but parameters
            // are expensive to calculate
            if (nameStr.endsWith("." + munger.getSignature().getName())) {
                return ITDInfo.create(concreteTypeMunger, true);
            }
        }
    }
    return null;
}

From source file:org.eclipse.ajdt.core.model.AJWorldFacade.java

License:Open Source License

public ITDInfo findITDInfoFromTargetType(char[] targetTypeSignature, char[] name) {
    if (world == null || targetTypeSignature == null) {
        return null;
    }// w  w  w.  jav a  2s .  com
    List<ConcreteTypeMunger> itds;
    String nameStr = new String(name);
    if (cachedMungers != null && cachedMungers.containsKey(targetTypeSignature)) {
        itds = (List<ConcreteTypeMunger>) cachedMungers.get(targetTypeSignature);
        if (itds == null) {
            return null;
        }
    } else {
        ResolvedType type = null;
        try {
            String sig = createAJSignature(targetTypeSignature);
            type = world.getCoreType(UnresolvedType.forSignature(sig));
        } catch (Exception e) {
            // don't cache
            return null;
        }
        if (type == null || type.isMissing()) {
            cacheMunger(targetTypeSignature, null);
            return null;
        }
        itds = type.getInterTypeMungersIncludingSupers();
        cacheMunger(targetTypeSignature, itds);
    }

    for (ConcreteTypeMunger concreteTypeMunger : itds) {
        ResolvedTypeMunger munger = concreteTypeMunger.getMunger();
        if (munger == null) {
            continue;
        }
        if (munger.getKind() == ResolvedTypeMunger.Field) {
            if (munger.getSignature().getName().equals(nameStr)) {
                return ITDInfo.create(concreteTypeMunger, false);
            }
        }

        if (munger.getKind() == ResolvedTypeMunger.Method) {
            // also need to compare parameters, but parameters
            // are expensive to calculate
            if (munger.getSignature().getName().equals(nameStr)) {
                return ITDInfo.create(concreteTypeMunger, false);
            }
        }
    }
    return null;
}