KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > compiler > ast > SingleMemberAnnotation


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-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.*;
15
16 /**
17  * SingleMemberAnnotation node
18  */

19 public class SingleMemberAnnotation extends Annotation {
20     
21     public Expression memberValue;
22     private MemberValuePair[] singlePairs; // fake pair set, only value has accurate positions
23

24     public SingleMemberAnnotation(TypeReference type, int sourceStart) {
25         this.type = type;
26         this.sourceStart = sourceStart;
27         this.sourceEnd = type.sourceEnd;
28     }
29
30     public ElementValuePair[] computeElementValuePairs() {
31         return new ElementValuePair[] {memberValuePairs()[0].compilerElementPair};
32     }
33
34     /**
35      * @see org.eclipse.jdt.internal.compiler.ast.Annotation#memberValuePairs()
36      */

37     public MemberValuePair[] memberValuePairs() {
38         if (this.singlePairs == null) {
39             this.singlePairs =
40                 new MemberValuePair[]{
41                     new MemberValuePair(VALUE, this.memberValue.sourceStart, this.memberValue.sourceEnd, this.memberValue)
42                 };
43         }
44         return this.singlePairs;
45     }
46     
47     public StringBuffer JavaDoc printExpression(int indent, StringBuffer JavaDoc output) {
48         super.printExpression(indent, output);
49         output.append('(');
50         this.memberValue.printExpression(indent, output);
51         return output.append(')');
52     }
53     
54     public void traverse(ASTVisitor visitor, BlockScope 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 }
63
Popular Tags