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