Makefile fixup
[org.ibex.tool.git] / src / org / eclipse / jdt / internal / compiler / ast / JavadocArgumentExpression.java
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.env.IConstants;
15 import org.eclipse.jdt.internal.compiler.lookup.*;
16 import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
17 import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
18
19
20 public class JavadocArgumentExpression extends Expression {
21         public char[] token;
22         public Argument argument;
23
24         public JavadocArgumentExpression(char[] name, int startPos, int endPos, TypeReference typeRef) {
25                 this.token = name;
26                 this.sourceStart = startPos;
27                 this.sourceEnd = endPos;
28                 long pos = (((long) startPos) << 32) + endPos;
29                 this.argument = new Argument(name, pos, typeRef, IConstants.AccDefault);
30                 this.bits |= InsideJavadoc;
31         }
32
33         /*
34          * Resolves type on a Block or Class scope.
35          */
36         private TypeBinding internalResolveType(Scope scope) {
37                 this.constant = NotAConstant;
38                 if (this.resolvedType != null) { // is a shared type reference which was already resolved
39                         if (!this.resolvedType.isValidBinding()) {
40                                 return null; // already reported error
41                         }
42                 }
43                 else {
44                         if (this.argument != null) {
45                                 TypeReference typeRef = this.argument.type;
46                                 if (typeRef != null) {
47                                         this.resolvedType = typeRef.getTypeBinding(scope);
48                                         typeRef.resolvedType = this.resolvedType;
49                                         if (!this.resolvedType.isValidBinding()) {
50                                                 scope.problemReporter().javadocInvalidType(typeRef, this.resolvedType, scope.getDeclarationModifiers());
51                                                 return null;
52                                         }
53                                         if (isTypeUseDeprecated(this.resolvedType, scope)) {
54                                                 scope.problemReporter().javadocDeprecatedType(this.resolvedType, typeRef, scope.getDeclarationModifiers());
55                                                 return null;
56                                         }
57                                         return this.resolvedType;
58                                 }
59                         }
60                 }
61                 return null;
62         }
63         
64         public StringBuffer printExpression(int indent, StringBuffer output) {
65                 if (this.argument == null) {
66                         if (this.token != null) {
67                                 output.append(this.token);
68                         }
69                 }
70                 else {
71                         this.argument.print(indent, output);
72                 }
73                 return output;
74         }
75
76         public void resolve(BlockScope scope) {
77                 if (this.argument != null) {
78                         this.argument.resolve(scope);
79                 }
80         }
81
82         public TypeBinding resolveType(BlockScope scope) {
83                 return internalResolveType(scope);
84         }
85
86         public TypeBinding resolveType(ClassScope scope) {
87                 return internalResolveType(scope);
88         }
89         
90         /* (non-Javadoc)
91          * Redefine to capture javadoc specific signatures
92          * @see org.eclipse.jdt.internal.compiler.ast.ASTNode#traverse(org.eclipse.jdt.internal.compiler.ASTVisitor, org.eclipse.jdt.internal.compiler.lookup.BlockScope)
93          */
94         public void traverse(ASTVisitor visitor, BlockScope blockScope) {
95                 if (visitor.visit(this, blockScope)) {
96                         if (this.argument != null) {
97                                 this.argument.traverse(visitor, blockScope);
98                         }
99                 }
100                 visitor.endVisit(this, blockScope);
101         }
102 }