added -J option to preserve unmodified files in preexisting jarfile
[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                         return this.resolvedType.isValidBinding() ? this.resolvedType : null; // already reported error
40
41                 if (this.argument != null) {
42                         TypeReference typeRef = this.argument.type;
43                         if (typeRef != null) {
44                                 this.resolvedType = typeRef.getTypeBinding(scope);
45                                 typeRef.resolvedType = this.resolvedType;
46                                 if (!this.resolvedType.isValidBinding()) {
47                                         scope.problemReporter().javadocInvalidType(typeRef, this.resolvedType, scope.getDeclarationModifiers());
48                                         return null;
49                                 }
50                                 if (isTypeUseDeprecated(this.resolvedType, scope)) {
51                                         scope.problemReporter().javadocDeprecatedType(this.resolvedType, typeRef, scope.getDeclarationModifiers());
52                                         return null;
53                                 }
54                                 return this.resolvedType = scope.convertToRawType(this.resolvedType);
55                         }
56                 }
57                 return null;
58         }
59         
60         public StringBuffer printExpression(int indent, StringBuffer output) {
61                 if (this.argument == null) {
62                         if (this.token != null) {
63                                 output.append(this.token);
64                         }
65                 }
66                 else {
67                         this.argument.print(indent, output);
68                 }
69                 return output;
70         }
71
72         public void resolve(BlockScope scope) {
73                 if (this.argument != null) {
74                         this.argument.resolve(scope);
75                 }
76         }
77
78         public TypeBinding resolveType(BlockScope scope) {
79                 return internalResolveType(scope);
80         }
81
82         public TypeBinding resolveType(ClassScope scope) {
83                 return internalResolveType(scope);
84         }
85         
86         /* (non-Javadoc)
87          * Redefine to capture javadoc specific signatures
88          * @see org.eclipse.jdt.internal.compiler.ast.ASTNode#traverse(org.eclipse.jdt.internal.compiler.ASTVisitor, org.eclipse.jdt.internal.compiler.lookup.BlockScope)
89          */
90         public void traverse(ASTVisitor visitor, BlockScope blockScope) {
91                 if (visitor.visit(this, blockScope)) {
92                         if (this.argument != null) {
93                                 this.argument.traverse(visitor, blockScope);
94                         }
95                 }
96                 visitor.endVisit(this, blockScope);
97         }
98 }