KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > compiler > ast > JavadocArgumentExpression


1 /*******************************************************************************
2  * Copyright (c) 2000, 2007 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-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.classfmt.ClassFileConstants;
15 import org.eclipse.jdt.internal.compiler.impl.Constant;
16 import org.eclipse.jdt.internal.compiler.lookup.*;
17
18 public class JavadocArgumentExpression extends Expression {
19     public char[] token;
20     public Argument argument;
21
22     public JavadocArgumentExpression(char[] name, int startPos, int endPos, TypeReference typeRef) {
23         this.token = name;
24         this.sourceStart = startPos;
25         this.sourceEnd = endPos;
26         long pos = (((long) startPos) << 32) + endPos;
27         this.argument = new Argument(name, pos, typeRef, ClassFileConstants.AccDefault);
28         this.bits |= InsideJavadoc;
29     }
30
31     /*
32      * Resolves type on a Block or Class scope.
33      */

34     private TypeBinding internalResolveType(Scope scope) {
35         this.constant = Constant.NotAConstant;
36         if (this.resolvedType != null) // is a shared type reference which was already resolved
37
return this.resolvedType.isValidBinding() ? this.resolvedType : null; // already reported error
38

39         if (this.argument != null) {
40             TypeReference typeRef = this.argument.type;
41             if (typeRef != null) {
42                 this.resolvedType = typeRef.getTypeBinding(scope);
43                 typeRef.resolvedType = this.resolvedType;
44                 if (!this.resolvedType.isValidBinding()) {
45                     scope.problemReporter().javadocInvalidType(typeRef, this.resolvedType, scope.getDeclarationModifiers());
46                     return null;
47                 }
48                 if (isTypeUseDeprecated(this.resolvedType, scope)) {
49                     scope.problemReporter().javadocDeprecatedType(this.resolvedType, typeRef, scope.getDeclarationModifiers());
50                 }
51                 return this.resolvedType = scope.environment().convertToRawType(this.resolvedType);
52             }
53         }
54         return null;
55     }
56     
57     public StringBuffer JavaDoc printExpression(int indent, StringBuffer JavaDoc output) {
58         if (this.argument == null) {
59             if (this.token != null) {
60                 output.append(this.token);
61             }
62         }
63         else {
64             this.argument.print(indent, output);
65         }
66         return output;
67     }
68
69     public void resolve(BlockScope scope) {
70         if (this.argument != null) {
71             this.argument.resolve(scope);
72         }
73     }
74
75     public TypeBinding resolveType(BlockScope scope) {
76         return internalResolveType(scope);
77     }
78
79     public TypeBinding resolveType(ClassScope scope) {
80         return internalResolveType(scope);
81     }
82
83     /* (non-Javadoc)
84      * Redefine to capture javadoc specific signatures
85      * @see org.eclipse.jdt.internal.compiler.ast.ASTNode#traverse(org.eclipse.jdt.internal.compiler.ASTVisitor, org.eclipse.jdt.internal.compiler.lookup.BlockScope)
86      */

87     public void traverse(ASTVisitor visitor, BlockScope blockScope) {
88         if (visitor.visit(this, blockScope)) {
89             if (this.argument != null) {
90                 this.argument.traverse(visitor, blockScope);
91             }
92         }
93         visitor.endVisit(this, blockScope);
94     }
95     public void traverse(ASTVisitor visitor, ClassScope blockScope) {
96         if (visitor.visit(this, blockScope)) {
97             if (this.argument != null) {
98                 this.argument.traverse(visitor, blockScope);
99             }
100         }
101         visitor.endVisit(this, blockScope);
102     }
103 }
104
Popular Tags