Lines 13-21
Link Here
|
13 |
import org.eclipse.jdt.internal.compiler.ASTVisitor; |
13 |
import org.eclipse.jdt.internal.compiler.ASTVisitor; |
14 |
import org.eclipse.jdt.internal.compiler.impl.Constant; |
14 |
import org.eclipse.jdt.internal.compiler.impl.Constant; |
15 |
import org.eclipse.jdt.internal.compiler.lookup.BaseTypeBinding; |
15 |
import org.eclipse.jdt.internal.compiler.lookup.BaseTypeBinding; |
|
|
16 |
import org.eclipse.jdt.internal.compiler.lookup.Binding; |
16 |
import org.eclipse.jdt.internal.compiler.lookup.BlockScope; |
17 |
import org.eclipse.jdt.internal.compiler.lookup.BlockScope; |
17 |
import org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope; |
18 |
import org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope; |
18 |
import org.eclipse.jdt.internal.compiler.lookup.ElementValuePair; |
19 |
import org.eclipse.jdt.internal.compiler.lookup.ElementValuePair; |
|
|
20 |
import org.eclipse.jdt.internal.compiler.lookup.FieldBinding; |
19 |
import org.eclipse.jdt.internal.compiler.lookup.MethodBinding; |
21 |
import org.eclipse.jdt.internal.compiler.lookup.MethodBinding; |
20 |
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; |
22 |
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; |
21 |
|
23 |
|
Lines 141-148
Link Here
|
141 |
final Expression[] expressions = initializer.expressions; |
143 |
final Expression[] expressions = initializer.expressions; |
142 |
if (expressions != null) { |
144 |
if (expressions != null) { |
143 |
for (int i =0, max = expressions.length; i < max; i++) { |
145 |
for (int i =0, max = expressions.length; i < max; i++) { |
144 |
if (!(expressions[i] instanceof ClassLiteralAccess)) { |
146 |
Expression currentExpression = expressions[i]; |
145 |
scope.problemReporter().annotationValueMustBeClassLiteral(this.binding.declaringClass, this.name, expressions[i]); |
147 |
if (!(currentExpression instanceof ClassLiteralAccess)) { |
|
|
148 |
scope.problemReporter().annotationValueMustBeClassLiteral(this.binding.declaringClass, this.name, currentExpression); |
146 |
} |
149 |
} |
147 |
} |
150 |
} |
148 |
} |
151 |
} |
Lines 153-160
Link Here
|
153 |
} |
156 |
} |
154 |
if (leafType.isEnum()) { |
157 |
if (leafType.isEnum()) { |
155 |
if (this.value instanceof NullLiteral) { |
158 |
if (this.value instanceof NullLiteral) { |
156 |
// TODO (olivier) change message for annotation value must be an *enum* constant |
|
|
157 |
scope.problemReporter().annotationValueMustBeConstant(this.binding.declaringClass, this.name, this.value); |
159 |
scope.problemReporter().annotationValueMustBeConstant(this.binding.declaringClass, this.name, this.value); |
|
|
160 |
} else if (this.value instanceof ArrayInitializer) { |
161 |
ArrayInitializer initializer = (ArrayInitializer) this.value; |
162 |
final Expression[] expressions = initializer.expressions; |
163 |
if (expressions != null) { |
164 |
for (int i =0, max = expressions.length; i < max; i++) { |
165 |
Expression currentExpression = expressions[i]; |
166 |
if (currentExpression instanceof NullLiteral) { |
167 |
scope.problemReporter().annotationValueMustBeConstant(this.binding.declaringClass, this.name, currentExpression); |
168 |
} else if (currentExpression instanceof NameReference) { |
169 |
NameReference nameReference = (NameReference) currentExpression; |
170 |
final Binding nameReferenceBinding = nameReference.binding; |
171 |
if (nameReferenceBinding.kind() == Binding.FIELD) { |
172 |
FieldBinding fieldBinding = (FieldBinding) nameReferenceBinding; |
173 |
if (!fieldBinding.declaringClass.isEnum()) { |
174 |
scope.problemReporter().annotationValueMustBeConstant(this.binding.declaringClass, this.name, currentExpression); |
175 |
} |
176 |
} |
177 |
} |
178 |
} |
179 |
} |
180 |
} else if (this.value instanceof NameReference) { |
181 |
NameReference nameReference = (NameReference) this.value; |
182 |
final Binding nameReferenceBinding = nameReference.binding; |
183 |
if (nameReferenceBinding.kind() == Binding.FIELD) { |
184 |
FieldBinding fieldBinding = (FieldBinding) nameReferenceBinding; |
185 |
if (!fieldBinding.declaringClass.isEnum()) { |
186 |
scope.problemReporter().annotationValueMustBeConstant(this.binding.declaringClass, this.name, this.value); |
187 |
} |
188 |
} |
158 |
} |
189 |
} |
159 |
break checkAnnotationMethodType; |
190 |
break checkAnnotationMethodType; |
160 |
} |
191 |
} |