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
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package net.sourceforge.phpdt.internal.compiler.ast;
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;
20 import org.eclipse.core.resources.IFile;
22 public class SingleTypeReference extends TypeReference {
27 public SingleTypeReference(IFile f, char[] source, int start, int end) {
35 public SingleTypeReference(char[] source, long pos) {
38 sourceStart = (int) (pos >>> 32);
39 sourceEnd = (int) (pos & 0x00000000FFFFFFFFL);
43 public SingleTypeReference(char[] source, TypeBinding type, long pos) {
45 this.resolvedType = type;
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
52 return new ArrayTypeReference(token, null, dim,
53 (((long) sourceStart) << 32) + sourceEnd);
56 public TypeBinding getTypeBinding(Scope scope) {
57 if (this.resolvedType != null)
58 return this.resolvedType;
59 return scope.getType(token);
62 public char[][] getTypeName() {
63 return new char[][] { token };
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,
74 if (isTypeUseDeprecated(memberTb, scope))
75 scope.problemReporter().deprecatedType(memberTb, this);
76 return this.resolvedType = memberTb;
79 public StringBuffer printExpression(int indent, StringBuffer output) {
81 return output.append(token);
84 public String toStringExpression(int tab) {
85 return new String(token);
88 public void traverse(ASTVisitor visitor, BlockScope scope) {
89 visitor.visit(this, scope);
90 visitor.endVisit(this, scope);
93 public void traverse(ASTVisitor visitor, ClassScope scope) {
94 visitor.visit(this, scope);
95 visitor.endVisit(this, scope);