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.ClassScope; 16 import org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope; 17 18 /** 19 * SingleMemberAnnotation node 20 */ 21 public class SingleMemberAnnotation extends Annotation { 22 public Expression memberValue; 23 SingleMemberAnnotation(char[][] tokens, long[] sourcePositions, int sourceStart)24 public SingleMemberAnnotation(char[][] tokens, long[] sourcePositions, int sourceStart) { 25 this.tokens = tokens; 26 this.sourcePositions = sourcePositions; 27 this.sourceStart = sourceStart; 28 this.sourceEnd = (int) sourcePositions[sourcePositions.length - 1]; 29 } 30 SingleMemberAnnotation(char[] token, long sourcePosition, int sourceStart)31 public SingleMemberAnnotation(char[] token, long sourcePosition, int sourceStart) { 32 this.tokens = new char[][] { token }; 33 this.sourcePositions = new long[] { sourcePosition }; 34 this.sourceStart = sourceStart; 35 this.sourceEnd = (int) sourcePosition; 36 } 37 printExpression(int indent, StringBuffer output)38 public StringBuffer printExpression(int indent, StringBuffer output) { 39 super.printExpression(indent, output); 40 output.append('('); 41 this.memberValue.printExpression(indent, output); 42 return output.append(')'); 43 } 44 traverse(ASTVisitor visitor, BlockScope scope)45 public void traverse(ASTVisitor visitor, BlockScope scope) { 46 if (visitor.visit(this, scope)) { 47 if (this.memberValue != null) { 48 this.memberValue.traverse(visitor, scope); 49 } 50 } 51 visitor.endVisit(this, scope); 52 } traverse(ASTVisitor visitor, ClassScope scope)53 public void traverse(ASTVisitor visitor, ClassScope scope) { 54 if (visitor.visit(this, scope)) { 55 if (this.memberValue != null) { 56 this.memberValue.traverse(visitor, scope); 57 } 58 } 59 visitor.endVisit(this, scope); 60 } traverse(ASTVisitor visitor, CompilationUnitScope scope)61 public void traverse(ASTVisitor visitor, CompilationUnitScope scope) { 62 if (visitor.visit(this, scope)) { 63 if (this.memberValue != null) { 64 this.memberValue.traverse(visitor, scope); 65 } 66 } 67 visitor.endVisit(this, scope); 68 } 69 } 70