A massive organize imports and formatting of the sources using default Eclipse code...
[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
25         public IFile file;
26
27         public SingleTypeReference(IFile f, char[] source, int start, int end) {
28                 token = source;
29                 file = f;
30                 sourceStart = start;
31                 sourceEnd = end;
32
33         }
34
35         public SingleTypeReference(char[] source, long pos) {
36                 token = source;
37                 file = null;
38                 sourceStart = (int) (pos >>> 32);
39                 sourceEnd = (int) (pos & 0x00000000FFFFFFFFL);
40
41         }
42
43         public SingleTypeReference(char[] source, TypeBinding type, long pos) {
44                 this(source, pos);
45                 this.resolvedType = type;
46         }
47
48         public TypeReference copyDims(int dim) {
49                 // return a type reference copy of me with some dimensions
50                 // warning : the new type ref has a null binding
51
52                 return new ArrayTypeReference(token, null, dim,
53                                 (((long) sourceStart) << 32) + sourceEnd);
54         }
55
56         public TypeBinding getTypeBinding(Scope scope) {
57                 if (this.resolvedType != null)
58                         return this.resolvedType;
59                 return scope.getType(token);
60         }
61
62         public char[][] getTypeName() {
63                 return new char[][] { token };
64         }
65
66         public TypeBinding resolveTypeEnclosing(BlockScope scope,
67                         ReferenceBinding enclosingType) {
68                 ReferenceBinding memberTb = scope.getMemberType(token, enclosingType);
69                 if (!memberTb.isValidBinding()) {
70                         scope.problemReporter().invalidEnclosingType(this, memberTb,
71                                         enclosingType);
72                         return null;
73                 }
74                 if (isTypeUseDeprecated(memberTb, scope))
75                         scope.problemReporter().deprecatedType(memberTb, this);
76                 return this.resolvedType = memberTb;
77         }
78
79         public StringBuffer printExpression(int indent, StringBuffer output) {
80
81                 return output.append(token);
82         }
83
84         public String toStringExpression(int tab) {
85                 return new String(token);
86         }
87
88         public void traverse(ASTVisitor visitor, BlockScope scope) {
89                 visitor.visit(this, scope);
90                 visitor.endVisit(this, scope);
91         }
92
93         public void traverse(ASTVisitor visitor, ClassScope scope) {
94                 visitor.visit(this, scope);
95                 visitor.endVisit(this, scope);
96         }
97 }