improved PHP parser
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / internal / compiler / ast / QualifiedTypeReference.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.phpeclipse.internal.compiler.ast;
12
13 import net.sourceforge.phpdt.internal.compiler.ASTVisitor;
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 QualifiedTypeReference extends TypeReference {
20         public char[][] tokens;
21         public long[] sourcePositions;
22 public QualifiedTypeReference(char[][] sources , long[] poss) {
23         tokens = sources ;
24         sourcePositions = poss ;
25         sourceStart = (int) (sourcePositions[0]>>>32) ;
26         sourceEnd = (int)(sourcePositions[sourcePositions.length-1] & 0x00000000FFFFFFFFL ) ;
27 }
28 public QualifiedTypeReference(char[][] sources , TypeBinding type , long[] poss) {
29         this(sources,poss);
30         this.resolvedType = type;
31 }
32 public TypeReference copyDims(int dim){
33         //return a type reference copy of me with some dimensions
34         //warning : the new type ref has a null binding
35         
36         return new ArrayQualifiedTypeReference(tokens,null,dim,sourcePositions) ;
37 }
38 public TypeBinding getTypeBinding(Scope scope) {
39         if (this.resolvedType != null)
40                 return this.resolvedType;
41         return scope.getType(tokens);
42 }
43 public char[][] getTypeName(){
44
45         return tokens;
46 }
47 public StringBuffer printExpression(int indent, StringBuffer output) {
48         
49         for (int i = 0; i < tokens.length; i++) {
50                 if (i > 0) output.append('.');
51                 output.append(tokens[i]);
52         }
53         return output;
54 }
55 public String toStringExpression(int tab) {
56         StringBuffer buffer = new StringBuffer();
57         for (int i = 0; i < tokens.length; i++) {
58                 buffer.append(tokens[i]);
59                 if (i < (tokens.length - 1)) {
60                         buffer.append("."); //$NON-NLS-1$
61                 }
62         }
63         return buffer.toString();
64 }
65 public void traverse(ASTVisitor visitor, BlockScope scope) {
66         visitor.visit(this, scope);
67         visitor.endVisit(this, scope);
68 }
69 public void traverse(ASTVisitor visitor, ClassScope scope) {
70         visitor.visit(this, scope);
71         visitor.endVisit(this, scope);
72 }
73 }