01: /*******************************************************************************
02: * Copyright (c) 2000, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.jdt.internal.compiler.lookup;
11:
12: public class UnresolvedAnnotationBinding extends AnnotationBinding {
13: private LookupEnvironment env;
14: private boolean typeUnresolved = true;
15:
16: UnresolvedAnnotationBinding(ReferenceBinding type,
17: ElementValuePair[] pairs, LookupEnvironment env) {
18: super (type, pairs);
19: this .env = env;
20: }
21:
22: public ReferenceBinding getAnnotationType() {
23: if (this .typeUnresolved) { // the type is resolved when requested
24: this .type = BinaryTypeBinding.resolveType(this .type,
25: this .env, false);
26: // annotation type are never parameterized
27: this .typeUnresolved = false;
28: }
29: return this .type;
30: }
31:
32: public ElementValuePair[] getElementValuePairs() {
33: if (this .env != null) {
34: if (this .typeUnresolved) {
35: getAnnotationType(); // resolve the annotation type
36: }
37: // resolve method binding and value type (if unresolved) for each pair
38: for (int i = this .pairs.length; --i >= 0;) {
39: ElementValuePair pair = this .pairs[i];
40: MethodBinding[] methods = this .type.getMethods(pair
41: .getName());
42: // there should be exactly one since the type is an annotation type.
43: if (methods != null && methods.length == 1) {
44: pair.setMethodBinding(methods[0]);
45: } // else silently leave a null there
46: Object value = pair.getValue();
47: if (value instanceof UnresolvedReferenceBinding) {
48: pair.setValue(((UnresolvedReferenceBinding) value)
49: .resolve(this .env, false));
50: // no parameterized types in annotation values
51: } // do nothing for UnresolvedAnnotationBinding-s, since their
52: // content is only accessed through get* methods
53: }
54: this.env = null;
55: }
56: return this.pairs;
57: }
58: }
|