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.*;
16 import org.eclipse.jdt.internal.compiler.problem.AbortCompilation;
18 public class ArrayQualifiedTypeReference extends QualifiedTypeReference {
21 public ArrayQualifiedTypeReference(char[][] sources , int dim, long[] poss) {
23 super( sources , poss);
27 public int dimensions() {
35 public char [][] getParameterizedTypeName(){
36 int dim = this.dimensions;
37 char[] dimChars = new char[dim*2];
38 for (int i = 0; i < dim; i++) {
40 dimChars[index] = '[';
41 dimChars[index+1] = ']';
43 int length = this.tokens.length;
44 char[][] qParamName = new char[length][];
45 System.arraycopy(this.tokens, 0, qParamName, 0, length-1);
46 qParamName[length-1] = CharOperation.concat(this.tokens[length-1], dimChars);
50 protected TypeBinding getTypeBinding(Scope scope) {
52 if (this.resolvedType != null)
53 return this.resolvedType;
54 if (dimensions > 255) {
55 scope.problemReporter().tooManyDimensions(this);
58 TypeBinding leafComponentType = scope.getType(this.tokens, this.tokens.length);
59 return scope.createArrayType(leafComponentType, dimensions);
60 } catch (AbortCompilation e) {
61 e.updateContext(this, scope.referenceCompilationUnit().compilationResult);
66 public StringBuffer printExpression(int indent, StringBuffer output){
68 super.printExpression(indent, output);
69 if ((this.bits & IsVarArgs) != 0) {
70 for (int i= 0 ; i < dimensions - 1; i++) {
71 output.append("[]"); //$NON-NLS-1$
73 output.append("..."); //$NON-NLS-1$
75 for (int i= 0 ; i < dimensions; i++) {
76 output.append("[]"); //$NON-NLS-1$
82 public void traverse(ASTVisitor visitor, BlockScope scope) {
84 visitor.visit(this, scope);
85 visitor.endVisit(this, scope);
88 public void traverse(ASTVisitor visitor, ClassScope scope) {
90 visitor.visit(this, scope);
91 visitor.endVisit(this, scope);