From e0c401c92c0c586c37a17c563e73473a367f2dde Mon Sep 17 00:00:00 2001 From: aclement Date: Sat, 23 Aug 2008 04:17:26 +0000 Subject: [PATCH] 243376: optimized implementation --- .../aspectj/asm/internal/Relationship.java | 39 ++++++++++--------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/asm/src/org/aspectj/asm/internal/Relationship.java b/asm/src/org/aspectj/asm/internal/Relationship.java index 8304a9e58..44713c31e 100644 --- a/asm/src/org/aspectj/asm/internal/Relationship.java +++ b/asm/src/org/aspectj/asm/internal/Relationship.java @@ -10,15 +10,13 @@ * Mik Kersten initial implementation * Andy Clement Extensions for better IDE representation * ******************************************************************/ - - package org.aspectj.asm.internal; +import java.util.Collection; import java.util.List; +import java.util.Set; import org.aspectj.asm.IRelationship; -//import org.aspectj.asm.IRelationship.Kind; - /** * @author Mik Kersten @@ -29,6 +27,7 @@ public class Relationship implements IRelationship { private String name; private Kind kind; + private boolean isAffects; private String sourceHandle; private List targets; private boolean hasRuntimeTest; @@ -41,6 +40,13 @@ public class Relationship implements IRelationship { boolean runtimeTest) { this.name = name; + this.isAffects = + name.equals("advises") || + name.equals("declares on") || + name.equals("softens") || + name.equals("matched by") || + name.equals("declared on") || + name.equals("annotates"); this.kind = kind; this.sourceHandle = sourceHandle; this.targets = targets; @@ -63,33 +69,28 @@ public class Relationship implements IRelationship { return sourceHandle; } + // TODO should be a Set and not a list public List getTargets() { return targets; } - public boolean addTarget(String handle) { - if (targets.contains(handle)) return false; + public void addTarget(String handle) { + if (targets.contains(handle)) return; targets.add(handle); - return true; } public boolean hasRuntimeTest() { return hasRuntimeTest; } - // For repairing the relationship map on incremental builds, we need - // to know the direction of the relationship: either 'affects' or 'affected by' - // this set are considered the 'affects' relationship. If we know which direction - // it is in, we know which ones should be removed when a particular resource - // is modified because the subsequent reweave will re-add it. + /** + * Return the direction of the relationship. It might be affects or affected-by. + * The direction enables the incremental model repair code to do the right thing. + * + * @return true if is an affects relationship: advises/declareson/softens/matchedby/declaredon/annotates + */ public boolean isAffects() { - // TODO should be a well defined set (enum type) with a flag for this... - return name.equals("advises") || - name.equals("declares on") || - name.equals("softens") || - name.equals("matched by") || - name.equals("declared on") || - name.equals("annotates"); + return isAffects; } } -- 2.39.5