Lines 25-32
Link Here
|
25 |
import org.eclipse.jdt.core.dom.Annotation; |
25 |
import org.eclipse.jdt.core.dom.Annotation; |
26 |
import org.eclipse.jdt.core.dom.CompilationUnit; |
26 |
import org.eclipse.jdt.core.dom.CompilationUnit; |
27 |
import org.eclipse.jdt.core.dom.IMethodBinding; |
27 |
import org.eclipse.jdt.core.dom.IMethodBinding; |
28 |
import org.eclipse.jdt.core.dom.IResolvedAnnotation; |
28 |
import org.eclipse.jdt.core.dom.IAnnotationBinding; |
29 |
import org.eclipse.jdt.core.dom.IResolvedMemberValuePair; |
29 |
import org.eclipse.jdt.core.dom.IMemberValuePairBinding; |
30 |
import org.eclipse.jdt.core.dom.ITypeBinding; |
30 |
import org.eclipse.jdt.core.dom.ITypeBinding; |
31 |
import org.eclipse.jdt.core.dom.IVariableBinding; |
31 |
import org.eclipse.jdt.core.dom.IVariableBinding; |
32 |
import org.eclipse.jdt.core.dom.MemberValuePair; |
32 |
import org.eclipse.jdt.core.dom.MemberValuePair; |
Lines 46-58
Link Here
|
46 |
public class AnnotationMirrorImpl implements AnnotationMirror, EclipseMirrorImpl |
46 |
public class AnnotationMirrorImpl implements AnnotationMirror, EclipseMirrorImpl |
47 |
{ |
47 |
{ |
48 |
/**The ast node that correspond to the annotation.*/ |
48 |
/**The ast node that correspond to the annotation.*/ |
49 |
private final IResolvedAnnotation _domAnnotation; |
49 |
private final IAnnotationBinding _domAnnotation; |
50 |
private final BaseProcessorEnv _env; |
50 |
private final BaseProcessorEnv _env; |
51 |
/** the declaration that is annotated by this annotation or the annotation element declaration |
51 |
/** the declaration that is annotated by this annotation or the annotation element declaration |
52 |
* if this is (part of) a default value*/ |
52 |
* if this is (part of) a default value*/ |
53 |
private final EclipseDeclarationImpl _annotated; |
53 |
private final EclipseDeclarationImpl _annotated; |
54 |
|
54 |
|
55 |
public AnnotationMirrorImpl(IResolvedAnnotation annotationAstNode, EclipseDeclarationImpl decl, BaseProcessorEnv env) |
55 |
public AnnotationMirrorImpl(IAnnotationBinding annotationAstNode, EclipseDeclarationImpl decl, BaseProcessorEnv env) |
56 |
{ |
56 |
{ |
57 |
_domAnnotation = annotationAstNode; |
57 |
_domAnnotation = annotationAstNode; |
58 |
_env = env; |
58 |
_env = env; |
Lines 80-93
Link Here
|
80 |
|
80 |
|
81 |
public Map<AnnotationTypeElementDeclaration, AnnotationValue> getElementValues() |
81 |
public Map<AnnotationTypeElementDeclaration, AnnotationValue> getElementValues() |
82 |
{ |
82 |
{ |
83 |
final IResolvedMemberValuePair[] pairs = _domAnnotation.getDeclaredMemberValuePairs(); |
83 |
final IMemberValuePairBinding[] pairs = _domAnnotation.getDeclaredMemberValuePairs(); |
84 |
if (pairs.length == 0) { |
84 |
if (pairs.length == 0) { |
85 |
return Collections.emptyMap(); |
85 |
return Collections.emptyMap(); |
86 |
} |
86 |
} |
87 |
|
87 |
|
88 |
final Map<AnnotationTypeElementDeclaration, AnnotationValue> result = |
88 |
final Map<AnnotationTypeElementDeclaration, AnnotationValue> result = |
89 |
new LinkedHashMap<AnnotationTypeElementDeclaration, AnnotationValue>(pairs.length * 4 / 3 + 1 ); |
89 |
new LinkedHashMap<AnnotationTypeElementDeclaration, AnnotationValue>(pairs.length * 4 / 3 + 1 ); |
90 |
for( IResolvedMemberValuePair pair : pairs ){ |
90 |
for( IMemberValuePairBinding pair : pairs ){ |
91 |
final String name = pair.getName(); |
91 |
final String name = pair.getName(); |
92 |
if( name == null ) continue; |
92 |
if( name == null ) continue; |
93 |
IMethodBinding elementMethod = pair.getMethodBinding(); |
93 |
IMethodBinding elementMethod = pair.getMethodBinding(); |
Lines 142-149
Link Here
|
142 |
public ITypeBinding[] getMemberValueTypeBinding(String membername) |
142 |
public ITypeBinding[] getMemberValueTypeBinding(String membername) |
143 |
{ |
143 |
{ |
144 |
if( membername == null ) return null; |
144 |
if( membername == null ) return null; |
145 |
final IResolvedMemberValuePair[] declaredPairs = _domAnnotation.getDeclaredMemberValuePairs(); |
145 |
final IMemberValuePairBinding[] declaredPairs = _domAnnotation.getDeclaredMemberValuePairs(); |
146 |
for( IResolvedMemberValuePair pair : declaredPairs ){ |
146 |
for( IMemberValuePairBinding pair : declaredPairs ){ |
147 |
if( membername.equals(pair.getName()) ){ |
147 |
if( membername.equals(pair.getName()) ){ |
148 |
final Object value = pair.getValue(); |
148 |
final Object value = pair.getValue(); |
149 |
return getValueTypeBinding(value, pair.getMethodBinding().getReturnType()); |
149 |
return getValueTypeBinding(value, pair.getMethodBinding().getReturnType()); |
Lines 191-198
Link Here
|
191 |
public Object getValue(final String memberName) |
191 |
public Object getValue(final String memberName) |
192 |
{ |
192 |
{ |
193 |
if( memberName == null ) return null; |
193 |
if( memberName == null ) return null; |
194 |
final IResolvedMemberValuePair[] declaredPairs = _domAnnotation.getDeclaredMemberValuePairs(); |
194 |
final IMemberValuePairBinding[] declaredPairs = _domAnnotation.getDeclaredMemberValuePairs(); |
195 |
for( IResolvedMemberValuePair pair : declaredPairs ){ |
195 |
for( IMemberValuePairBinding pair : declaredPairs ){ |
196 |
if( memberName.equals(pair.getName()) ){ |
196 |
if( memberName.equals(pair.getName()) ){ |
197 |
return pair.getValue(); |
197 |
return pair.getValue(); |
198 |
} |
198 |
} |
Lines 221-227
Link Here
|
221 |
return null; |
221 |
return null; |
222 |
} |
222 |
} |
223 |
|
223 |
|
224 |
public IResolvedAnnotation getResolvedAnnotaion(){return _domAnnotation; } |
224 |
public IAnnotationBinding getResolvedAnnotaion(){return _domAnnotation; } |
225 |
|
225 |
|
226 |
|
226 |
|
227 |
|
227 |
|