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