]> source.dussan.org Git - aspectj.git/commitdiff
148027: dont generate usespointcut relationship (for now...)
authoraclement <aclement>
Thu, 22 Jun 2006 08:04:54 +0000 (08:04 +0000)
committeraclement <aclement>
Thu, 22 Jun 2006 08:04:54 +0000 (08:04 +0000)
ajde/testsrc/org/aspectj/ajde/AsmRelationshipsTest.java
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmHierarchyBuilder.java
tests/bugs152/pr148027/A.aj [new file with mode: 0644]
tests/bugs152/pr148027/C.aj [new file with mode: 0644]
tests/src/org/aspectj/systemtest/ajc152/Ajc152Tests.java
tests/src/org/aspectj/systemtest/ajc152/ajc152.xml
tests/src/org/aspectj/systemtest/incremental/model/IncrementalModelTests.java
tests/src/org/aspectj/systemtest/incremental/tools/MultiProjectIncrementalTests.java

index f2fcca34bde424e621737af635b6492db62d9e3a..cb32415edad3dc555c5c32118efe7fe77a5234ef 100644 (file)
@@ -14,6 +14,7 @@ package org.aspectj.ajde;
 import java.util.Iterator;
 import java.util.List;
 
+import org.aspectj.ajdt.internal.core.builder.AsmHierarchyBuilder;
 import org.aspectj.asm.AsmManager;
 import org.aspectj.asm.IProgramElement;
 import org.aspectj.asm.IRelationship;
@@ -31,7 +32,10 @@ public class AsmRelationshipsTest extends AjdeTestCase {
                super(name);
        }
 
+       // see pr148027
        public void testUsesPointcut() {
+               if (!AsmHierarchyBuilder.shouldAddUsesPointcut) return;
+               
            IProgramElement ptUsage = AsmManager.getDefault().getHierarchy().findElementForType(null, "PointcutUsage");
            assertNotNull(ptUsage);
            IProgramElement pts = AsmManager.getDefault().getHierarchy().findElementForType(null, "Pointcuts");
index a65cfbf778119e40b05a585b97c08a754254eea2..f97f4d64790d8f45a59afcba4471984dac4d200e 100644 (file)
@@ -52,7 +52,9 @@ import org.aspectj.weaver.patterns.*;
 public class AsmHierarchyBuilder extends ASTVisitor {
 
        protected AsmElementFormatter formatter = new AsmElementFormatter();
-       public static boolean shouldAddUsesPointcut = true;
+       // pr148027 - stop generating uses pointcut/pointcut used by relationship
+       // until we do it in the same way as other relationships.
+       public static boolean shouldAddUsesPointcut = false;
        /**
         * Reset for every compilation unit.
         */
diff --git a/tests/bugs152/pr148027/A.aj b/tests/bugs152/pr148027/A.aj
new file mode 100644 (file)
index 0000000..306f14b
--- /dev/null
@@ -0,0 +1,15 @@
+package pkg;
+
+public aspect A {
+
+       before() : C.pointcutInClass() {        
+       }
+       
+       pointcut pointcutInAspect() : execution(void aMethod());
+       
+       before() : pointcutInAspect() {
+       }
+       
+       public void aMethod() {
+       }
+}
diff --git a/tests/bugs152/pr148027/C.aj b/tests/bugs152/pr148027/C.aj
new file mode 100644 (file)
index 0000000..63b4e6c
--- /dev/null
@@ -0,0 +1,10 @@
+package pkg;
+
+public class C {
+
+       pointcut pointcutInClass() : execution(void cMethod());
+       
+       public void cMethod() {
+               
+       }
+}
index 79a3dc233c1245cc085adc68212d02c4954b62e3..906695d5f638ee1f9a957839b82662815ce9764c 100644 (file)
@@ -17,6 +17,7 @@ import java.util.List;
 
 import junit.framework.Test;
 
+import org.aspectj.ajdt.internal.core.builder.AsmHierarchyBuilder;
 import org.aspectj.asm.AsmManager;
 import org.aspectj.asm.IHierarchy;
 import org.aspectj.asm.IProgramElement;
@@ -295,6 +296,29 @@ public class Ajc152Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
          }
   }
   
+  public void testPCDInClassAppearsInModel_pr148027() {
+         // only want to test that its there if we're creating the uses pointcut
+         // relationship. This should be addressed by pr148027
+         if (!AsmHierarchyBuilder.shouldAddUsesPointcut) return;
+         World.createInjarHierarchy = false;
+         try {
+                 runTest("ensure pcd declare in class appears in model");
+                 IHierarchy top = AsmManager.getDefault().getHierarchy();
+                 IProgramElement pcd = top.findElementForLabel(top.getRoot(),IProgramElement.Kind.POINTCUT,"pointcutInClass()");
+                 IRelationshipMap relMap = AsmManager.getDefault().getRelationshipMap();
+                 List relationships = relMap.get(pcd);
+                 assertNotNull("expected relationships for pointcut " + pcd.toLinkLabelString()
+                                 + " but didn't", relationships);
+                 
+                 pcd = top.findElementForLabel(top.getRoot(),IProgramElement.Kind.POINTCUT,"pointcutInAspect()");
+                 relationships = relMap.get(pcd);
+                 assertNotNull("expected relationships for pointcut " + pcd.toLinkLabelString()
+                                 + " but didn't", relationships);
+         } finally {
+                 World.createInjarHierarchy = true;
+         }
+  }
+  
 //  public void testFunkyGenericErrorWithITDs_pr126355_2() { 
 //       runTest("bizarre generic error with itds - 2");
 //       // public class Pair<F,S> affected by pertarget aspect
index da553bad92072beccdefad61862aea1e24e1a957..b4244e827366be48846e01c2999f9ed8491a3915 100644 (file)
         </stderr>
       </run>
     </ajc-test>
-       
+    
+       <ajc-test dir="bugs152/pr148027" title="ensure pcd declare in class appears in model">
+      <compile files="A.aj, C.aj" options="-emacssym"/>
+    </ajc-test>
+
        <ajc-test dir="bugs152/pr148007" title="jrockit boolean fun">
                <compile files="test/BooleanUnitTest.java, test/LoggingAspect.aj"/>
                <run class="test.BooleanUnitTest"/>
index 0324aab993ea9454f9ef2572b96cac3c0f9136ca..e6507e6e122aa1f816b63e5f924f26b0e0d74409 100644 (file)
@@ -14,6 +14,7 @@ import java.io.File;
 import junit.framework.Test;
 
 import org.aspectj.ajde.ui.StructureModelUtil;
+import org.aspectj.ajdt.internal.core.builder.AsmHierarchyBuilder;
 import org.aspectj.asm.AsmManager;
 import org.aspectj.testing.XMLBasedAjcTestCase;
 
@@ -58,17 +59,29 @@ public class IncrementalModelTests extends org.aspectj.testing.XMLBasedAjcTestCa
     // <!-- BetaA has a new piece of handler advice added -->
     nextIncrement(true);
        copyFileAndDoIncrementalBuild("changes/primary/BetaA.20.java","src/primary/BetaA.java");
-    StructureModelUtil.checkModel("code=1,advice=1,RelationshipMapSize=3");
+       if (AsmHierarchyBuilder.shouldAddUsesPointcut) {
+               StructureModelUtil.checkModel("code=1,advice=1,RelationshipMapSize=3");
+       } else {
+               StructureModelUtil.checkModel("code=1,advice=1,RelationshipMapSize=2");
+       }
 
     // <!-- secondary.GammaA added, also advises the same handler -->
     nextIncrement(true);
        copyFileAndDoIncrementalBuild("changes/secondary/GammaA.30.java","src/secondary/GammaA.java");
-    StructureModelUtil.checkModel("code=1,advice=2,RelationshipMapSize=5");
+    if (AsmHierarchyBuilder.shouldAddUsesPointcut) {
+        StructureModelUtil.checkModel("code=1,advice=2,RelationshipMapSize=5");                
+       } else {
+           StructureModelUtil.checkModel("code=1,advice=2,RelationshipMapSize=3");
+       }
 
     // <!-- primary.BetaA deleted -->
     nextIncrement(true);
     deleteFileAndDoIncrementalBuild("src/primary/BetaA.java");
-    StructureModelUtil.checkModel("code=1,advice=1,RelationshipMapSize=3");
+    if (AsmHierarchyBuilder.shouldAddUsesPointcut) {
+        StructureModelUtil.checkModel("code=1,advice=1,RelationshipMapSize=3");                
+       } else {
+           StructureModelUtil.checkModel("code=1,advice=1,RelationshipMapSize=2");
+       }
 
   }
   
@@ -79,12 +92,21 @@ public class IncrementalModelTests extends org.aspectj.testing.XMLBasedAjcTestCa
     // <!-- BetaA has a new piece of advice added -->
     nextIncrement(true);
        copyFileAndDoIncrementalBuild("changes/primary/BetaA.20.java","src/primary/BetaA.java");
-    StructureModelUtil.checkModel("code=2,advice=2,java source file=3,RelationshipMapSize=6");
+       if (AsmHierarchyBuilder.shouldAddUsesPointcut) {
+                StructureModelUtil.checkModel("code=2,advice=2,java source file=3,RelationshipMapSize=6");
+       } else {
+                StructureModelUtil.checkModel("code=2,advice=2,java source file=3,RelationshipMapSize=4");
+       }
+   
     
     // <!-- BetaA has a piece of advice removed -->
     nextIncrement(true);
        copyFileAndDoIncrementalBuild("changes/primary/BetaA.30.java","src/primary/BetaA.java");
-    StructureModelUtil.checkModel("code=1,advice=1,RelationshipMapSize=3");
+       if (AsmHierarchyBuilder.shouldAddUsesPointcut) {
+           StructureModelUtil.checkModel("code=1,advice=1,RelationshipMapSize=3");
+       } else {
+           StructureModelUtil.checkModel("code=1,advice=1,RelationshipMapSize=2");
+       }
     
     // <!-- BetaA other piece of advice removed (now empty) -->
     nextIncrement(true);
index 1f5793688480c0fc899615e4fb9533ac5fe92d0a..454dd9e692c4137be8ac1fe82c6f01fba60556db 100644 (file)
@@ -23,7 +23,6 @@ import java.util.Set;
 
 import org.aspectj.ajdt.internal.compiler.lookup.EclipseFactory;
 import org.aspectj.ajdt.internal.core.builder.AjState;
-import org.aspectj.ajdt.internal.core.builder.AsmHierarchyBuilder;
 import org.aspectj.ajdt.internal.core.builder.IncrementalStateManager;
 import org.aspectj.asm.AsmManager;
 import org.aspectj.asm.IProgramElement;
@@ -76,7 +75,7 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa
        }*/
        public void testDontLoseAdviceMarkers_pr134471() {
                try {
-                       AsmHierarchyBuilder.shouldAddUsesPointcut=false;
+                       // see pr148027 AsmHierarchyBuilder.shouldAddUsesPointcut=false;
                        configureBuildStructureModel(true);
                        initialiseProject("P4");
                        build("P4");
@@ -144,7 +143,7 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa
                        }
                        
                } finally {
-                       AsmHierarchyBuilder.shouldAddUsesPointcut=true;
+                       // see pr148027 AsmHierarchyBuilder.shouldAddUsesPointcut=true;
                        configureBuildStructureModel(false);
                }
        }
@@ -1042,7 +1041,7 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa
        // 134471 related tests perform incremental compilation and verify features of the structure model post compile
        public void testPr134471_IncrementalCompilationAndModelUpdates() {
                try {
-                       AsmHierarchyBuilder.shouldAddUsesPointcut=false;
+                       // see pr148027 AsmHierarchyBuilder.shouldAddUsesPointcut=false;
                configureBuildStructureModel(true);
                configureNonStandardCompileOptions("-showWeaveInfo -emacssym");
                
@@ -1074,7 +1073,7 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa
                line = programElement.getSourceLocation().getLine();
                assertTrue("advice should be at line 7 - but is at line "+line,line==7);
                } finally {
-               AsmHierarchyBuilder.shouldAddUsesPointcut=true;
+               // see pr148027 AsmHierarchyBuilder.shouldAddUsesPointcut=true;
                }
        }
        
@@ -1123,7 +1122,7 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa
        // same as first test with an extra stage that asks for C to be recompiled, it should still be advised...
        public void testPr134471_IncrementallyRecompilingTheAffectedClass() {
                try {
-                       AsmHierarchyBuilder.shouldAddUsesPointcut=false;
+                       // see pr148027 AsmHierarchyBuilder.shouldAddUsesPointcut=false;
                configureBuildStructureModel(true);
                configureNonStandardCompileOptions("-showWeaveInfo -emacssym");
                
@@ -1155,7 +1154,7 @@ public class MultiProjectIncrementalTests extends AbstractMultiProjectIncrementa
                line = programElement.getSourceLocation().getLine();
                assertTrue("advice should be at line 7 - but is at line "+line,line==7);                
        } finally {
-               AsmHierarchyBuilder.shouldAddUsesPointcut=true;
+               // see pr148027 AsmHierarchyBuilder.shouldAddUsesPointcut=true;
                }
 
        }