KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > compiler > ast > SingleTypeReference


1 /*******************************************************************************
2  * Copyright (c) 2000, 2007 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jdt.internal.compiler.ast;
12
13 import org.eclipse.jdt.internal.compiler.ASTVisitor;
14 import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
15 import org.eclipse.jdt.internal.compiler.lookup.*;
16 import org.eclipse.jdt.internal.compiler.problem.ProblemSeverities;
17
18 public class SingleTypeReference extends TypeReference {
19
20     public char[] token;
21
22     public SingleTypeReference(char[] source, long pos) {
23
24             token = source;
25             sourceStart = (int) (pos>>>32) ;
26             sourceEnd = (int) (pos & 0x00000000FFFFFFFFL) ;
27         
28     }
29
30     public TypeReference copyDims(int dim){
31         //return a type reference copy of me with some dimensions
32
//warning : the new type ref has a null binding
33

34         return new ArrayTypeReference(token, dim,(((long)sourceStart)<<32)+sourceEnd);
35     }
36
37     public char[] getLastToken() {
38         return this.token;
39     }
40     protected TypeBinding getTypeBinding(Scope scope) {
41         if (this.resolvedType != null)
42             return this.resolvedType;
43
44         this.resolvedType = scope.getType(token);
45
46         if (scope.kind == Scope.CLASS_SCOPE && this.resolvedType.isValidBinding())
47             if (((ClassScope) scope).detectHierarchyCycle(this.resolvedType, this))
48                 return null;
49         return this.resolvedType;
50     }
51
52     public char [][] getTypeName() {
53         return new char[][] { token };
54     }
55
56     public StringBuffer JavaDoc printExpression(int indent, StringBuffer JavaDoc output){
57         
58         return output.append(token);
59     }
60
61     public TypeBinding resolveTypeEnclosing(BlockScope scope, ReferenceBinding enclosingType) {
62
63         TypeBinding memberType = scope.getMemberType(token, enclosingType);
64         if (!memberType.isValidBinding()) {
65             this.resolvedType = memberType;
66             scope.problemReporter().invalidEnclosingType(this, memberType, enclosingType);
67             return null;
68         }
69         if (isTypeUseDeprecated(memberType, scope))
70             scope.problemReporter().deprecatedType(memberType, this);
71         memberType = scope.environment().convertToRawType(memberType);
72         if (memberType.isRawType()
73                 && (this.bits & IgnoreRawTypeCheck) == 0
74                 && scope.compilerOptions().getSeverity(CompilerOptions.RawTypeReference) != ProblemSeverities.Ignore){
75             scope.problemReporter().rawTypeReference(this, memberType);
76         }
77         return this.resolvedType = memberType;
78     }
79
80     public void traverse(ASTVisitor visitor, BlockScope scope) {
81         visitor.visit(this, scope);
82         visitor.endVisit(this, scope);
83     }
84
85     public void traverse(ASTVisitor visitor, ClassScope scope) {
86         visitor.visit(this, scope);
87         visitor.endVisit(this, scope);
88     }
89 }
90
Popular Tags