3ebd595eba798d332825fd010f0ffde1292cbc23
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / ast / SingleTypeReference.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.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.ReferenceBinding;
17 import net.sourceforge.phpdt.internal.compiler.lookup.Scope;
18 import net.sourceforge.phpdt.internal.compiler.lookup.TypeBinding;
19
20 public class SingleTypeReference extends TypeReference {
21         public char[] token;
22         
23
24 public SingleTypeReference(char[] source, long pos) {
25                 token = source;
26                 sourceStart = (int) (pos>>>32)  ;
27                 sourceEnd = (int) (pos & 0x00000000FFFFFFFFL) ;
28         
29 }
30 public SingleTypeReference(char[] source ,TypeBinding type, long pos) {
31         this(source, pos) ;
32         this.resolvedType = type ;
33 }
34 public TypeReference copyDims(int dim){
35         //return a type reference copy of me with some dimensions
36         //warning : the new type ref has a null binding
37         
38         return new ArrayTypeReference(token,null,dim,(((long)sourceStart)<<32)+sourceEnd) ;
39 }
40 public TypeBinding getTypeBinding(Scope scope) {
41         if (this.resolvedType != null)
42                 return this.resolvedType;
43         return scope.getType(token);
44 }
45 public char [][] getTypeName() {
46         return new char[][] { token };
47 }
48 public TypeBinding resolveTypeEnclosing(BlockScope scope, ReferenceBinding enclosingType) {
49         ReferenceBinding memberTb = scope.getMemberType(token, enclosingType);
50         if (!memberTb.isValidBinding()) {
51                 scope.problemReporter().invalidEnclosingType(this, memberTb, enclosingType);
52                 return null;
53         }
54         if (isTypeUseDeprecated(memberTb, scope))
55                 scope.problemReporter().deprecatedType(memberTb, this);
56         return this.resolvedType = memberTb;
57 }
58 public StringBuffer printExpression(int indent, StringBuffer output){
59         
60         return output.append(token);
61 }
62 public String toStringExpression(int tab){
63         return new String(token) ;
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 }