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
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package org.eclipse.jdt.internal.compiler.ast;
13 import org.eclipse.jdt.core.compiler.CharOperation;
14 import org.eclipse.jdt.internal.compiler.ASTVisitor;
15 import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
16 import org.eclipse.jdt.internal.compiler.lookup.ClassScope;
17 import org.eclipse.jdt.internal.compiler.lookup.Scope;
18 import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
20 public class ArrayTypeReference extends SingleTypeReference {
21 public int dimensions;
22 public int originalSourceEnd;
25 * ArrayTypeReference constructor comment.
26 * @param source char[]
27 * @param dimensions int
30 public ArrayTypeReference(char[] source, int dimensions, long pos) {
33 this.originalSourceEnd = this.sourceEnd;
34 this.dimensions = dimensions ;
37 public int dimensions() {
44 public char [][] getParameterizedTypeName(){
45 int dim = this.dimensions;
46 char[] dimChars = new char[dim*2];
47 for (int i = 0; i < dim; i++) {
49 dimChars[index] = '[';
50 dimChars[index+1] = ']';
52 return new char[][]{ CharOperation.concat(token, dimChars) };
54 protected TypeBinding getTypeBinding(Scope scope) {
56 if (this.resolvedType != null) return this.resolvedType;
57 if (dimensions > 255) {
58 scope.problemReporter().tooManyDimensions(this);
60 TypeBinding leafComponentType = scope.getType(token);
61 return scope.createArrayType(leafComponentType, dimensions);
65 public StringBuffer printExpression(int indent, StringBuffer output){
67 super.printExpression(indent, output);
68 if ((this.bits & IsVarArgs) != 0) {
69 for (int i= 0 ; i < dimensions - 1; i++) {
70 output.append("[]"); //$NON-NLS-1$
72 output.append("..."); //$NON-NLS-1$
74 for (int i= 0 ; i < dimensions; i++) {
75 output.append("[]"); //$NON-NLS-1$
81 public void traverse(ASTVisitor visitor, BlockScope scope) {
83 visitor.visit(this, scope);
84 visitor.endVisit(this, scope);
87 public void traverse(ASTVisitor visitor, ClassScope scope) {
89 visitor.visit(this, scope);
90 visitor.endVisit(this, scope);