aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoraclement <aclement>2006-06-20 10:25:03 +0000
committeraclement <aclement>2006-06-20 10:25:03 +0000
commitc2ae48e581cd204a64f95f4dd3891d118a71eaf6 (patch)
treef21fe5ea37f15fd6af4668cc409c6222548f3208
parent1468daa88534262ebdd209574d3be360a0c78143 (diff)
downloadaspectj-c2ae48e581cd204a64f95f4dd3891d118a71eaf6.tar.gz
aspectj-c2ae48e581cd204a64f95f4dd3891d118a71eaf6.zip
145963: patches from comment #3
-rw-r--r--asm/src/org/aspectj/asm/IRelationshipMap.java4
-rw-r--r--tests/src/org/aspectj/systemtest/ajc152/CreatingModelForInjarTests.java23
-rw-r--r--weaver/src/org/aspectj/weaver/AsmRelationshipProvider.java10
3 files changed, 30 insertions, 7 deletions
diff --git a/asm/src/org/aspectj/asm/IRelationshipMap.java b/asm/src/org/aspectj/asm/IRelationshipMap.java
index ba6ebee87..68f97676e 100644
--- a/asm/src/org/aspectj/asm/IRelationshipMap.java
+++ b/asm/src/org/aspectj/asm/IRelationshipMap.java
@@ -37,12 +37,12 @@ import java.util.Set;
public interface IRelationshipMap extends Serializable {
/**
- * @return an empty list if the element is not found.
+ * @return null if the element is not found.
*/
public List/*IRelationship*/ get(IProgramElement source);
/**
- * @return an empty list if the element is not found.
+ * @return null if the element is not found.
*/
public List/*IRelationship*/ get(String handle);
diff --git a/tests/src/org/aspectj/systemtest/ajc152/CreatingModelForInjarTests.java b/tests/src/org/aspectj/systemtest/ajc152/CreatingModelForInjarTests.java
index 5dc35afe1..92b07152c 100644
--- a/tests/src/org/aspectj/systemtest/ajc152/CreatingModelForInjarTests.java
+++ b/tests/src/org/aspectj/systemtest/ajc152/CreatingModelForInjarTests.java
@@ -19,6 +19,7 @@ import junit.framework.Test;
import org.aspectj.asm.AsmManager;
import org.aspectj.asm.IHierarchy;
import org.aspectj.asm.IProgramElement;
+import org.aspectj.asm.IRelationshipMap;
import org.aspectj.testing.XMLBasedAjcTestCase;
//import org.aspectj.weaver.World;
@@ -80,6 +81,28 @@ public class CreatingModelForInjarTests extends org.aspectj.testing.XMLBasedAjcT
assertEquals("expected one package called 'pkg' but found " + numberOfPkgs,1,numberOfPkgs);
}
+ public void testAdviceInRelMap() {
+ runTest("advice and deow");
+ IHierarchy top = AsmManager.getDefault().getHierarchy();
+ IProgramElement adviceNode = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.ADVICE,"before()");
+ IRelationshipMap relMap = AsmManager.getDefault().getRelationshipMap();
+ List adviceRels = relMap.get(adviceNode);
+ assertFalse("expected before advice to have relationships but did not",adviceRels.isEmpty());
+ }
+
+ public void testDeclareWarningInRelMap() {
+ runTest("advice and deow");
+ IHierarchy top = AsmManager.getDefault().getHierarchy();
+ IProgramElement dwNode = top.findElementForLabel(top.getRoot(),
+ IProgramElement.Kind.DECLARE_WARNING,
+ "declare warning: \"There should be n..\"");
+ IRelationshipMap relMap = AsmManager.getDefault().getRelationshipMap();
+ List dwRels = relMap.get(dwNode);
+ assertFalse("expected declare warning to have relationships but did not",dwRels.isEmpty());
+ }
+
+ // --------------------- Helper methods ---------------------
+
private IProgramElement getPkgNode() {
IHierarchy top = AsmManager.getDefault().getHierarchy();
IProgramElement pkgNode = top.findElementForLabel(top.getRoot(),
diff --git a/weaver/src/org/aspectj/weaver/AsmRelationshipProvider.java b/weaver/src/org/aspectj/weaver/AsmRelationshipProvider.java
index e68696a77..04725f894 100644
--- a/weaver/src/org/aspectj/weaver/AsmRelationshipProvider.java
+++ b/weaver/src/org/aspectj/weaver/AsmRelationshipProvider.java
@@ -52,6 +52,10 @@ public class AsmRelationshipProvider {
public void checkerMunger(IHierarchy model, Shadow shadow, Checker checker) {
if (!AsmManager.isCreatingModel()) return;
if (shadow.getSourceLocation() == null || checker.getSourceLocation() == null) return;
+
+ if (World.createInjarHierarchy) {
+ checker.createHierarchy();
+ }
// Ensure a node for the target exists
IProgramElement targetNode = getNode(AsmManager.getDefault().getHierarchy(),shadow);
@@ -59,17 +63,13 @@ public class AsmRelationshipProvider {
String targetHandle = AsmManager.getDefault().getHandleProvider()
.createHandleIdentifier(targetNode);
if (targetHandle == null) return;
-
+
IProgramElement sourceNode = AsmManager.getDefault().getHierarchy()
.findElementForSourceLine(checker.getSourceLocation());
String sourceHandle = AsmManager.getDefault().getHandleProvider()
.createHandleIdentifier(sourceNode);
if (sourceHandle == null) return;
- if (World.createInjarHierarchy) {
- checker.createHierarchy();
- }
-
IRelationshipMap mapper = AsmManager.getDefault().getRelationshipMap();
IRelationship foreward = mapper.get(sourceHandle, IRelationship.Kind.DECLARE, MATCHED_BY,false,true);
foreward.addTarget(targetHandle);