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);
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;
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(),
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);
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);