Committing missing change or PHPFileUtil
[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 import org.eclipse.core.resources.IFile;
21
22 public class SingleTypeReference extends TypeReference {
23         public char[] token;
24         public IFile file;
25
26         public SingleTypeReference(IFile f, char[] source, int start, int end) {
27                 token = source;
28                 file = f;
29                 sourceStart = start;
30                 sourceEnd = end;
31
32 }
33 public SingleTypeReference(char[] source, long pos) {
34                 token = source;
35                 file = null;
36                 sourceStart = (int) (pos>>>32)  ;
37                 sourceEnd = (int) (pos & 0x00000000FFFFFFFFL) ;
38
39 }
40 public SingleTypeReference(char[] source ,TypeBinding type, long pos) {
41         this(source, pos) ;
42         this.resolvedType = type ;
43 }
44 public TypeReference copyDims(int dim){
45         //return a type reference copy of me with some dimensions
46         //warning : the new type ref has a null binding
47
48         return new ArrayTypeReference(token,null,dim,(((long)sourceStart)<<32)+sourceEnd) ;
49 }
50 public TypeBinding getTypeBinding(Scope scope) {
51         if (this.resolvedType != null)
52                 return this.resolvedType;
53         return scope.getType(token);
54 }
55 public char [][] getTypeName() {
56         return new char[][] { token };
57 }
58 public TypeBinding resolveTypeEnclosing(BlockScope scope, ReferenceBinding enclosingType) {
59         ReferenceBinding memberTb = scope.getMemberType(token, enclosingType);
60         if (!memberTb.isValidBinding()) {
61                 scope.problemReporter().invalidEnclosingType(this, memberTb, enclosingType);
62                 return null;
63         }
64         if (isTypeUseDeprecated(memberTb, scope))
65                 scope.problemReporter().deprecatedType(memberTb, this);
66         return this.resolvedType = memberTb;
67 }
68 public StringBuffer printExpression(int indent, StringBuffer output){
69
70         return output.append(token);
71 }
72 public String toStringExpression(int tab){
73         return new String(token) ;
74 }
75 public void traverse(ASTVisitor visitor, BlockScope scope) {
76         visitor.visit(this, scope);
77         visitor.endVisit(this, scope);
78 }
79 public void traverse(ASTVisitor visitor, ClassScope scope) {
80         visitor.visit(this, scope);
81         visitor.endVisit(this, scope);
82 }
83 }