aboutsummaryrefslogtreecommitdiffstats
path: root/ajde
diff options
context:
space:
mode:
authormkersten <mkersten>2003-08-14 17:18:34 +0000
committermkersten <mkersten>2003-08-14 17:18:34 +0000
commit56d4d719ba6e1ff20efe3f1003aa8eec8d5b88a2 (patch)
tree98aed82a88fcdef2d0aaf660ce44f9ec8bb8896d /ajde
parentb5d8b449c79cbedc82e03381cc459ae8c8ae9718 (diff)
downloadaspectj-56d4d719ba6e1ff20efe3f1003aa8eec8d5b88a2.tar.gz
aspectj-56d4d719ba6e1ff20efe3f1003aa8eec8d5b88a2.zip
Improved declare relationships. Implemented batch-build relationship clearing policy.
Diffstat (limited to 'ajde')
-rw-r--r--ajde/src/org/aspectj/ajde/Ajde.java3
-rw-r--r--ajde/testdata/examples/coverage/ModelCoverage.java2
-rw-r--r--ajde/testsrc/org/aspectj/ajde/AsmRelationshipsTest.java58
3 files changed, 50 insertions, 13 deletions
diff --git a/ajde/src/org/aspectj/ajde/Ajde.java b/ajde/src/org/aspectj/ajde/Ajde.java
index 032ad6e59..687f8bbbd 100644
--- a/ajde/src/org/aspectj/ajde/Ajde.java
+++ b/ajde/src/org/aspectj/ajde/Ajde.java
@@ -294,6 +294,9 @@ public class Ajde {
* Writes the default configuration file if it has been selected for compilation
*/
public void compileStarted(String buildConfig) {
+ // TODO: implement incremental policy
+ AsmManager.getDefault().getRelationshipMap().clear();
+
String configFilePath = projectProperties.getDefaultBuildConfigFile();
if (buildConfig.equals(configFilePath)) {
configurationManager.writePaths(configFilePath, projectProperties.getProjectSourceFiles());
diff --git a/ajde/testdata/examples/coverage/ModelCoverage.java b/ajde/testdata/examples/coverage/ModelCoverage.java
index 075bddc3b..bb977e36c 100644
--- a/ajde/testdata/examples/coverage/ModelCoverage.java
+++ b/ajde/testdata/examples/coverage/ModelCoverage.java
@@ -55,7 +55,7 @@ aspect AdvisesRelationshipCoverage {
pointcut getP(): get(int *.*);
before(): getP() { }
- pointcut setP(): set(int *.*);
+ pointcut setP(): set(int *.*) && !set(int *.xxx);
before(): setP() { }
pointcut initializationP(): initialization(Point.new(..));
diff --git a/ajde/testsrc/org/aspectj/ajde/AsmRelationshipsTest.java b/ajde/testsrc/org/aspectj/ajde/AsmRelationshipsTest.java
index db82a96cf..85df30d08 100644
--- a/ajde/testsrc/org/aspectj/ajde/AsmRelationshipsTest.java
+++ b/ajde/testsrc/org/aspectj/ajde/AsmRelationshipsTest.java
@@ -11,10 +11,9 @@
package org.aspectj.ajde;
-import java.util.List;
+import java.util.Iterator;
import org.aspectj.asm.*;
-import org.aspectj.asm.internal.ProgramElement;
// TODO: check for return types
public class AsmRelationshipsTest extends AjdeTestCase {
@@ -27,29 +26,40 @@ public class AsmRelationshipsTest extends AjdeTestCase {
}
public void testInterTypeDeclarations() {
-// checkMapping("InterTypeDecCoverage", "Point", "Point.xxx", "xxx", "declared on", "aspect declarations");
-// checkMapping("InterTypeDecCoverage", "Point", "Point.check(int, Line)", "Point", "declared on", "aspect declarations");
-
+ checkInterTypeMapping("InterTypeDecCoverage", "Point", "Point.xxx", "Point",
+ "declared on", "aspect declarations", IProgramElement.Kind.INTER_TYPE_FIELD);
+ checkInterTypeMapping("InterTypeDecCoverage", "Point", "Point.check(int, Line)",
+ "Point", "declared on", "aspect declarations", IProgramElement.Kind.INTER_TYPE_METHOD);
}
public void testAdvice() {
- checkMapping("AdvisesRelationshipCoverage", "Point", "before(): methodExecutionP..", "setX(int)", "advises", "advised by");
- checkUniDirectionalMapping("AdvisesRelationshipCoverage", "Point", "before(): getP..", "field-get(int Point.x)", "advises");
- checkUniDirectionalMapping("AdvisesRelationshipCoverage", "Point", "before(): setP..", "field-set(int Point.xxx)", "advises");
+ checkMapping("AdvisesRelationshipCoverage", "Point", "before(): methodExecutionP..",
+ "setX(int)", "advises", "advised by");
+ checkUniDirectionalMapping("AdvisesRelationshipCoverage", "Point", "before(): getP..",
+ "field-get(int Point.x)", "advises");
+ checkUniDirectionalMapping("AdvisesRelationshipCoverage", "Point", "before(): setP..",
+ "field-set(int Point.x)", "advises");
}
- private void checkUniDirectionalMapping(String fromType, String toType, String from, String to, String relName) {
+ private void checkUniDirectionalMapping(String fromType, String toType, String from,
+ String to, String relName) {
+
IProgramElement aspect = AsmManager.getDefault().getHierarchy().findElementForType(null, fromType);
assertNotNull(aspect);
String beforeExec = from;
IProgramElement beforeExecNode = manager.getHierarchy().findElementForLabel(aspect, IProgramElement.Kind.ADVICE, beforeExec);
assertNotNull(beforeExecNode);
IRelationship rel = manager.getRelationshipMap().get(beforeExecNode, IRelationship.Kind.ADVICE, relName);
- String handle = (String)rel.getTargets().get(0);
- assertEquals(manager.getHierarchy().findElementForHandle(handle).toLabelString(), to);
+ for (Iterator it = rel.getTargets().iterator(); it.hasNext(); ) {
+ String currHandle = (String)it.next();
+ if (manager.getHierarchy().findElementForHandle(currHandle).toLabelString().equals(to)) return;
+ }
+ fail(); // didn't find it
}
- private void checkMapping(String fromType, String toType, String from, String to, String forwardRelName, String backRelName) {
+ private void checkMapping(String fromType, String toType, String from, String to,
+ String forwardRelName, String backRelName) {
+
IProgramElement aspect = AsmManager.getDefault().getHierarchy().findElementForType(null, fromType);
assertNotNull(aspect);
String beforeExec = from;
@@ -69,6 +79,30 @@ public class AsmRelationshipsTest extends AjdeTestCase {
assertEquals(manager.getHierarchy().findElementForHandle(handle2).toString(), from);
}
+ private void checkInterTypeMapping(String fromType, String toType, String from,
+ String to, String forwardRelName, String backRelName, IProgramElement.Kind declareKind) {
+
+ IProgramElement aspect = AsmManager.getDefault().getHierarchy().findElementForType(null, fromType);
+ assertNotNull(aspect);
+ String beforeExec = from;
+ IProgramElement fromNode = manager.getHierarchy().findElementForLabel(aspect, declareKind, beforeExec);
+ assertNotNull(fromNode);
+ IRelationship rel = manager.getRelationshipMap().get(fromNode, IRelationship.Kind.DECLARE_INTER_TYPE, forwardRelName);
+ String handle = (String)rel.getTargets().get(0);
+ assertEquals(manager.getHierarchy().findElementForHandle(handle).toString(), to);
+
+ IProgramElement clazz = AsmManager.getDefault().getHierarchy().findElementForType(null, toType);
+ assertNotNull(clazz);
+ String set = to;
+ IRelationship rel2 = manager.getRelationshipMap().get(clazz, IRelationship.Kind.DECLARE_INTER_TYPE, backRelName);
+ String handle2 = (String)rel2.getTargets().get(0);
+ for (Iterator it = rel2.getTargets().iterator(); it.hasNext(); ) {
+ String currHandle = (String)it.next();
+ if (manager.getHierarchy().findElementForHandle(currHandle).toLabelString().equals(from)) return;
+ }
+ fail(); // didn't find it
+ }
+
protected void setUp() throws Exception {
super.setUp("examples");
assertTrue("build success", doSynchronousBuild(CONFIG_FILE_PATH));