]> source.dussan.org Git - aspectj.git/commitdiff
145963: patches from comment #3
authoraclement <aclement>
Tue, 20 Jun 2006 10:25:03 +0000 (10:25 +0000)
committeraclement <aclement>
Tue, 20 Jun 2006 10:25:03 +0000 (10:25 +0000)
asm/src/org/aspectj/asm/IRelationshipMap.java
tests/src/org/aspectj/systemtest/ajc152/CreatingModelForInjarTests.java
weaver/src/org/aspectj/weaver/AsmRelationshipProvider.java

index ba6ebee879079cb872e77c63375a0631ed23a04a..68f97676e5f2a34b9511160fab43bd95de9da3aa 100644 (file)
@@ -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);
 
index 5dc35afe144a8b79a1dcdf8c7e84cd5c6ddfadee..92b07152c9136ceadca52066fb8d975295346306 100644 (file)
@@ -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(),
index e68696a77cc313be9a13a9cdf5f0a1214fd8654e..04725f89400494e85fe9b9a843bb350307306eb8 100644 (file)
@@ -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);