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