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;
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");
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.
*/
--- /dev/null
+package pkg;
+
+public aspect A {
+
+ before() : C.pointcutInClass() {
+ }
+
+ pointcut pointcutInAspect() : execution(void aMethod());
+
+ before() : pointcutInAspect() {
+ }
+
+ public void aMethod() {
+ }
+}
--- /dev/null
+package pkg;
+
+public class C {
+
+ pointcut pointcutInClass() : execution(void cMethod());
+
+ public void cMethod() {
+
+ }
+}
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;
}
}
+ 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
</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"/>
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;
// <!-- 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");
+ }
}
// <!-- 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);
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;
}*/
public void testDontLoseAdviceMarkers_pr134471() {
try {
- AsmHierarchyBuilder.shouldAddUsesPointcut=false;
+ // see pr148027 AsmHierarchyBuilder.shouldAddUsesPointcut=false;
configureBuildStructureModel(true);
initialiseProject("P4");
build("P4");
}
} finally {
- AsmHierarchyBuilder.shouldAddUsesPointcut=true;
+ // see pr148027 AsmHierarchyBuilder.shouldAddUsesPointcut=true;
configureBuildStructureModel(false);
}
}
// 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");
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;
}
}
// 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");
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;
}
}