added -J option to preserve unmodified files in preexisting jarfile
[org.ibex.tool.git] / src / org / eclipse / jdt / internal / compiler / ast / JavadocReturnStatement.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.lookup.*;
15
16
17 public class JavadocReturnStatement extends ReturnStatement {
18         public char[] description;
19         public boolean empty = true;
20
21         public JavadocReturnStatement(int s, int e, char[] descr) {
22                 super(null, s, e);
23                 this.description = descr;
24                 this.bits |= InsideJavadoc;
25         }
26
27         /* (non-Javadoc)
28          * @see org.eclipse.jdt.internal.compiler.ast.Statement#resolve(org.eclipse.jdt.internal.compiler.lookup.BlockScope)
29          */
30         public void resolve(BlockScope scope) {
31                 MethodScope methodScope = scope.methodScope();
32                 MethodBinding methodBinding = null;
33                 TypeBinding methodType =
34                         (methodScope.referenceContext instanceof AbstractMethodDeclaration)
35                                 ? ((methodBinding = ((AbstractMethodDeclaration) methodScope.referenceContext).binding) == null 
36                                         ? null 
37                                         : methodBinding.returnType)
38                                 : VoidBinding;
39                 if (methodType == null || methodType == VoidBinding) {
40                         scope.problemReporter().javadocUnexpectedTag(this.sourceStart, this.sourceEnd);
41                 } else if (this.empty) {
42                         scope.problemReporter().javadocEmptyReturnTag(this.sourceStart, this.sourceEnd);
43                 }
44         }
45
46         /* (non-Javadoc)
47          * @see org.eclipse.jdt.internal.compiler.ast.Statement#printStatement(int, java.lang.StringBuffer)
48          */
49         public StringBuffer printStatement(int tab, StringBuffer output) {
50                 printIndent(tab, output).append("return"); //$NON-NLS-1$
51                 if (description != null )
52                         output.append(' ').append(description);
53                 return output;
54         }
55
56         /* (non-Javadoc)
57          * Redefine to capture javadoc specific signatures
58          * @see org.eclipse.jdt.internal.compiler.ast.ASTNode#traverse(org.eclipse.jdt.internal.compiler.ASTVisitor, org.eclipse.jdt.internal.compiler.lookup.BlockScope)
59          */
60         public void traverse(ASTVisitor visitor, BlockScope scope) {
61                 visitor.visit(this, scope);
62                 visitor.endVisit(this, scope);
63         }
64 }