01: /*******************************************************************************
02: * Copyright (c) 2000, 2007 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.jdt.internal.compiler.ast;
11:
12: import org.eclipse.jdt.internal.compiler.ASTVisitor;
13: import org.eclipse.jdt.internal.compiler.impl.Constant;
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.ParameterizedTypeBinding;
19: import org.eclipse.jdt.internal.compiler.lookup.Scope;
20: import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
21:
22: public class JavadocQualifiedTypeReference extends
23: QualifiedTypeReference {
24:
25: public int tagSourceStart, tagSourceEnd;
26: public PackageBinding packageBinding;
27:
28: public JavadocQualifiedTypeReference(char[][] sources, long[] pos,
29: 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 ,
38: this .resolvedType, scope.getDeclarationModifiers());
39: }
40:
41: protected void reportDeprecatedType(TypeBinding type, Scope scope) {
42: scope.problemReporter().javadocDeprecatedType(type, this ,
43: scope.getDeclarationModifiers());
44: }
45:
46: /* (non-Javadoc)
47: * Redefine to capture javadoc specific signatures
48: * @see org.eclipse.jdt.internal.compiler.ast.ASTNode#traverse(org.eclipse.jdt.internal.compiler.ASTVisitor, org.eclipse.jdt.internal.compiler.lookup.BlockScope)
49: */
50: public void traverse(ASTVisitor visitor, BlockScope scope) {
51: visitor.visit(this , scope);
52: visitor.endVisit(this , scope);
53: }
54:
55: public void traverse(ASTVisitor visitor, ClassScope scope) {
56: visitor.visit(this , scope);
57: visitor.endVisit(this , scope);
58: }
59:
60: /*
61: * We need to modify resolving behavior to handle package references
62: */
63: private TypeBinding internalResolveType(Scope scope,
64: boolean checkBounds) {
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
69: : null; // already reported error
70:
71: this .resolvedType = getTypeBinding(scope);
72: if (!this .resolvedType.isValidBinding()) {
73: Binding binding = scope.getTypeOrPackage(this .tokens);
74: if (binding instanceof PackageBinding) {
75: this .packageBinding = (PackageBinding) binding;
76: } else {
77: reportInvalidType(scope);
78: }
79: return null;
80: }
81: if (isTypeUseDeprecated(this .resolvedType, scope))
82: reportDeprecatedType(this .resolvedType, scope);
83: if (this .resolvedType instanceof ParameterizedTypeBinding) {
84: this .resolvedType = ((ParameterizedTypeBinding) this .resolvedType)
85: .genericType();
86: }
87: return this .resolvedType;
88: }
89:
90: public TypeBinding resolveType(BlockScope blockScope,
91: boolean checkBounds) {
92: return internalResolveType(blockScope, checkBounds);
93: }
94:
95: public TypeBinding resolveType(ClassScope classScope) {
96: return internalResolveType(classScope, false);
97: }
98: }
|