package org.eclipse.jdt.internal.compiler.ast;
import org.eclipse.jdt.internal.compiler.ASTVisitor;
import org.eclipse.jdt.internal.compiler.impl.Constant;
import org.eclipse.jdt.internal.compiler.lookup.Binding;
import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
import org.eclipse.jdt.internal.compiler.lookup.ClassScope;
import org.eclipse.jdt.internal.compiler.lookup.LocalTypeBinding;
import org.eclipse.jdt.internal.compiler.lookup.PackageBinding;
import org.eclipse.jdt.internal.compiler.lookup.ProblemReasons;
import org.eclipse.jdt.internal.compiler.lookup.ProblemReferenceBinding;
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
import org.eclipse.jdt.internal.compiler.lookup.Scope;
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
public class JavadocSingleTypeReference extends SingleTypeReference implements IJavadocTypeReference {
public int tagSourceStart, tagSourceEnd;
public PackageBinding packageBinding;
public JavadocSingleTypeReference(char[] source, long pos, int tagStart, int tagEnd) {
super(source, pos);
this.tagSourceStart = tagStart;
this.tagSourceEnd = tagEnd;
this.bits |= ASTNode.InsideJavadoc;
}
@Override
protected TypeBinding internalResolveType(Scope scope, int location) {
this.constant = Constant.NotAConstant;
if (this.resolvedType != null) {
if (this.resolvedType.isValidBinding()) {
return this.resolvedType;
} else {
switch (this.resolvedType.problemId()) {
case ProblemReasons.NotFound :
case ProblemReasons.NotVisible :
case ProblemReasons.InheritedNameHidesEnclosingName :
TypeBinding type = this.resolvedType.closestMatch();
return type;
default :
return null;
}
}
}
this.resolvedType = getTypeBinding(scope);
if (this.resolvedType instanceof LocalTypeBinding) {
LocalTypeBinding localType = (LocalTypeBinding) this.resolvedType;
if (localType.scope != null && localType.scope.parent == scope) {
this.resolvedType = new ProblemReferenceBinding(new char[][] { localType.sourceName },
(ReferenceBinding) this.resolvedType, ProblemReasons.NotFound);
}
}
if (this.resolvedType == null) return null;
if (!this.resolvedType.isValidBinding()) {
char[][] tokens = { this.token };
Binding binding = scope.getTypeOrPackage(tokens);
if (binding instanceof PackageBinding) {
this.packageBinding = (PackageBinding) binding;
} else {
if (this.resolvedType.problemId() == ProblemReasons.NonStaticReferenceInStaticContext) {
TypeBinding closestMatch = this.resolvedType.closestMatch();
if (closestMatch != null && closestMatch.isTypeVariable()) {
this.resolvedType = closestMatch;
return this.resolvedType;
}
}
reportInvalidType(scope);
}
return null;
}
if (isTypeUseDeprecated(this.resolvedType, scope))
reportDeprecatedType(this.resolvedType, scope);
if (this.resolvedType.isGenericType() || this.resolvedType.isParameterizedType()) {
this.resolvedType = scope.environment().convertToRawType(this.resolvedType, true );
}
return this.resolvedType;
}
@Override
protected void reportDeprecatedType(TypeBinding type, Scope scope) {
scope.problemReporter().javadocDeprecatedType(type, this, scope.getDeclarationModifiers());
}
@Override
protected void reportInvalidType(Scope scope) {
scope.problemReporter().javadocInvalidType(this, this.resolvedType, scope.getDeclarationModifiers());
}
@Override
public void traverse(ASTVisitor visitor, BlockScope scope) {
visitor.visit(this, scope);
visitor.endVisit(this, scope);
}
@Override
public void traverse(ASTVisitor visitor, ClassScope scope) {
visitor.visit(this, scope);
visitor.endVisit(this, scope);
}
@Override
public int getTagSourceStart() {
return this.tagSourceStart;
}
@Override
public int getTagSourceEnd() {
return this.tagSourceEnd;
}
}