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.ast;
11:
12: import org.eclipse.jdt.internal.compiler.ASTVisitor;
13: import org.eclipse.jdt.internal.compiler.lookup.*;
14:
15: /**
16: * Normal annotation node
17: */
18: public class NormalAnnotation extends Annotation {
19:
20: public MemberValuePair[] memberValuePairs;
21:
22: public NormalAnnotation(TypeReference type, int sourceStart) {
23: this .type = type;
24: this .sourceStart = sourceStart;
25: this .sourceEnd = type.sourceEnd;
26: }
27:
28: public ElementValuePair[] computeElementValuePairs() {
29: int numberOfPairs = this .memberValuePairs == null ? 0
30: : this .memberValuePairs.length;
31: if (numberOfPairs == 0)
32: return Binding.NO_ELEMENT_VALUE_PAIRS;
33:
34: ElementValuePair[] pairs = new ElementValuePair[numberOfPairs];
35: for (int i = 0; i < numberOfPairs; i++)
36: pairs[i] = this .memberValuePairs[i].compilerElementPair;
37: return pairs;
38: }
39:
40: /**
41: * @see org.eclipse.jdt.internal.compiler.ast.Annotation#memberValuePairs()
42: */
43: public MemberValuePair[] memberValuePairs() {
44: return this .memberValuePairs == null ? NoValuePairs
45: : this .memberValuePairs;
46: }
47:
48: public StringBuffer printExpression(int indent, StringBuffer output) {
49: super .printExpression(indent, output);
50: output.append('(');
51: if (this .memberValuePairs != null) {
52: for (int i = 0, max = this .memberValuePairs.length; i < max; i++) {
53: if (i > 0) {
54: output.append(',');
55: }
56: this .memberValuePairs[i].print(indent, output);
57: }
58: }
59: output.append(')');
60: return output;
61: }
62:
63: public void traverse(ASTVisitor visitor, BlockScope scope) {
64: if (visitor.visit(this , scope)) {
65: if (this .memberValuePairs != null) {
66: int memberValuePairsLength = this .memberValuePairs.length;
67: for (int i = 0; i < memberValuePairsLength; i++)
68: this.memberValuePairs[i].traverse(visitor, scope);
69: }
70: }
71: visitor.endVisit(this, scope);
72: }
73: }
|