aboutsummaryrefslogtreecommitdiffstats
path: root/tests/symbols/CrosscutTest.java
blob: 9eecb0df93b5ea19d996f964f2e49be59ff27b52 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
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);
    }

}