001: /*******************************************************************************
002: * Copyright (c) 2000, 2007 IBM Corporation and others.
003: * All rights reserved. This program and the accompanying materials
004: * are made available under the terms of the Eclipse Public License v1.0
005: * which accompanies this distribution, and is available at
006: * http://www.eclipse.org/legal/epl-v10.html
007: *
008: * Contributors:
009: * IBM Corporation - initial API and implementation
010: *******************************************************************************/package org.eclipse.jdt.internal.compiler.ast;
011:
012: import org.eclipse.jdt.internal.compiler.ASTVisitor;
013: import org.eclipse.jdt.internal.compiler.impl.Constant;
014: import org.eclipse.jdt.internal.compiler.lookup.*;
015:
016: public class JavadocImplicitTypeReference extends TypeReference {
017:
018: public char[] token;
019:
020: public JavadocImplicitTypeReference(char[] name, int pos) {
021: super ();
022: this .token = name;
023: this .sourceStart = pos;
024: this .sourceEnd = pos;
025: }
026:
027: /* (non-Javadoc)
028: * @see org.eclipse.jdt.internal.compiler.ast.TypeReference#copyDims(int)
029: */
030: public TypeReference copyDims(int dim) {
031: return null;
032: }
033:
034: /* (non-Javadoc)
035: * @see org.eclipse.jdt.internal.compiler.ast.TypeReference#getTypeBinding(org.eclipse.jdt.internal.compiler.lookup.Scope)
036: */
037: protected TypeBinding getTypeBinding(Scope scope) {
038: this .constant = Constant.NotAConstant;
039: return this .resolvedType = scope.enclosingSourceType();
040: }
041:
042: public char[] getLastToken() {
043: return this .token;
044: }
045:
046: /* (non-Javadoc)
047: * @see org.eclipse.jdt.internal.compiler.ast.TypeReference#getTypeName()
048: */
049: public char[][] getTypeName() {
050: if (this .token != null) {
051: char[][] tokens = { this .token };
052: return tokens;
053: }
054: return null;
055: }
056:
057: public boolean isThis() {
058: return true;
059: }
060:
061: /*
062: * Resolves type on a Block, Class or CompilationUnit scope.
063: * We need to modify resoling behavior to avoid raw type creation.
064: */
065: private TypeBinding internalResolveType(Scope scope) {
066: // handle the error here
067: this .constant = Constant.NotAConstant;
068: if (this .resolvedType != null) // is a shared type reference which was already resolved
069: return this .resolvedType.isValidBinding() ? this .resolvedType
070: : null; // already reported error
071:
072: this .resolvedType = scope.enclosingSourceType();
073: if (this .resolvedType == null)
074: return null; // detected cycle while resolving hierarchy
075: if (!this .resolvedType.isValidBinding()) {
076: reportInvalidType(scope);
077: return null;
078: }
079: if (isTypeUseDeprecated(this .resolvedType, scope))
080: reportDeprecatedType(this .resolvedType, scope);
081: return this .resolvedType;
082: }
083:
084: protected void reportInvalidType(Scope scope) {
085: scope.problemReporter().javadocInvalidType(this ,
086: this .resolvedType, scope.getDeclarationModifiers());
087: }
088:
089: protected void reportDeprecatedType(TypeBinding type, Scope scope) {
090: scope.problemReporter().javadocDeprecatedType(type, this ,
091: scope.getDeclarationModifiers());
092: }
093:
094: public TypeBinding resolveType(BlockScope blockScope,
095: boolean checkBounds) {
096: return internalResolveType(blockScope);
097: }
098:
099: public TypeBinding resolveType(ClassScope classScope) {
100: return internalResolveType(classScope);
101: }
102:
103: public void traverse(ASTVisitor visitor, BlockScope scope) {
104: visitor.visit(this , scope);
105: visitor.endVisit(this , scope);
106: }
107:
108: public void traverse(ASTVisitor visitor, ClassScope scope) {
109: visitor.visit(this , scope);
110: visitor.endVisit(this , scope);
111: }
112:
113: public StringBuffer printExpression(int indent, StringBuffer output) {
114: return new StringBuffer();
115: }
116: }
|