ff9881f28776a3ecb5eb3212e701c4d5ca177ceb
[org.ibex.tool.git] / src / org / eclipse / jdt / internal / compiler / ast / SingleMemberAnnotation.java
1 /*******************************************************************************
2  * Copyright (c) 2000, 2004 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials 
4  * are made available under the terms of the Common Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v10.html
7  * 
8  * Contributors:
9  *     IBM Corporation - initial API and implementation
10  *******************************************************************************/
11 package org.eclipse.jdt.internal.compiler.ast;
12
13 import org.eclipse.jdt.internal.compiler.ASTVisitor;
14 import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
15 import org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope;
16
17 /**
18  * SingleMemberAnnotation node
19  */
20 public class SingleMemberAnnotation extends Annotation {
21         
22         public Expression memberValue;
23         public MemberValuePair singlePair; // fake pair, only value has accurate positions
24
25         public SingleMemberAnnotation(TypeReference type, int sourceStart) {
26                 this.type = type;
27                 this.sourceStart = sourceStart;
28                 this.sourceEnd = type.sourceEnd;
29         }
30         
31         /**
32          * @see org.eclipse.jdt.internal.compiler.ast.Annotation#memberValuePairs()
33          */
34         public MemberValuePair[] memberValuePairs() {
35                 this.singlePair =  new MemberValuePair(VALUE, this.memberValue.sourceStart, this.memberValue.sourceEnd, this.memberValue);
36                 return new MemberValuePair[] { singlePair };
37         }
38         
39         public StringBuffer printExpression(int indent, StringBuffer output) {
40                 super.printExpression(indent, output);
41                 output.append('(');
42                 this.memberValue.printExpression(indent, output);
43                 return output.append(')');
44         }
45         
46         public void traverse(ASTVisitor visitor, BlockScope scope) {
47                 if (visitor.visit(this, scope)) {
48                         if (this.memberValue != null) {
49                                 this.memberValue.traverse(visitor, scope);
50                         }
51                 }
52                 visitor.endVisit(this, scope);
53         }
54         public void traverse(ASTVisitor visitor, CompilationUnitScope scope) {
55                 if (visitor.visit(this, scope)) {
56                         if (this.memberValue != null) {
57                                 this.memberValue.traverse(visitor, scope);
58                         }
59                 }
60                 visitor.endVisit(this, scope);
61         }
62 }