added -J option to preserve unmodified files in preexisting jarfile
[org.ibex.tool.git] / src / org / eclipse / jdt / internal / compiler / ast / JavadocSingleTypeReference.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.Binding;
15 import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
16 import org.eclipse.jdt.internal.compiler.lookup.ClassScope;
17 import org.eclipse.jdt.internal.compiler.lookup.PackageBinding;
18 import org.eclipse.jdt.internal.compiler.lookup.Scope;
19 import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
20
21
22 public class JavadocSingleTypeReference extends SingleTypeReference {
23         
24         public int tagSourceStart, tagSourceEnd;
25         public PackageBinding packageBinding;
26
27         public JavadocSingleTypeReference(char[] source, long pos, int tagStart, int tagEnd) {
28                 super(source, pos);
29                 this.tagSourceStart = tagStart;
30                 this.tagSourceEnd = tagEnd;
31                 this.bits |= InsideJavadoc;
32         }
33
34         protected void reportInvalidType(Scope scope) {
35                 scope.problemReporter().javadocInvalidType(this, this.resolvedType, scope.getDeclarationModifiers());
36         }
37         protected void reportDeprecatedType(Scope scope) {
38                 scope.problemReporter().javadocDeprecatedType(this.resolvedType, this, scope.getDeclarationModifiers());
39         }
40
41         /* (non-Javadoc)
42          * Redefine to capture javadoc specific signatures
43          * @see org.eclipse.jdt.internal.compiler.ast.ASTNode#traverse(org.eclipse.jdt.internal.compiler.ASTVisitor, org.eclipse.jdt.internal.compiler.lookup.BlockScope)
44          */
45         public void traverse(ASTVisitor visitor, BlockScope scope) {
46                 visitor.visit(this, scope);
47                 visitor.endVisit(this, scope);
48         }
49         
50         public void traverse(ASTVisitor visitor, ClassScope scope) {
51                 visitor.visit(this, scope);
52                 visitor.endVisit(this, scope);
53         }
54
55         TypeBinding internalResolveType(Scope scope) {
56                 // handle the error here
57                 this.constant = NotAConstant;
58                 if (this.resolvedType != null)// is a shared type reference which was already resolved
59                         return this.resolvedType.isValidBinding() ? this.resolvedType : null; // already reported error
60
61                 this.resolvedType = getTypeBinding(scope);
62                 if (!this.resolvedType.isValidBinding()) {
63                         char[][] tokens = { this.token };
64                         Binding binding = scope.getTypeOrPackage(tokens);
65                         if (binding instanceof PackageBinding) {
66                                 this.packageBinding = (PackageBinding) binding;
67                         } else {
68                                 reportInvalidType(scope);
69                         }
70                         return null;
71                 }
72                 if (isTypeUseDeprecated(this.resolvedType, scope))
73                         reportDeprecatedType(scope);
74                 return this.resolvedType = scope.convertToRawType(this.resolvedType);
75         }
76
77         /* (non-Javadoc)
78          * @see org.eclipse.jdt.internal.compiler.ast.Expression#resolveType(org.eclipse.jdt.internal.compiler.lookup.BlockScope)
79          * We need to override to handle package references
80          */
81         public TypeBinding resolveType(BlockScope blockScope, boolean checkBounds) {
82                 return internalResolveType(blockScope);
83         }
84
85         /* (non-Javadoc)
86          * @see org.eclipse.jdt.internal.compiler.ast.Expression#resolveType(org.eclipse.jdt.internal.compiler.lookup.ClassScope)
87          * We need to override to handle package references
88          */
89         public TypeBinding resolveType(ClassScope classScope) {
90                 return internalResolveType(classScope);
91         }
92 }