Example usage for org.aspectj.asm IRelationship isAffects

List of usage examples for org.aspectj.asm IRelationship isAffects

Introduction

In this page you can find the example usage for org.aspectj.asm IRelationship isAffects.

Prototype

public boolean isAffects();

Source Link

Usage

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

License:Open Source License

public boolean isAdvised(IJavaElement elt) {
    if (!isInitialized) {
        return false;
    }//from  w  ww . ja  v  a2s. c  o m

    IProgramElement ipe = javaElementToProgramElement(elt);
    if (ipe != IHierarchy.NO_STRUCTURE) {
        List<IRelationship> rels = relationshipMap.get(ipe);
        if (rels != null && rels.size() > 0) {
            for (IRelationship rel : rels) {
                if (!rel.isAffects()) {
                    return true;
                }
            }
        }
        // check children if the children would not otherwise be in 
        // outline view (ie- code elements)
        if (ipe.getKind() != IProgramElement.Kind.CLASS && ipe.getKind() != IProgramElement.Kind.ASPECT) {
            List<IProgramElement> ipeChildren = ipe.getChildren();
            if (ipeChildren != null) {
                for (IProgramElement child : ipeChildren) {
                    if (child.getKind() == IProgramElement.Kind.CODE) {
                        rels = relationshipMap.get(child);
                        for (IRelationship rel : rels) {
                            if (!rel.isAffects()) {
                                return true;
                            }
                        }
                    }
                }
            }
        }
    }
    return false;
}

From source file:org.eclipse.ajdt.internal.ui.markers.UpdateAJMarkers.java

License:Open Source License

/**
 * check if this relationship comes from an aspect that has a custom marker
 * @see AJMarkersDialog/*from w  w w .  j av a 2s.c om*/
 */
private String getCustomMarker(IRelationship relationship) {
    // get the element in the aspect, it is source or target depending
    // on the kind of relationship
    List<IJavaElement> aspectEntities = new ArrayList<IJavaElement>();
    if (relationship.isAffects()) {
        aspectEntities.add(model.programElementToJavaElement(relationship.getSourceHandle()));
    } else {
        // all targets are from the same
        for (String target : relationship.getTargets()) {
            aspectEntities.add(model.programElementToJavaElement(target));
        }
    }

    for (IJavaElement elt : aspectEntities) {
        if (elt != null) { // will be null if the referent is not found.  Should only be in error cases
            IType typeElement = (IType) elt.getAncestor(IJavaElement.TYPE);
            if (typeElement != null) {
                String customImage = AspectJPreferences.getSavedIcon(typeElement.getJavaProject().getProject(),
                        AJMarkersDialog.getFullyQualifiedAspectName(typeElement));
                if (customImage != null) {
                    return customImage;
                }
            }
        }
    }
    return null;
}