A massive organize imports and formatting of the sources using default Eclipse code...
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / ast / ArrayQualifiedTypeReference.java
1 /*******************************************************************************
2  * Copyright (c) 2000, 2003 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 net.sourceforge.phpdt.internal.compiler.ast;
12
13 import net.sourceforge.phpdt.internal.compiler.IAbstractSyntaxTreeVisitor;
14 import net.sourceforge.phpdt.internal.compiler.lookup.BlockScope;
15 import net.sourceforge.phpdt.internal.compiler.lookup.ClassScope;
16 import net.sourceforge.phpdt.internal.compiler.lookup.Scope;
17 import net.sourceforge.phpdt.internal.compiler.lookup.TypeBinding;
18
19 public class ArrayQualifiedTypeReference extends QualifiedTypeReference {
20         int dimensions;
21
22         public ArrayQualifiedTypeReference(char[][] sources, int dim, long[] poss) {
23                 super(sources, poss);
24                 dimensions = dim;
25         }
26
27         public ArrayQualifiedTypeReference(char[][] sources, TypeBinding tb,
28                         int dim, long[] poss) {
29                 super(sources, tb, poss);
30                 dimensions = dim;
31         }
32
33         public int dimensions() {
34                 return dimensions;
35         }
36
37         public TypeBinding getTypeBinding(Scope scope) {
38                 if (this.resolvedType != null)
39                         return this.resolvedType;
40                 if (dimensions > 255) {
41                         scope.problemReporter().tooManyDimensions(this);
42                 }
43                 return scope.createArray(scope.getType(tokens), dimensions);
44         }
45
46         public String toStringExpression(int tab) {
47                 /* slow speed */
48
49                 String s = super.toStringExpression(tab);
50                 if (dimensions == 1)
51                         return s + "[]"; //$NON-NLS-1$
52                 for (int i = 1; i <= dimensions; i++)
53                         s = s + "[]"; //$NON-NLS-1$
54                 return s;
55         }
56
57         public void traverse(IAbstractSyntaxTreeVisitor visitor, BlockScope scope) {
58                 visitor.visit(this, scope);
59                 visitor.endVisit(this, scope);
60         }
61
62         public void traverse(IAbstractSyntaxTreeVisitor visitor, ClassScope scope) {
63                 visitor.visit(this, scope);
64                 visitor.endVisit(this, scope);
65         }
66 }