aboutsummaryrefslogtreecommitdiffstats
path: root/tests/symbols
diff options
context:
space:
mode:
authorwisberg <wisberg>2002-12-16 18:51:06 +0000
committerwisberg <wisberg>2002-12-16 18:51:06 +0000
commit144143c2970a1e874d74cdbd0f8c622d4282a3c3 (patch)
treeb12383d3d9e76c7e1f25f7fbec83051ef17f81fb /tests/symbols
parentfafae443719b26159ab2d7dac1c9b46b5e00b671 (diff)
downloadaspectj-144143c2970a1e874d74cdbd0f8c622d4282a3c3.tar.gz
aspectj-144143c2970a1e874d74cdbd0f8c622d4282a3c3.zip
initial version
Diffstat (limited to 'tests/symbols')
-rw-r--r--tests/symbols/A.java49
-rw-r--r--tests/symbols/C.java24
-rw-r--r--tests/symbols/CrosscutTest.java128
-rw-r--r--tests/symbols/GenericTest.java268
-rw-r--r--tests/symbols/Helper.java220
5 files changed, 689 insertions, 0 deletions
diff --git a/tests/symbols/A.java b/tests/symbols/A.java
new file mode 100644
index 000000000..d838835e8
--- /dev/null
+++ b/tests/symbols/A.java
@@ -0,0 +1,49 @@
+package symbols;
+
+strictfp aspect A issingleton() {
+
+ /** objects */
+ pointcut instanceof_C(): this(C);
+ pointcut hasaspect_A(): if(A.hasAspect());
+
+ /** lexical extents */
+ pointcut within_C(): within(C);
+ pointcut withinall_C(): within(C+);
+ pointcut withincode_C(): withincode(void C.*(..));
+
+ /** control flow */
+ pointcut cflow_C(): cflow(withincode_C());
+ pointcut cflowtop_C(): cflow(withincode_C() && !cflowbelow(withincode_C()));
+
+ /** methods and constructors */
+ pointcut calls_C(): call(int C.*(..));
+ pointcut receptions_C(): call(int C.*(..));
+ pointcut executions_C(): execution(* C.*(..,float,..));
+ //pointcut callsto_C(): callsto(call(void C.*()));
+
+ /** exception handlers */
+ pointcut handlers_Thr(): handler(java.lang.Throwable);
+ pointcut handlers_Err(): handler(java.lang.Error);
+ pointcut handlers_Exc(): handler(java.lang.Exception);
+ pointcut handlers_Rt(): handler(java.lang.RuntimeException);
+
+ /** fields */
+ pointcut gets_f(): get(float C.*);
+ pointcut sets_f(): set(float C.*);
+
+ /** Advices */
+ //before(): call(void C.*()) { }
+ before(): this(C) && call(String Object.toString()) { }
+ before(): execution(C.new()) { }
+ after(): call(void C.*()) { }
+ after() returning (int x): call(int C.*(..)) { }
+ after() throwing (RuntimeException e): call(void C.MethV()) {
+ throw new RuntimeException("test");
+ }
+ void around() : call(void C.MethV()) { proceed(); }
+
+ /** Introductions */
+ public double symbols.C.intrD;
+ private void C.intrMethV() { intrD += 1; }
+
+}
diff --git a/tests/symbols/C.java b/tests/symbols/C.java
new file mode 100644
index 000000000..dcefa4ade
--- /dev/null
+++ b/tests/symbols/C.java
@@ -0,0 +1,24 @@
+package symbols;
+
+public class C {
+ /**
+ * multiline
+ * comment
+ */
+ void MethV() { }
+ public void MethVI(int i) { }
+ static public synchronized void MethVLF(long l, float f) { }
+ int MethISO(String s, Object o) { return this.toString().length(); }
+
+ public static volatile int i;
+ public float f;
+
+ static {
+ i = 0;
+ }
+
+ {
+ f = 1.f;
+ }
+
+}
diff --git a/tests/symbols/CrosscutTest.java b/tests/symbols/CrosscutTest.java
new file mode 100644
index 000000000..9eecb0df9
--- /dev/null
+++ b/tests/symbols/CrosscutTest.java
@@ -0,0 +1,128 @@
+import symbols.Helper;
+import org.aspectj.testing.Tester;
+
+import org.aspectj.tools.ide.SymbolManager;
+import org.aspectj.tools.ide.SourceLine;
+import org.aspectj.tools.ide.Declaration;
+
+import java.io.File;
+
+public class CrosscutTest {
+ private static Helper h = new Helper();
+
+ public static void main(String[] args) {
+ Declaration classDec = h.getDecl("C.java", 3);
+ Declaration aspectDec = h.getDecl("A.java", 3);
+
+ Declaration methodDecV = h.getDecl("C.java", 8);
+ Declaration methodDecVI = h.getDecl("C.java", 9);
+ Declaration methodDecVLF = h.getDecl("C.java",10);
+ Declaration methodDecISO = h.getDecl("C.java",11);
+
+ Declaration fieldDecI = h.getDecl("C.java",13);
+ Declaration fieldDecF = h.getDecl("C.java",14);
+
+ Declaration pointcutDecInstOf = h.getDecl("A.java", 6);
+ Declaration pointcutDecHasAsp = h.getDecl("A.java", 7);
+ Declaration pointcutDecWithin = h.getDecl("A.java", 10);
+ Declaration pointcutDecWithinAll = h.getDecl("A.java", 11);
+ Declaration pointcutDecWithinCode = h.getDecl("A.java", 12);
+ Declaration pointcutDecCFlow = h.getDecl("A.java", 15);
+ Declaration pointcutDecCFlowTop = h.getDecl("A.java", 16);
+ Declaration pointcutDecCalls = h.getDecl("A.java", 19);
+ Declaration pointcutDecRec = h.getDecl("A.java", 20);
+ Declaration pointcutDecExec = h.getDecl("A.java", 21);
+ Declaration pointcutDecCallsTo = h.getDecl("A.java", 22);
+ Declaration pointcutDecHandThr = h.getDecl("A.java", 25);
+ Declaration pointcutDecHandErr = h.getDecl("A.java", 26);
+ Declaration pointcutDecHandExc = h.getDecl("A.java", 27);
+ Declaration pointcutDecHandRt = h.getDecl("A.java", 28);
+ Declaration pointcutDecGets = h.getDecl("A.java", 31);
+ Declaration pointcutDecSets = h.getDecl("A.java", 32);
+
+ Declaration adviceDecBefore = h.getDecl("A.java", 35);
+ Declaration adviceDecAfter = h.getDecl("A.java", 36);
+ Declaration adviceDecAfterRet = h.getDecl("A.java", 37);
+ Declaration adviceDecAfterThr = h.getDecl("A.java", 38);
+ Declaration adviceDecAround = h.getDecl("A.java", 41);
+
+ Declaration fieldDecIntrD = h.getDecl("A.java", 44);
+ Declaration methodDecIntrV = h.getDecl("A.java", 45);
+
+ Declaration adviceDecBeforeToString = h.getDecl("A.java", 47);
+ Declaration adviceDecBeforeNew = h.getDecl("A.java", 48);
+
+ if (!h.allDecsFound) return;
+
+ // Check "points to"
+ h.checkPointsNothing(methodDecV);
+ h.checkPointsNothing(methodDecVI);
+ h.checkPointsNothing(methodDecVLF);
+ h.checkPointsNothing(methodDecISO);
+
+ h.checkPointsNothing(pointcutDecInstOf);
+ h.checkPointsNothing(pointcutDecHasAsp);
+ h.checkPointsNothing(pointcutDecWithin);
+ h.checkPointsNothing(pointcutDecWithinAll);
+ h.checkPointsNothing(pointcutDecWithinCode);
+ h.checkPointsNothing(pointcutDecCFlow);
+ h.checkPointsNothing(pointcutDecCFlowTop);
+ h.checkPointsNothing(pointcutDecCalls);
+ h.checkPointsNothing(pointcutDecRec);
+ h.checkPointsNothing(pointcutDecExec);
+ h.checkPointsNothing(pointcutDecCallsTo);
+ h.checkPointsNothing(pointcutDecHandThr);
+ h.checkPointsNothing(pointcutDecHandErr);
+ h.checkPointsNothing(pointcutDecHandExc);
+ h.checkPointsNothing(pointcutDecHandRt);
+ h.checkPointsNothing(pointcutDecGets);
+ h.checkPointsNothing(pointcutDecSets);
+
+ //XXX Need to decide if advices on introductions have to point to
+ // the introduction declaration, or to the member that was introduced
+ h.checkPointsTo(adviceDecBefore, new Declaration[]{methodDecV,methodDecIntrV});
+ h.checkPointsTo(adviceDecAfter, new Declaration[]{methodDecV,methodDecIntrV});
+ h.checkPointsTo(adviceDecAfterRet, new Declaration[]{methodDecISO});
+ h.checkPointsTo(adviceDecAfterThr, new Declaration[]{methodDecV});
+ h.checkPointsTo(adviceDecAround, new Declaration[]{methodDecV});
+
+ h.checkPointsNothing(adviceDecBeforeToString);
+ h.checkPointsNothing(adviceDecBeforeNew);
+
+ // Check "pointed by"
+ h.checkPointedToBy(methodDecV, new Declaration[]{adviceDecBefore,adviceDecAfter,adviceDecAfterThr,adviceDecAround});
+ h.checkPointedToByNone(methodDecVI);
+ h.checkPointedToByNone(methodDecVLF);
+ h.checkPointedToBy(methodDecISO, new Declaration[]{adviceDecAfterRet});
+
+ h.checkPointedToByNone(pointcutDecInstOf);
+ h.checkPointedToByNone(pointcutDecHasAsp);
+ h.checkPointedToByNone(pointcutDecWithin);
+ h.checkPointedToByNone(pointcutDecWithinAll);
+ h.checkPointedToByNone(pointcutDecWithinCode);
+ h.checkPointedToByNone(pointcutDecCFlow);
+ h.checkPointedToByNone(pointcutDecCFlowTop);
+ h.checkPointedToByNone(pointcutDecCalls);
+ h.checkPointedToByNone(pointcutDecRec);
+ h.checkPointedToByNone(pointcutDecExec);
+ h.checkPointedToByNone(pointcutDecCallsTo);
+ h.checkPointedToByNone(pointcutDecHandThr);
+ h.checkPointedToByNone(pointcutDecHandErr);
+ h.checkPointedToByNone(pointcutDecHandExc);
+ h.checkPointedToByNone(pointcutDecHandRt);
+ h.checkPointedToByNone(pointcutDecGets);
+ h.checkPointedToByNone(pointcutDecSets);
+
+ h.checkPointedToByNone(adviceDecBefore);
+ h.checkPointedToByNone(adviceDecBefore);
+ h.checkPointedToByNone(adviceDecAfter);
+ h.checkPointedToByNone(adviceDecAfterRet);
+ h.checkPointedToByNone(adviceDecAfterThr);
+ h.checkPointedToByNone(adviceDecAround);
+
+ h.checkPointedToByNone(adviceDecBeforeToString);
+ h.checkPointedToByNone(adviceDecBeforeNew);
+ }
+
+}
+
diff --git a/tests/symbols/GenericTest.java b/tests/symbols/GenericTest.java
new file mode 100644
index 000000000..650dbc8f1
--- /dev/null
+++ b/tests/symbols/GenericTest.java
@@ -0,0 +1,268 @@
+import symbols.Helper;
+import org.aspectj.testing.Tester;
+
+import org.aspectj.tools.ide.SymbolManager;
+import org.aspectj.tools.ide.SourceLine;
+import org.aspectj.tools.ide.Declaration;
+
+import java.io.File;
+
+public class GenericTest {
+ private static Helper h = new Helper();
+
+ public static void main(String[] args) {
+ Declaration classDec = h.getDecl("C.java", 3);
+ Declaration aspectDec = h.getDecl("A.java", 3);
+
+ Declaration fieldDecI = h.getDecl("C.java", 13);
+ Declaration fieldDecF = h.getDecl("C.java", 14);
+
+ //Declaration initDecS = h.getDecl("C.java", 22);
+ //Declaration initDec = h.getDecl("C.java", 26);
+
+ Declaration methodDecV = h.getDecl("C.java", 8);
+ Declaration methodDecVI = h.getDecl("C.java", 9);
+ Declaration methodDecVLF = h.getDecl("C.java",10);
+ Declaration methodDecISO = h.getDecl("C.java",11);
+
+ Declaration pointcutDecInstOf = h.getDecl("A.java", 6);
+ Declaration pointcutDecHasAsp = h.getDecl("A.java", 7);
+ Declaration pointcutDecWithin = h.getDecl("A.java", 10);
+ Declaration pointcutDecWithinAll = h.getDecl("A.java", 11);
+ Declaration pointcutDecWithinCode = h.getDecl("A.java", 12);
+ Declaration pointcutDecCFlow = h.getDecl("A.java", 15);
+ Declaration pointcutDecCFlowTop = h.getDecl("A.java", 16);
+ Declaration pointcutDecCalls = h.getDecl("A.java", 19);
+ Declaration pointcutDecRec = h.getDecl("A.java", 20);
+ Declaration pointcutDecExec = h.getDecl("A.java", 21);
+ Declaration pointcutDecCallsTo = h.getDecl("A.java", 22);
+ Declaration pointcutDecHandThr = h.getDecl("A.java", 25);
+ Declaration pointcutDecHandErr = h.getDecl("A.java", 26);
+ Declaration pointcutDecHandExc = h.getDecl("A.java", 27);
+ Declaration pointcutDecHandRt = h.getDecl("A.java", 28);
+ Declaration pointcutDecGets = h.getDecl("A.java", 31);
+ Declaration pointcutDecSets = h.getDecl("A.java", 32);
+
+ Declaration adviceDecBefore = h.getDecl("A.java", 35);
+ Declaration adviceDecAfter = h.getDecl("A.java", 36);
+ Declaration adviceDecAfterRet = h.getDecl("A.java", 37);
+ Declaration adviceDecAfterThr = h.getDecl("A.java", 38);
+ Declaration adviceDecAround = h.getDecl("A.java", 41);
+ Declaration adviceDecBeforeToString = h.getDecl("A.java", 47);
+ Declaration adviceDecBeforeNew = h.getDecl("A.java", 48);
+
+
+ Declaration fieldDecIntrD = h.getDecl("A.java", 44);
+ Declaration methodDecIntrV = h.getDecl("A.java", 45);
+
+ // check we've checking all decs in aspect A and class C
+ h.checkAllDecsOf(classDec,new Declaration[]{
+ fieldDecI,
+ fieldDecF,
+ //initDecS,
+ //initDec,
+ methodDecV,
+ methodDecVI,
+ methodDecVLF,
+ methodDecISO
+ });
+ h.checkAllDecsOf(aspectDec,new Declaration[]{
+ pointcutDecInstOf,
+ pointcutDecHasAsp,
+ pointcutDecWithin,
+ pointcutDecWithinAll,
+ pointcutDecWithinCode,
+ pointcutDecCFlow,
+ pointcutDecCFlowTop,
+ pointcutDecCalls,
+ pointcutDecRec,
+ pointcutDecExec,
+ pointcutDecCallsTo,
+ pointcutDecHandThr,
+ pointcutDecHandErr,
+ pointcutDecHandExc,
+ pointcutDecHandRt,
+ pointcutDecGets,
+ pointcutDecSets,
+ adviceDecBefore,
+ adviceDecAfter,
+ adviceDecAfterRet,
+ adviceDecAfterThr,
+ adviceDecAround,
+ adviceDecBeforeToString,
+ adviceDecBeforeNew,
+ fieldDecIntrD,
+ methodDecIntrV
+ });
+
+ if (!h.allDecsFound) return;
+
+ h.checkPos(classDec, 3, 1,24, 2, "C.java");
+ h.checkPos(aspectDec, 3, 1,49, 2, "A.java");
+ h.checkPos(fieldDecI, 13, 5,13,34, "C.java");
+ h.checkPos(fieldDecF, 14, 5,14,20, "C.java");
+ h.checkPos(methodDecV, 8, 5, 8, 21, "C.java");
+ h.checkPos(methodDecVI, 9, 5, 9, 34, "C.java");
+ h.checkPos(methodDecVLF,10, 5,10, 65, "C.java");
+ h.checkPos(methodDecISO,11, 5,11, 74, "C.java");
+ h.checkPos(pointcutDecInstOf, 6, 5, 6, 44, "A.java");
+ h.checkPos(pointcutDecHasAsp, 7, 5, 7, 42, "A.java");
+ h.checkPos(pointcutDecWithin, 10, 5, 10, 36, "A.java");
+ h.checkPos(pointcutDecWithinAll, 11, 5, 11, 42, "A.java");
+ h.checkPos(pointcutDecWithinCode,12, 5, 12, 55, "A.java");
+ h.checkPos(pointcutDecCFlow, 15, 5, 15, 47, "A.java");
+ h.checkPos(pointcutDecCFlowTop, 16, 5, 16, 53, "A.java");
+ h.checkPos(pointcutDecCalls, 19, 5, 19, 44, "A.java");
+ h.checkPos(pointcutDecRec, 20, 5, 20, 54, "A.java");
+ h.checkPos(pointcutDecExec, 21, 5, 21, 61, "A.java");
+ h.checkPos(pointcutDecCallsTo, 22, 5, 22, 59, "A.java");
+ h.checkPos(pointcutDecHandThr, 25, 5, 25, 60, "A.java");
+ h.checkPos(pointcutDecHandErr, 26, 5, 26, 56, "A.java");
+ h.checkPos(pointcutDecHandExc, 27, 5, 27, 60, "A.java");
+ h.checkPos(pointcutDecHandRt, 28, 5, 28, 66, "A.java");
+ h.checkPos(pointcutDecGets, 31, 5, 31, 40, "A.java");
+ h.checkPos(pointcutDecSets, 32, 5, 32, 40, "A.java");
+ h.checkPos(adviceDecBefore, 35, 5, 35, 41, "A.java");
+ h.checkPos(adviceDecAfter, 36, 5, 36, 40, "A.java");
+ h.checkPos(adviceDecAfterRet, 37, 5, 37, 59, "A.java");
+ h.checkPos(adviceDecAfterThr, 38, 5, 40, 6, "A.java");
+ h.checkPos(adviceDecAround, 41, 5, 41, 69, "A.java");
+ h.checkPos(fieldDecIntrD, 44, 5, 44, 35, "A.java");
+ h.checkPos(methodDecIntrV, 45, 5, 45, 47, "A.java");
+
+ h.checkKind(classDec, "class");
+ h.checkKind(aspectDec, "class");
+ h.checkKind(fieldDecI, "field");
+ h.checkKind(fieldDecF, "field");
+ h.checkKind(methodDecV, "method");
+ h.checkKind(methodDecVI, "method");
+ h.checkKind(methodDecVLF, "method");
+ h.checkKind(methodDecISO, "method");
+ h.checkKind(pointcutDecInstOf, "pointcut");
+ h.checkKind(pointcutDecHasAsp, "pointcut");
+ h.checkKind(pointcutDecWithin, "pointcut");
+ h.checkKind(pointcutDecWithinAll, "pointcut");
+ h.checkKind(pointcutDecWithinCode,"pointcut");
+ h.checkKind(pointcutDecCFlow, "pointcut");
+ h.checkKind(pointcutDecCFlowTop, "pointcut");
+ h.checkKind(pointcutDecCalls, "pointcut");
+ h.checkKind(pointcutDecRec, "pointcut");
+ h.checkKind(pointcutDecExec, "pointcut");
+ h.checkKind(pointcutDecCallsTo, "pointcut");
+ h.checkKind(pointcutDecHandThr, "pointcut");
+ h.checkKind(pointcutDecHandErr, "pointcut");
+ h.checkKind(pointcutDecHandExc, "pointcut");
+ h.checkKind(pointcutDecHandRt, "pointcut");
+ h.checkKind(pointcutDecGets, "pointcut");
+ h.checkKind(pointcutDecSets, "pointcut");
+ h.checkKind(adviceDecBefore, "advice");
+ h.checkKind(adviceDecAfter, "advice");
+ h.checkKind(adviceDecAfterRet, "advice");
+ h.checkKind(adviceDecAfterThr, "advice");
+ h.checkKind(adviceDecAround, "advice");
+ h.checkKind(fieldDecIntrD, "introduction");
+ h.checkKind(methodDecIntrV, "introduction");
+
+ h.checkFormalComment(classDec, "");
+ h.checkFormalComment(aspectDec, "");
+ h.checkFormalComment(fieldDecI, "");
+ h.checkFormalComment(fieldDecF, "");
+ h.checkFormalComment(methodDecV, "/**\n * multiline\n * comment\n */");
+ h.checkFormalComment(methodDecVI, "");
+ h.checkFormalComment(methodDecVLF, "");
+ h.checkFormalComment(methodDecISO, "");
+ h.checkFormalComment(pointcutDecInstOf, "/** objects */");
+ h.checkFormalComment(pointcutDecHasAsp, "");
+ h.checkFormalComment(pointcutDecWithin, "/** lexical extents */");
+ h.checkFormalComment(pointcutDecWithinAll, "");
+ h.checkFormalComment(pointcutDecWithinCode,"");
+ h.checkFormalComment(pointcutDecCFlow, "/** control flow */");
+ h.checkFormalComment(pointcutDecCFlowTop, "");
+ h.checkFormalComment(pointcutDecCalls, "/** methods and constructors */");
+ h.checkFormalComment(pointcutDecRec, "");
+ h.checkFormalComment(pointcutDecExec, "");
+ h.checkFormalComment(pointcutDecCallsTo, "");
+ h.checkFormalComment(pointcutDecHandThr, "/** exception handlers */");
+ h.checkFormalComment(pointcutDecHandErr, "");
+ h.checkFormalComment(pointcutDecHandExc, "");
+ h.checkFormalComment(pointcutDecHandRt, "");
+ h.checkFormalComment(pointcutDecGets, "/** fields */");
+ h.checkFormalComment(pointcutDecSets, "");
+ h.checkFormalComment(adviceDecBefore, "/** Advices */");
+ h.checkFormalComment(adviceDecAfter, "");
+ h.checkFormalComment(adviceDecAfterRet, "");
+ h.checkFormalComment(adviceDecAfterThr, "");
+ h.checkFormalComment(adviceDecAround, "");
+ h.checkFormalComment(fieldDecIntrD, "/** Introductions */");
+ h.checkFormalComment(methodDecIntrV, "");
+
+ h.checkModifiers(classDec, "public");
+ h.checkModifiers(aspectDec, "public strictfp");
+ h.checkModifiers(fieldDecI, "public static volatile");
+ h.checkModifiers(fieldDecF, "public");
+ h.checkModifiers(methodDecV, "");
+ h.checkModifiers(methodDecVI, "public");
+ h.checkModifiers(methodDecVLF, "synchronized public static");
+ h.checkModifiers(methodDecISO, "");
+ h.checkModifiers(pointcutDecInstOf, "");
+ h.checkModifiers(pointcutDecHasAsp, "");
+ h.checkModifiers(pointcutDecWithin, "");
+ h.checkModifiers(pointcutDecWithinAll, "");
+ h.checkModifiers(pointcutDecWithinCode,"");
+ h.checkModifiers(pointcutDecCFlow, "");
+ h.checkModifiers(pointcutDecCFlowTop, "");
+ h.checkModifiers(pointcutDecCalls, "");
+ h.checkModifiers(pointcutDecRec, "");
+ h.checkModifiers(pointcutDecExec, "");
+ h.checkModifiers(pointcutDecCallsTo, "");
+ h.checkModifiers(pointcutDecHandThr, "");
+ h.checkModifiers(pointcutDecHandErr, "");
+ h.checkModifiers(pointcutDecHandExc, "");
+ h.checkModifiers(pointcutDecHandRt, "");
+ h.checkModifiers(pointcutDecGets, "");
+ h.checkModifiers(pointcutDecSets, "");
+ h.checkModifiers(adviceDecBefore, "");
+ h.checkModifiers(adviceDecAfter, "");
+ h.checkModifiers(adviceDecAfterRet, "");
+ h.checkModifiers(adviceDecAfterThr, "");
+ h.checkModifiers(adviceDecAround, "");
+ h.checkModifiers(fieldDecIntrD, "public");
+ h.checkModifiers(methodDecIntrV, "private");
+
+ h.checkSignature(classDec, "C", "public class C");
+ h.checkSignature(aspectDec, "A", "public strictfp class A");
+ h.checkSignature(fieldDecI, "i", "public static volatile int i");
+ h.checkSignature(fieldDecF, "f", "public float f");
+ h.checkSignature(methodDecV, "MethV()", "void MethV()");
+ h.checkSignature(methodDecVI, "MethVI(int)", "public void MethVI(int i)");
+ h.checkSignature(methodDecVLF, "MethVLF(long, float)", "public static synchronized void MethVLF(long l, float f)");
+ h.checkSignature(methodDecISO, "MethISO(String, Object)", "int MethISO(java.lang.String s, java.lang.Object o)");
+ h.checkSignature(pointcutDecInstOf, "instanceof_C()", "");
+ h.checkSignature(pointcutDecHasAsp, "hasaspect_A()", "");
+ h.checkSignature(pointcutDecWithin, "within_C()", "");
+ h.checkSignature(pointcutDecWithinAll, "withinall_C()", "");
+ h.checkSignature(pointcutDecWithinCode,"withincode_C()", "");
+ h.checkSignature(pointcutDecCFlow, "cflow_C()", "");
+ h.checkSignature(pointcutDecCFlowTop, "cflowtop_C()", "");
+ h.checkSignature(pointcutDecCalls, "calls_C()", "");
+ h.checkSignature(pointcutDecRec, "receptions_C()", "");
+ h.checkSignature(pointcutDecExec, "executions_C()", "");
+ h.checkSignature(pointcutDecCallsTo, "callsto_C()", "");
+ h.checkSignature(pointcutDecHandThr, "handlers_Thr()", "");
+ h.checkSignature(pointcutDecHandErr, "handlers_Err()", "");
+ h.checkSignature(pointcutDecHandExc, "handlers_Exc()", "");
+ h.checkSignature(pointcutDecHandRt, "handlers_Rt()", "");
+ h.checkSignature(pointcutDecGets, "gets_f()", "");
+ h.checkSignature(pointcutDecSets, "sets_f()", "");
+ h.checkSignature(adviceDecBefore, "before()", "");
+ h.checkSignature(adviceDecAfter, "after()", "");
+ h.checkSignature(adviceDecAfterRet, "afterReturning()", "");
+ h.checkSignature(adviceDecAfterThr, "afterThrowing()", "");
+ h.checkSignature(adviceDecAround, "around()", "");
+ h.checkSignature(fieldDecIntrD, "C.intrD", "");
+ h.checkSignature(methodDecIntrV, "C.intrMethV()", "");
+
+ }
+
+}
+
diff --git a/tests/symbols/Helper.java b/tests/symbols/Helper.java
new file mode 100644
index 000000000..2fe5164d4
--- /dev/null
+++ b/tests/symbols/Helper.java
@@ -0,0 +1,220 @@
+package symbols;
+
+import org.aspectj.testing.Tester;
+
+import org.aspectj.tools.ide.SymbolManager;
+import org.aspectj.tools.ide.SourceLine;
+import org.aspectj.tools.ide.Declaration;
+
+import java.io.File;
+import java.util.StringTokenizer;
+
+public class Helper {
+
+ public final SymbolManager sm = SymbolManager.getSymbolManager();
+
+ public String file(String fn) {
+ return new File(new File("symbols"),fn).getAbsolutePath();
+ }
+
+ public boolean allDecsFound = true;
+ public Declaration getDecl(String fn, int ln) {
+ Declaration dec = sm.getDeclarationAtLine(file(fn), ln);
+ if (dec == null) {
+ allDecsFound = false;
+ Tester.checkFailed("Declaration at "+fn+":"+ln+" not found");
+ }
+ return dec;
+ }
+
+ public void checkPos(Declaration dec, int line1, int col1, int line2, int col2, String fname) {
+ if (dec == null) return;
+ Tester.checkEqual(dec.getBeginLine(), line1, "wrond begin line of "+getName(dec));
+ Tester.checkEqual(dec.getEndLine(), line2, "wrond end line of "+getName(dec));
+ Tester.checkEqual(dec.getBeginColumn(),col1, "wrond begin column of "+getName(dec));
+ Tester.checkEqual(dec.getEndColumn(), col2, "wrond end column of "+getName(dec));
+ Tester.checkEqual(dec.getFilename(), file(fname), "wrond file name of "+getName(dec));
+ }
+
+ public void checkKind(Declaration dec, String kind) {
+ if (dec == null) return;
+ Tester.checkEqual(dec.getKind(),kind,"kinds differ");
+ }
+
+ public void checkSignature(Declaration dec, String sig, String fsig) {
+ if (dec == null) return;
+ String dsig = dec.getSignature();
+ String dfsig = dec.getFullSignature();
+ if (dsig != null) {
+ dsig = dsig.trim();
+ if (dsig.startsWith("/*") && dsig.endsWith("*/")) dsig = "";
+ }
+ if (dfsig != null) {
+ dfsig = dfsig.trim();
+ if (dfsig.startsWith("/*") && dfsig.endsWith("*/")) dfsig = "";
+ }
+ Tester.checkEqual(dsig,sig,"signatures of '"+getName(dec)+"' differ");
+ Tester.checkEqual(dfsig,fsig,"full signatures of '"+getName(dec)+"' differ");
+ }
+
+ public void checkFormalComment(Declaration dec, String comment) {
+ if (dec == null) return;
+ String fc = dec.getFormalComment();
+ if (fc != null) fc = fc.trim();
+ //Tester.checkEqual(fc,comment,"formal comment differ");
+ }
+
+ public void checkPointsNothing(Declaration dec) {
+ if (dec == null) return;
+ Declaration[] points = dec.getPointsTo();
+ if (points == null) {
+ Tester.checkFailed(".getPointsTo() for Declaration of "+getName(dec)+" returns 'null'");
+ return;
+ }
+ for (int i=0; i < points.length; i++) {
+ Tester.checkFailed("unexpected that "+getName(dec)+" points to "+getName(points[i]));
+ }
+ }
+ public void checkPointsTo(Declaration dec, Declaration[] expected) {
+ if (dec == null) return;
+ Declaration[] points = dec.getPointsTo();
+ if (points == null) {
+ Tester.checkFailed(".getPointsTo() for Declaration of "+getName(dec)+" returns 'null'");
+ return;
+ }
+ int i, j;
+ for (i=0; i < expected.length; i++) {
+ if (expected[i] == null) {
+ Tester.checkFailed("array element ["+i+"] of expected 'points to' declarations of "+getName(dec)+" contains 'null'");
+ continue;
+ }
+ for (j=0; j < points.length; j++) {
+ if (expected[i].equals(points[j])) break;
+ }
+ if (j >= points.length)
+ Tester.checkFailed("expected that "+getName(dec)+" points to "+getName(expected[i]));
+ }
+ for (i=0; i < points.length; i++) {
+ if (points[i] == null) {
+ Tester.checkFailed(".getPointsTo() array element ["+i+"] of declaration "+getName(dec)+" contains 'null'");
+ continue;
+ }
+ for (j=0; j < expected.length; j++) {
+ if (points[i].equals(expected[j])) break;
+ }
+ if (j >= expected.length)
+ Tester.checkFailed("unexpected that "+getName(dec)+" points to "+getName(points[i]));
+ }
+ }
+
+ public void checkPointedToByNone(Declaration dec) {
+ if (dec == null) return;
+ Declaration[] pointed = dec.getPointedToBy();
+ if (pointed == null) {
+ Tester.checkFailed(".getPointedToBy() for Declaration of "+getName(dec)+" returns 'null'");
+ return;
+ }
+ for (int i=0; i < pointed.length; i++) {
+ Tester.checkFailed("unexpected that "+getName(dec)+" pointed by "+getName(pointed[i]));
+ }
+ }
+ public void checkPointedToBy(Declaration dec, Declaration[] expected) {
+ if (dec == null) return;
+ Declaration[] pointed = dec.getPointedToBy();
+ if (pointed == null) {
+ Tester.checkFailed(".getPointedToBy() for Declaration of "+getName(dec)+" returns 'null'");
+ return;
+ }
+ int i, j;
+ for (i=0; i < expected.length; i++) {
+ if (expected[i] == null) {
+ Tester.checkFailed("array element ["+i+"] of expected 'pointed to by' declarations of "+getName(dec)+" contains 'null'");
+ continue;
+ }
+ for (j=0; j < pointed.length; j++) {
+ if (pointed[j].equals(expected[i])) break;
+ }
+ if (j >= pointed.length)
+ Tester.checkFailed("expected that "+getName(dec)+" pointed to by "+getName(expected[i]));
+ }
+ for (i=0; i < pointed.length; i++) {
+ if (pointed[i] == null) {
+ Tester.checkFailed(".getPointedToBy() array element ["+i+"] of declaration "+getName(dec)+" contains 'null'");
+ continue;
+ }
+ for (j=0; j < expected.length; j++) {
+ if (pointed[i].equals(expected[j])) break;
+ }
+ if (j >= expected.length)
+ Tester.checkFailed("unexpected that "+getName(dec)+" pointed to by "+getName(pointed[i]));
+ }
+ }
+
+ public void checkModifiers(Declaration dec, String expected_modifiers) {
+ if (dec == null) return;
+ StringTokenizer st = new StringTokenizer(expected_modifiers);
+ String[] expected = new String[st.countTokens()];
+ for(int i=0; i < expected.length; i++) expected[i] = st.nextToken();
+ st = new StringTokenizer(dec.getModifiers());
+ String[] modifiers = new String[st.countTokens()];
+ for(int i=0; i < modifiers.length; i++) modifiers[i] = st.nextToken();
+
+ int i, j;
+ for (i=0; i < expected.length; i++) {
+ for (j=0; j < modifiers.length; j++) {
+ if (modifiers[j].equals(expected[i])) break;
+ }
+ if (j >= modifiers.length)
+ Tester.checkFailed("expected that "+getName(dec)+" has modifier "+expected[i]);
+ }
+ for (i=0; i < modifiers.length; i++) {
+ for (j=0; j < expected.length; j++) {
+ if (modifiers[i].equals(expected[j])) break;
+ }
+ if (j >= expected.length)
+ Tester.checkFailed("unexpected that "+getName(dec)+" has modifier "+modifiers[i]);
+ }
+ }
+
+ public void checkAllDecsOf(Declaration dec, Declaration[] decs) {
+ Declaration[] sdecs = dec.getDeclarations();
+ if (sdecs == null) {
+ Tester.checkFailed("unexpected that 'getDeclarations' for "+getName(dec)+" returned 'null'");
+ return;
+ }
+ int i, j;
+ for (i=0; i < decs.length; i++) {
+ if (decs[i] == null) continue;
+ for (j=0; j < sdecs.length; j++) {
+ if (decs[j].equals(sdecs[i])) break;
+ }
+ if (j >= sdecs.length)
+ Tester.checkFailed("expected that "+getName(dec)+" contains "+getName(decs[i]));
+ }
+ for (i=0; i < sdecs.length; i++) {
+ if (sdecs[i] == null) continue;
+ for (j=0; j < decs.length; j++) {
+ if (sdecs[i].equals(decs[j])) break;
+ }
+ if (j >= decs.length)
+ Tester.checkFailed("unexpected that "+getName(dec)+" contains "+getName(sdecs[i]));
+ }
+ }
+
+ private static String getName(Declaration dec) {
+ if (dec == null) return "<null>";
+ String name = dec.getSignature();
+ if (name != null && name.length() > 0) return name + "(" + getFilePos(dec) + ")";
+ name = dec.getKind() + " at " + getFilePos(dec);
+ return name;
+ }
+ private static String getFilePos(Declaration dec) {
+ String longFileName = dec.getFilename();
+ if (longFileName == null) return "?.java:" + dec.getBeginLine();
+ int pos = longFileName.lastIndexOf('/');
+ if (pos < 0) pos = longFileName.lastIndexOf('\\');
+ if (pos < 0) return longFileName + ":" + dec.getBeginLine();
+ return longFileName.substring(pos+1) + ":" + dec.getBeginLine();
+ }
+}
+