Example usage for org.aspectj.weaver ResolvedType getInterTypeMungersIncludingSupers

List of usage examples for org.aspectj.weaver ResolvedType getInterTypeMungersIncludingSupers

Introduction

In this page you can find the example usage for org.aspectj.weaver ResolvedType getInterTypeMungersIncludingSupers.

Prototype

public List<ConcreteTypeMunger> getInterTypeMungersIncludingSupers() 

Source Link

Document

This method is O(N*M) where N = number of methods and M is number of inter-type declarations in my super

Usage

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 ww. ja  v  a2s .c o m*/
    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;
}

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

License:Open Source License

public ErasedTypeSignature getMethodTypeSignatures(String typeSignature, IProgramElement elt) {
    if (world == null) {
        return null;
    }//from   w w  w .j a v  a2s  .c  o  m
    // ensure '/' instead of '.'
    typeSignature = createAJSignature(typeSignature.toCharArray());

    ResolvedType type = world.resolve(UnresolvedType.forSignature(typeSignature));
    if (type == null || type.isMissing()) {
        return null;
    }
    List itds = type.getInterTypeMungersIncludingSupers();
    ConcreteTypeMunger myMunger = null;
    for (Iterator iterator = itds.iterator(); iterator.hasNext();) {
        ConcreteTypeMunger munger = (ConcreteTypeMunger) iterator.next();
        if (equalSignatures(elt, munger)) {
            myMunger = munger;
            break;
        }
    }
    if (myMunger == null) {
        return null;
    }

    String returnTypeSig = myMunger.getSignature().getReturnType().getSignature();
    returnTypeSig = createJDTSignature(returnTypeSig);
    //        returnTypeSig = Signature.toString(returnType);
    UnresolvedType[] parameterTypes = myMunger.getSignature().getParameterTypes();
    String[] parameterTypesStr = new String[parameterTypes.length];
    for (int i = 0; i < parameterTypes.length; i++) {
        parameterTypesStr[i] = parameterTypes[i].getErasureSignature();
        parameterTypesStr[i] = createJDTSignature(parameterTypesStr[i]);
        parameterTypesStr[i] = Signature.toString(parameterTypesStr[i]);
    }
    return new ErasedTypeSignature(returnTypeSig, parameterTypesStr,
            convertTypeParameters(myMunger.getSignature().getTypeVariables()));
}