1 2 25 26 package org.aspectj.asm.associations; 27 28 import java.util.*; 29 import org.aspectj.compiler.base.*; 30 import org.aspectj.compiler.base.ast.*; 31 import org.aspectj.compiler.base.cst.*; 32 import org.aspectj.compiler.crosscuts.*; 33 import org.aspectj.compiler.crosscuts.ast.*; 34 import org.aspectj.asm.*; 35 import org.aspectj.asm.internal.*; 36 37 40 public class Introduction implements Association { 41 public static final String NAME = "Introduction"; 42 public static final Relation INTRODUCES_RELATION = new Relation("declares member on", "inter-type declared members", NAME, true, false); 43 private List relations = new ArrayList(); 44 45 public Introduction() { 46 relations.add(INTRODUCES_RELATION); 47 } 48 49 public List getRelations() { 50 return relations; 51 } 52 53 public List getRelationNodes(ASTObject astObject) { 54 List relations = new ArrayList(); 55 List introduces = new ArrayList(); 56 Set forwardCorrs = StructureModelManager.correspondences.getAffects(astObject); 57 Set backCorrs = StructureModelManager.correspondences.getAffectedBy(astObject); 58 if (astObject instanceof IntroducedDec) { 59 for (Iterator it = forwardCorrs.iterator(); it.hasNext(); ) { 60 ASTObject node = (ASTObject)it.next(); 61 LinkNode link = StructureNodeFactory.makeLink(node, false); 62 if (node instanceof TypeDec) { 63 introduces.add(link); 64 } 65 } 66 if (!introduces.isEmpty()) relations.add(new RelationNode(INTRODUCES_RELATION, INTRODUCES_RELATION.getForwardNavigationName(), introduces)); 67 } else { 68 for (Iterator it = backCorrs.iterator(); it.hasNext(); ) { 69 ASTObject node = (ASTObject)it.next(); 70 if (astObject instanceof TypeDec) { 71 if (node instanceof IntroducedDec) { 72 introduces.add(StructureNodeFactory.makeLink(node, false)); 73 } 74 } 75 } 76 if (!introduces.isEmpty()) relations.add(new RelationNode(INTRODUCES_RELATION, INTRODUCES_RELATION.getBackNavigationName(), introduces)); 77 } 78 return relations; 79 } 80 81 public String getName() { 82 return NAME; 83 } 84 } 85 | Popular Tags |