added -J option to preserve unmodified files in preexisting jarfile
[org.ibex.tool.git] / src / org / eclipse / jdt / internal / compiler / ast / SingleTypeReference.java
1 /*******************************************************************************
2  * Copyright (c) 2000, 2004 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 org.eclipse.jdt.internal.compiler.ast;
12
13 import org.eclipse.jdt.internal.compiler.ASTVisitor;
14 import org.eclipse.jdt.internal.compiler.lookup.*;
15
16 public class SingleTypeReference extends TypeReference {
17
18         public char[] token;
19
20         public SingleTypeReference(char[] source, long pos) {
21
22                         token = source;
23                         sourceStart = (int) (pos>>>32)  ;
24                         sourceEnd = (int) (pos & 0x00000000FFFFFFFFL) ;
25                 
26         }
27
28         public TypeReference copyDims(int dim){
29                 //return a type reference copy of me with some dimensions
30                 //warning : the new type ref has a null binding
31                 
32                 return new ArrayTypeReference(token, dim,(((long)sourceStart)<<32)+sourceEnd);
33         }
34
35         protected TypeBinding getTypeBinding(Scope scope) {
36                 if (this.resolvedType != null)
37                         return this.resolvedType;
38
39                 this.resolvedType = scope.getType(token);
40
41                 if (scope.kind == Scope.CLASS_SCOPE && this.resolvedType.isValidBinding())
42                         if (((ClassScope) scope).detectHierarchyCycle(this.resolvedType, this, null))
43                                 return null;
44                 return this.resolvedType;
45         }
46
47         public char [][] getTypeName() {
48                 return new char[][] { token };
49         }
50
51         public StringBuffer printExpression(int indent, StringBuffer output){
52                 
53                 return output.append(token);
54         }
55
56         public TypeBinding resolveTypeEnclosing(BlockScope scope, ReferenceBinding enclosingType) {
57
58                 ReferenceBinding memberType = scope.getMemberType(token, enclosingType);
59                 if (!memberType.isValidBinding()) {
60                         this.resolvedType = memberType;
61                         scope.problemReporter().invalidEnclosingType(this, memberType, enclosingType);
62                         return null;
63                 }
64                 if (isTypeUseDeprecated(memberType, scope))
65                         scope.problemReporter().deprecatedType(memberType, this);
66                 return this.resolvedType = scope.convertToRawType(memberType);
67         }
68
69         public void traverse(ASTVisitor visitor, BlockScope scope) {
70                 visitor.visit(this, scope);
71                 visitor.endVisit(this, scope);
72         }
73
74         public void traverse(ASTVisitor visitor, ClassScope scope) {
75                 visitor.visit(this, scope);
76                 visitor.endVisit(this, scope);
77         }
78 }