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
|
/* *******************************************************************
* Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Common Public License v1.0
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* PARC initial implementation
* ******************************************************************/
package org.aspectj.weaver.patterns;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.Set;
import org.aspectj.bridge.MessageUtil;
import org.aspectj.util.FuzzyBoolean;
import org.aspectj.weaver.ISourceContext;
import org.aspectj.weaver.ResolvedType;
import org.aspectj.weaver.Shadow;
import org.aspectj.weaver.VersionedDataInputStream;
import org.aspectj.weaver.WeaverMessages;
import org.aspectj.weaver.ast.Test;
public class PerFromSuper extends PerClause {
private PerClause.Kind kind;
public PerFromSuper(PerClause.Kind kind) {
this.kind = kind;
}
public Object accept(PatternNodeVisitor visitor, Object data) {
return visitor.visit(this,data);
}
public Set couldMatchKinds() {
return Shadow.ALL_SHADOW_KINDS;
}
public FuzzyBoolean fastMatch(FastMatchInfo type) {
throw new RuntimeException("unimplemented");
}
public FuzzyBoolean fastMatch(Class targetType) {
throw new RuntimeException("unimplemented");
}
protected FuzzyBoolean matchInternal(Shadow shadow) {
throw new RuntimeException("unimplemented");
}
public void resolveBindings(IScope scope, Bindings bindings) {
// this method intentionally left blank
}
protected Test findResidueInternal(Shadow shadow, ExposedState state) {
throw new RuntimeException("unimplemented");
}
public PerClause concretize(ResolvedType inAspect) {
PerClause p = lookupConcretePerClause(inAspect.getSuperclass());
if (p == null) {
inAspect.getWorld().getMessageHandler().handleMessage(
MessageUtil.error(WeaverMessages.format(WeaverMessages.MISSING_PER_CLAUSE,inAspect.getSuperclass()), getSourceLocation())
);
return new PerSingleton().concretize(inAspect);// AV: fallback on something else NPE in AJDT
} else {
if (p.getKind() != kind) {
inAspect.getWorld().getMessageHandler().handleMessage(
MessageUtil.error(WeaverMessages.format(WeaverMessages.WRONG_PER_CLAUSE,kind,p.getKind()),
getSourceLocation())
);
}
return p.concretize(inAspect);
}
}
public PerClause lookupConcretePerClause(ResolvedType lookupType) {
PerClause ret = lookupType.getPerClause();
if (ret == null) return null;
if (ret instanceof PerFromSuper) {
return lookupConcretePerClause(lookupType.getSuperclass());
}
return ret;
}
public void write(DataOutputStream s) throws IOException {
FROMSUPER.write(s);
kind.write(s);
writeLocation(s);
}
public static PerClause readPerClause(VersionedDataInputStream s, ISourceContext context) throws IOException {
PerFromSuper ret = new PerFromSuper(Kind.read(s));
ret.readLocation(context, s);
return ret;
}
public String toString() {
return "perFromSuper(" + kind + ", " + inAspect + ")";
}
public String toDeclarationString() {
return "";
}
public PerClause.Kind getKind() {
return kind;
}
}
|