summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormkersten <mkersten>2003-02-26 10:11:28 +0000
committermkersten <mkersten>2003-02-26 10:11:28 +0000
commit9a67e6290d6e330418f9b0ccaa94ec32d9f0aa49 (patch)
tree66b43650b4cf851649bb829c36958c91879f2c2e
parent5e5a2dd20e2c8038dbaf14583710c76e21988659 (diff)
downloadaspectj-9a67e6290d6e330418f9b0ccaa94ec32d9f0aa49.tar.gz
aspectj-9a67e6290d6e330418f9b0ccaa94ec32d9f0aa49.zip
The mappings for advice are now correct, and associations have corresponding kinds (e.g. "affects exception handlers").
-rw-r--r--ajde/testdata/examples/coverage/ModelCoverage.java15
-rw-r--r--ajde/testdata/examples/coverage/coverage.ajsymbin10265 -> 12313 bytes
-rw-r--r--asm/src/org/aspectj/asm/AdviceAssociation.java16
-rw-r--r--weaver/src/org/aspectj/weaver/AsmAdaptor.java40
4 files changed, 49 insertions, 22 deletions
diff --git a/ajde/testdata/examples/coverage/ModelCoverage.java b/ajde/testdata/examples/coverage/ModelCoverage.java
index cf14bf080..c882d1674 100644
--- a/ajde/testdata/examples/coverage/ModelCoverage.java
+++ b/ajde/testdata/examples/coverage/ModelCoverage.java
@@ -1,5 +1,5 @@
-import java.io.*;;
+import java.io.*;
class Point {
@@ -23,24 +23,25 @@ class Point {
System.err.println("!");
}
setX(10);
+ new Point();
}
}
-aspect PcdCoverage {
+aspect AdvisesRelationCoverage {
before(): get(int *.*) { }
before(): set(int *.*) { }
before(): initialization(Point.new(..)) { }
before(): staticinitialization(Point) { }
before(): handler(IOException) { }
- before(): call(String Point.setX(int)) { }
-// before(): call(String Point.new()) { }
-// execution(): call(String Point.setX(int)) { }
+ before(): call(* Point.setX(int)) { }
+ before(): call(Point.new()) { }
+ before(): within(*) && execution(* Point.setX(..)) { }
+ before(): within(*) && execution(Point.new()) { }
}
aspect InterTypeDecCoverage {
- pointcut illegalNewFigElt(): call(FigureElement+.new(..)) &&
- !withincode(* Main.main(..));
+ pointcut illegalNewFigElt(): call(Point.new(..)) && !withincode(* *.doIt(..));
declare error: illegalNewFigElt():
"Illegal figure element constructor call.";
diff --git a/ajde/testdata/examples/coverage/coverage.ajsym b/ajde/testdata/examples/coverage/coverage.ajsym
index 27561a1b3..f796d993d 100644
--- a/ajde/testdata/examples/coverage/coverage.ajsym
+++ b/ajde/testdata/examples/coverage/coverage.ajsym
Binary files differ
diff --git a/asm/src/org/aspectj/asm/AdviceAssociation.java b/asm/src/org/aspectj/asm/AdviceAssociation.java
index c1914630d..842690ea2 100644
--- a/asm/src/org/aspectj/asm/AdviceAssociation.java
+++ b/asm/src/org/aspectj/asm/AdviceAssociation.java
@@ -23,14 +23,14 @@ import org.aspectj.asm.*;
public class AdviceAssociation implements Association {
public static final String NAME = "Advice";
- public static final Relation METHOD_RELATION = new Relation("affects methods", "method affected by", NAME, true, false);
- public static final Relation METHOD_CALL_SITE_RELATION = new Relation("affects method call sites", "method call site affected by", NAME, true, false);
- public static final Relation CONSTRUCTOR_RELATION = new Relation("affects constructors", "constructor affected by", NAME, true, false);
- public static final Relation CONSTRUCTOR_CALL_SITE_RELATION = new Relation("affects constructions", "construction affected by", NAME, true, false);
- public static final Relation HANDLER_RELATION = new Relation("affects handlers", "handler affected by", NAME, true, false);
- public static final Relation INITIALIZER_RELATION = new Relation("affects initializers", "initializer affected by", NAME, true, false);
- public static final Relation FIELD_ACCESS_RELATION = new Relation("affects field access", "field access affected by", NAME, true, false);
- public static final Relation INTRODUCTION_RELATION = new Relation("affects introduction", "introduction affected by", NAME, true, false);
+ public static final Relation METHOD_RELATION = new Relation("advises methods", "method advised by", NAME, true, false);
+ public static final Relation METHOD_CALL_SITE_RELATION = new Relation("advises method call sites", "method call site advised by", NAME, true, false);
+ public static final Relation CONSTRUCTOR_RELATION = new Relation("advises constructors", "constructors advised by", NAME, true, false);
+ public static final Relation CONSTRUCTOR_CALL_SITE_RELATION = new Relation("advises constructions", "construction advised by", NAME, true, false);
+ public static final Relation HANDLER_RELATION = new Relation("advises exception handlers", "exception handler advised by", NAME, true, false);
+ public static final Relation INITIALIZER_RELATION = new Relation("advises initializers", "initializers advised by", NAME, true, false);
+ public static final Relation FIELD_ACCESS_RELATION = new Relation("advises field access", "field access advised by", NAME, true, false);
+ public static final Relation INTRODUCTION_RELATION = new Relation("advises introduction", "introduction advised by", NAME, true, false);
private List relations = new ArrayList();
diff --git a/weaver/src/org/aspectj/weaver/AsmAdaptor.java b/weaver/src/org/aspectj/weaver/AsmAdaptor.java
index c9c0e52c0..0c3c7201d 100644
--- a/weaver/src/org/aspectj/weaver/AsmAdaptor.java
+++ b/weaver/src/org/aspectj/weaver/AsmAdaptor.java
@@ -33,19 +33,45 @@ public class AsmAdaptor {
// System.out.println("--------------------------");
ProgramElementNode targetNode = getNode(model, shadow);
ProgramElementNode adviceNode = getNode(model, a);
+
+ Relation relation;
+ if (shadow.getKind().equals(Shadow.FieldGet) || shadow.getKind().equals(Shadow.FieldSet)) {
+ relation = AdviceAssociation.FIELD_ACCESS_RELATION;
+ } else if (shadow.getKind().equals(Shadow.Initialization) || shadow.getKind().equals(Shadow.StaticInitialization)) {
+ relation = AdviceAssociation.INITIALIZER_RELATION;
+ } else if (shadow.getKind().equals(Shadow.ExceptionHandler)) {
+ relation = AdviceAssociation.HANDLER_RELATION;
+ } else if (shadow.getKind().equals(Shadow.MethodCall)) {
+ relation = AdviceAssociation.METHOD_CALL_SITE_RELATION;
+ } else if (shadow.getKind().equals(Shadow.ConstructorCall)) {
+ relation = AdviceAssociation.CONSTRUCTOR_CALL_SITE_RELATION;
+ } else if (shadow.getKind().equals(Shadow.MethodExecution) || shadow.getKind().equals(Shadow.AdviceExecution)) {
+ relation = AdviceAssociation.METHOD_RELATION;
+ } else if (shadow.getKind().equals(Shadow.ConstructorExecution)) {
+ relation = AdviceAssociation.CONSTRUCTOR_RELATION;
+ } else {
+ System.err.println("> unmatched relation: " + shadow.getKind());
+ relation = AdviceAssociation.METHOD_RELATION;
+ }
+
// System.out.println("> target: " + targetNode + ", advice: " + adviceNode);
- createAppropriateLinks(targetNode, adviceNode);
+ createAppropriateLinks(targetNode, adviceNode, relation);
}
}
private static void createAppropriateLinks(
ProgramElementNode target,
- ProgramElementNode advice)
+ ProgramElementNode advice,
+ Relation relation)
{
if (target == null || advice == null) return;
- addLink(target, new LinkNode(advice), org.aspectj.asm.AdviceAssociation.METHOD_RELATION, true);
- addLink(advice, new LinkNode(target), org.aspectj.asm.AdviceAssociation.METHOD_RELATION, false);
-// System.out.println(">> added target: " + target + ", advice: " + advice);
+
+
+ addLink(target, new LinkNode(advice), relation, true);
+ addLink(advice, new LinkNode(target), relation, false);
+
+// System.out.println(">> added target: " + target.getProgramElementKind() + ", advice: " + advice);
+// System.out.println(">> target: " + target + ", advice: " + target.getSourceLocation());
}
private static void addLink(
@@ -120,7 +146,8 @@ public class AsmAdaptor {
ProgramElementNode peNode = new ProgramElementNode(
shadow.toString(),
ProgramElementNode.Kind.CODE,
- new SourceLocation(enclosingNode.getSourceLocation().getSourceFile(), sl.getLine()),
+// new SourceLocation(enclosingNode.getSourceLocation().getSourceFile(), sl.getLine()),
+ enclosingNode.getSourceLocation(),
0,
"",
new ArrayList());
@@ -158,7 +185,6 @@ public class AsmAdaptor {
}
}
// if we can't find the member, we'll just put it in the class
- //??? is this what the IDEs want
return classNode;
}