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: * SingleMemberAnnotation node
17: */
18: public class SingleMemberAnnotation extends Annotation {
19:
20: public Expression memberValue;
21: private MemberValuePair[] singlePairs; // fake pair set, only value has accurate positions
22:
23: public SingleMemberAnnotation(TypeReference type, int sourceStart) {
24: this .type = type;
25: this .sourceStart = sourceStart;
26: this .sourceEnd = type.sourceEnd;
27: }
28:
29: public ElementValuePair[] computeElementValuePairs() {
30: return new ElementValuePair[] { memberValuePairs()[0].compilerElementPair };
31: }
32:
33: /**
34: * @see org.eclipse.jdt.internal.compiler.ast.Annotation#memberValuePairs()
35: */
36: public MemberValuePair[] memberValuePairs() {
37: if (this .singlePairs == null) {
38: this .singlePairs = new MemberValuePair[] { new MemberValuePair(
39: VALUE, this .memberValue.sourceStart,
40: this .memberValue.sourceEnd, this .memberValue) };
41: }
42: return this .singlePairs;
43: }
44:
45: public StringBuffer printExpression(int indent, StringBuffer output) {
46: super .printExpression(indent, output);
47: output.append('(');
48: this .memberValue.printExpression(indent, output);
49: return output.append(')');
50: }
51:
52: public void traverse(ASTVisitor visitor, BlockScope scope) {
53: if (visitor.visit(this, scope)) {
54: if (this.memberValue != null) {
55: this.memberValue.traverse(visitor, scope);
56: }
57: }
58: visitor.endVisit(this, scope);
59: }
60: }
|