first scanner /parser copied from the jdt java version
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / ast / ArrayQualifiedTypeReference.java
1 /*******************************************************************************
2  * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
3  * All rights reserved. This program and the accompanying materials 
4  * are made available under the terms of the Common Public License v0.5 
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v05.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.*;
15
16 public class ArrayQualifiedTypeReference extends QualifiedTypeReference {
17         int dimensions;
18 public ArrayQualifiedTypeReference(char[][] sources , int dim, long[] poss) {
19         super( sources , poss);
20         dimensions = dim ;
21 }
22 public ArrayQualifiedTypeReference(char[][] sources , TypeBinding tb, int dim, long[] poss) {
23         super( sources , tb, poss);
24         dimensions = dim ;
25 }
26 public int dimensions() {
27         return dimensions;
28 }
29 public TypeBinding getTypeBinding(Scope scope) {
30         if (binding != null)
31                 return binding;
32         return scope.createArray(scope.getType(tokens), dimensions);
33 }
34 public String toStringExpression(int tab){
35         /* slow speed */
36
37         String s = super.toStringExpression(tab)  ;
38         if (dimensions == 1 ) return s + "[]" ; //$NON-NLS-1$
39         for (int i=1 ; i <= dimensions ; i++)
40                 s = s + "[]" ; //$NON-NLS-1$
41         return s ;
42 }
43 public void traverse(IAbstractSyntaxTreeVisitor visitor, BlockScope scope) {
44         visitor.visit(this, scope);
45         visitor.endVisit(this, scope);
46 }
47 public void traverse(IAbstractSyntaxTreeVisitor visitor, ClassScope scope) {
48         visitor.visit(this, scope);
49         visitor.endVisit(this, scope);
50 }
51 }