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.classfmt.ClassFileConstants;
014: import org.eclipse.jdt.internal.compiler.impl.Constant;
015: import org.eclipse.jdt.internal.compiler.lookup.*;
016:
017: public class JavadocArgumentExpression extends Expression {
018: public char[] token;
019: public Argument argument;
020:
021: public JavadocArgumentExpression(char[] name, int startPos,
022: int endPos, TypeReference typeRef) {
023: this .token = name;
024: this .sourceStart = startPos;
025: this .sourceEnd = endPos;
026: long pos = (((long) startPos) << 32) + endPos;
027: this .argument = new Argument(name, pos, typeRef,
028: ClassFileConstants.AccDefault);
029: this .bits |= InsideJavadoc;
030: }
031:
032: /*
033: * Resolves type on a Block or Class scope.
034: */
035: private TypeBinding internalResolveType(Scope scope) {
036: this .constant = Constant.NotAConstant;
037: if (this .resolvedType != null) // is a shared type reference which was already resolved
038: return this .resolvedType.isValidBinding() ? this .resolvedType
039: : null; // already reported error
040:
041: if (this .argument != null) {
042: TypeReference typeRef = this .argument.type;
043: if (typeRef != null) {
044: this .resolvedType = typeRef.getTypeBinding(scope);
045: typeRef.resolvedType = this .resolvedType;
046: if (!this .resolvedType.isValidBinding()) {
047: scope.problemReporter().javadocInvalidType(typeRef,
048: this .resolvedType,
049: scope.getDeclarationModifiers());
050: return null;
051: }
052: if (isTypeUseDeprecated(this .resolvedType, scope)) {
053: scope.problemReporter().javadocDeprecatedType(
054: this .resolvedType, typeRef,
055: scope.getDeclarationModifiers());
056: }
057: return this .resolvedType = scope.environment()
058: .convertToRawType(this .resolvedType);
059: }
060: }
061: return null;
062: }
063:
064: public StringBuffer printExpression(int indent, StringBuffer output) {
065: if (this .argument == null) {
066: if (this .token != null) {
067: output.append(this .token);
068: }
069: } else {
070: this .argument.print(indent, output);
071: }
072: return output;
073: }
074:
075: public void resolve(BlockScope scope) {
076: if (this .argument != null) {
077: this .argument.resolve(scope);
078: }
079: }
080:
081: public TypeBinding resolveType(BlockScope scope) {
082: return internalResolveType(scope);
083: }
084:
085: public TypeBinding resolveType(ClassScope scope) {
086: return internalResolveType(scope);
087: }
088:
089: /* (non-Javadoc)
090: * Redefine to capture javadoc specific signatures
091: * @see org.eclipse.jdt.internal.compiler.ast.ASTNode#traverse(org.eclipse.jdt.internal.compiler.ASTVisitor, org.eclipse.jdt.internal.compiler.lookup.BlockScope)
092: */
093: public void traverse(ASTVisitor visitor, BlockScope blockScope) {
094: if (visitor.visit(this , blockScope)) {
095: if (this .argument != null) {
096: this .argument.traverse(visitor, blockScope);
097: }
098: }
099: visitor.endVisit(this , blockScope);
100: }
101:
102: public void traverse(ASTVisitor visitor, ClassScope blockScope) {
103: if (visitor.visit(this, blockScope)) {
104: if (this.argument != null) {
105: this.argument.traverse(visitor, blockScope);
106: }
107: }
108: visitor.endVisit(this, blockScope);
109: }
110: }
|