1) Moved net.sourceforge.phpeclipse.ui\src\net\sourceforge\phpdt back to net.sourcefo...
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / ast / JavadocSingleTypeReference.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 net.sourceforge.phpdt.internal.compiler.ast;
12
13 import net.sourceforge.phpdt.internal.compiler.ASTVisitor;
14 import net.sourceforge.phpdt.internal.compiler.lookup.Binding;
15 import net.sourceforge.phpdt.internal.compiler.lookup.BlockScope;
16 import net.sourceforge.phpdt.internal.compiler.lookup.ClassScope;
17 import net.sourceforge.phpdt.internal.compiler.lookup.PackageBinding;
18 import net.sourceforge.phpdt.internal.compiler.lookup.Scope;
19 import net.sourceforge.phpdt.internal.compiler.lookup.TypeBinding;
20
21 public class JavadocSingleTypeReference extends SingleTypeReference {
22
23         public int tagSourceStart, tagSourceEnd;
24
25         public PackageBinding packageBinding;
26
27         public JavadocSingleTypeReference(char[] source, long pos, int tagStart,
28                         int tagEnd) {
29                 super(source, pos);
30                 this.tagSourceStart = tagStart;
31                 this.tagSourceEnd = tagEnd;
32                 this.bits |= InsideJavadoc;
33         }
34
35         protected void reportInvalidType(Scope scope) {
36                 scope.problemReporter().javadocInvalidType(this, this.resolvedType,
37                                 scope.getDeclarationModifiers());
38         }
39
40         protected void reportDeprecatedType(Scope scope) {
41                 scope.problemReporter().javadocDeprecatedType(this.resolvedType, this,
42                                 scope.getDeclarationModifiers());
43         }
44
45         /*
46          * (non-Javadoc) Redefine to capture javadoc specific signatures
47          * 
48          * @see net.sourceforge.phpdt.internal.compiler.ast.ASTNode#traverse(net.sourceforge.phpdt.internal.compiler.ASTVisitor,
49          *      net.sourceforge.phpdt.internal.compiler.lookup.BlockScope)
50          */
51         public void traverse(ASTVisitor visitor, BlockScope scope) {
52                 visitor.visit(this, scope);
53                 visitor.endVisit(this, scope);
54         }
55
56         /*
57          * 
58          */
59         private TypeBinding internalResolveType(Scope scope) {
60                 // handle the error here
61                 this.constant = NotAConstant;
62                 if (this.resolvedType != null) { // is a shared type reference which
63                                                                                         // was already resolved
64                         if (!this.resolvedType.isValidBinding())
65                                 return null; // already reported error
66                 } else {
67                         this.resolvedType = getTypeBinding(scope);
68                         if (!this.resolvedType.isValidBinding()) {
69                                 char[][] tokens = { this.token };
70                                 Binding binding = scope.getTypeOrPackage(tokens);
71                                 if (binding instanceof PackageBinding) {
72                                         this.packageBinding = (PackageBinding) binding;
73                                 } else {
74                                         reportInvalidType(scope);
75                                 }
76                                 return null;
77                         }
78                         if (isTypeUseDeprecated(this.resolvedType, scope)) {
79                                 reportDeprecatedType(scope);
80                         }
81                 }
82                 return this.resolvedType;
83         }
84
85         /*
86          * (non-Javadoc)
87          * 
88          * @see net.sourceforge.phpdt.internal.compiler.ast.Expression#resolveType(net.sourceforge.phpdt.internal.compiler.lookup.BlockScope)
89          *      We need to override to handle package references
90          */
91         public TypeBinding resolveType(BlockScope blockScope) {
92                 return internalResolveType(blockScope);
93         }
94
95         /*
96          * (non-Javadoc)
97          * 
98          * @see net.sourceforge.phpdt.internal.compiler.ast.Expression#resolveType(net.sourceforge.phpdt.internal.compiler.lookup.ClassScope)
99          *      We need to override to handle package references
100          */
101         public TypeBinding resolveType(ClassScope classScope) {
102                 return internalResolveType(classScope);
103         }
104 }