KickJava   Java API By Example, From Geeks To Geeks.

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


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.*;
16
17 public class JavadocImplicitTypeReference extends TypeReference {
18     
19     public char[] token;
20
21     public JavadocImplicitTypeReference(char[] name, int pos) {
22         super();
23         this.token = name;
24         this.sourceStart = pos;
25         this.sourceEnd = pos;
26     }
27     /* (non-Javadoc)
28      * @see org.eclipse.jdt.internal.compiler.ast.TypeReference#copyDims(int)
29      */

30     public TypeReference copyDims(int dim) {
31         return null;
32     }
33
34     /* (non-Javadoc)
35      * @see org.eclipse.jdt.internal.compiler.ast.TypeReference#getTypeBinding(org.eclipse.jdt.internal.compiler.lookup.Scope)
36      */

37     protected TypeBinding getTypeBinding(Scope scope) {
38         this.constant = Constant.NotAConstant;
39         return this.resolvedType = scope.enclosingSourceType();
40     }
41
42     public char[] getLastToken() {
43         return this.token;
44     }
45     
46     /* (non-Javadoc)
47      * @see org.eclipse.jdt.internal.compiler.ast.TypeReference#getTypeName()
48      */

49     public char[][] getTypeName() {
50         if (this.token != null) {
51             char[][] tokens = { this.token };
52             return tokens;
53         }
54         return null;
55     }
56     public boolean isThis() {
57         return true;
58     }
59
60     /*
61      * Resolves type on a Block, Class or CompilationUnit scope.
62      * We need to modify resoling behavior to avoid raw type creation.
63      */

64     private TypeBinding internalResolveType(Scope scope) {
65         // handle the error here
66
this.constant = Constant.NotAConstant;
67         if (this.resolvedType != null) // is a shared type reference which was already resolved
68
return this.resolvedType.isValidBinding() ? this.resolvedType : null; // already reported error
69

70         this.resolvedType = scope.enclosingSourceType();
71         if (this.resolvedType == null)
72             return null; // detected cycle while resolving hierarchy
73
if (!this.resolvedType.isValidBinding()) {
74             reportInvalidType(scope);
75             return null;
76         }
77         if (isTypeUseDeprecated(this.resolvedType, scope))
78             reportDeprecatedType(this.resolvedType, scope);
79         return this.resolvedType;
80     }
81
82     protected void reportInvalidType(Scope scope) {
83         scope.problemReporter().javadocInvalidType(this, this.resolvedType, scope.getDeclarationModifiers());
84     }
85     protected void reportDeprecatedType(TypeBinding type, Scope scope) {
86         scope.problemReporter().javadocDeprecatedType(type, this, scope.getDeclarationModifiers());
87     }
88
89     public TypeBinding resolveType(BlockScope blockScope, boolean checkBounds) {
90         return internalResolveType(blockScope);
91     }
92
93     public TypeBinding resolveType(ClassScope classScope) {
94         return internalResolveType(classScope);
95     }
96
97     public void traverse(ASTVisitor visitor, BlockScope scope) {
98         visitor.visit(this, scope);
99         visitor.endVisit(this, scope);
100     }
101
102     public void traverse(ASTVisitor visitor, ClassScope scope) {
103         visitor.visit(this, scope);
104         visitor.endVisit(this, scope);
105     }
106
107     public StringBuffer JavaDoc printExpression(int indent, StringBuffer JavaDoc output) {
108         return new StringBuffer JavaDoc();
109     }
110 }
111
Popular Tags