KickJava   Java API By Example, From Geeks To Geeks.

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


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.Constant;
15 import org.eclipse.jdt.internal.compiler.lookup.Binding;
16 import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
17 import org.eclipse.jdt.internal.compiler.lookup.ClassScope;
18 import org.eclipse.jdt.internal.compiler.lookup.PackageBinding;
19 import org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding;
20 import org.eclipse.jdt.internal.compiler.lookup.Scope;
21 import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
22
23
24 public class JavadocQualifiedTypeReference extends QualifiedTypeReference {
25
26     public int tagSourceStart, tagSourceEnd;
27     public PackageBinding packageBinding;
28
29     public JavadocQualifiedTypeReference(char[][] sources, long[] pos, int tagStart, int tagEnd) {
30         super(sources, pos);
31         this.tagSourceStart = tagStart;
32         this.tagSourceEnd = tagEnd;
33         this.bits |= ASTNode.InsideJavadoc;
34     }
35
36     protected void reportInvalidType(Scope scope) {
37         scope.problemReporter().javadocInvalidType(this, this.resolvedType, scope.getDeclarationModifiers());
38     }
39     protected void reportDeprecatedType(TypeBinding type, Scope scope) {
40         scope.problemReporter().javadocDeprecatedType(type, this, scope.getDeclarationModifiers());
41     }
42
43     /* (non-Javadoc)
44      * Redefine to capture javadoc specific signatures
45      * @see org.eclipse.jdt.internal.compiler.ast.ASTNode#traverse(org.eclipse.jdt.internal.compiler.ASTVisitor, org.eclipse.jdt.internal.compiler.lookup.BlockScope)
46      */

47     public void traverse(ASTVisitor visitor, BlockScope scope) {
48         visitor.visit(this, scope);
49         visitor.endVisit(this, scope);
50     }
51     public void traverse(ASTVisitor visitor, ClassScope scope) {
52         visitor.visit(this, scope);
53         visitor.endVisit(this, scope);
54     }
55
56     /*
57      * We need to modify resolving behavior to handle package references
58      */

59     private TypeBinding internalResolveType(Scope scope, boolean checkBounds) {
60         // handle the error here
61
this.constant = Constant.NotAConstant;
62         if (this.resolvedType != null) // is a shared type reference which was already resolved
63
return this.resolvedType.isValidBinding() ? this.resolvedType : null; // already reported error
64

65         this.resolvedType = getTypeBinding(scope);
66         if (!this.resolvedType.isValidBinding()) {
67             Binding binding = scope.getTypeOrPackage(this.tokens);
68             if (binding instanceof PackageBinding) {
69                 this.packageBinding = (PackageBinding) binding;
70             } else {
71                 reportInvalidType(scope);
72             }
73             return null;
74         }
75         if (isTypeUseDeprecated(this.resolvedType, scope))
76             reportDeprecatedType(this.resolvedType, scope);
77         if (this.resolvedType instanceof ParameterizedTypeBinding) {
78             this.resolvedType = ((ParameterizedTypeBinding)this.resolvedType).genericType();
79         }
80         return this.resolvedType;
81     }
82
83     public TypeBinding resolveType(BlockScope blockScope, boolean checkBounds) {
84         return internalResolveType(blockScope, checkBounds);
85     }
86
87     public TypeBinding resolveType(ClassScope classScope) {
88         return internalResolveType(classScope, false);
89     }
90 }
91
Popular Tags