*** empty log message ***
[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.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 tb , long[] poss) {
29         this(sources,poss);
30         binding = tb;
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 (binding != null)
40                 return binding;
41         return scope.getType(tokens);
42 }
43 public char[][] getTypeName(){
44
45         return tokens;
46 }
47 public String toStringExpression(int tab) {
48         StringBuffer buffer = new StringBuffer();
49         for (int i = 0; i < tokens.length; i++) {
50                 buffer.append(tokens[i]);
51                 if (i < (tokens.length - 1)) {
52                         buffer.append("."); //$NON-NLS-1$
53                 }
54         }
55         return buffer.toString();
56 }
57 public void traverse(IAbstractSyntaxTreeVisitor visitor, BlockScope scope) {
58         visitor.visit(this, scope);
59         visitor.endVisit(this, scope);
60 }
61 public void traverse(IAbstractSyntaxTreeVisitor visitor, ClassScope scope) {
62         visitor.visit(this, scope);
63         visitor.endVisit(this, scope);
64 }
65 }