new version with WorkingCopy Management
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / internal / compiler / ast / TypeReference.java
1 /*******************************************************************************
2  * Copyright (c) 2000, 2003 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.IAbstractSyntaxTreeVisitor;
14 import net.sourceforge.phpdt.internal.compiler.lookup.BlockScope;
15 import net.sourceforge.phpdt.internal.compiler.lookup.ClassScope;
16 import net.sourceforge.phpdt.internal.compiler.lookup.Scope;
17 import net.sourceforge.phpdt.internal.compiler.lookup.TypeBinding;
18
19 import net.sourceforge.phpdt.internal.compiler.flow.FlowContext;
20 import net.sourceforge.phpdt.internal.compiler.flow.FlowInfo;
21
22 public abstract class TypeReference extends Expression {
23
24 public TypeReference() {
25                 super () ;
26                 }
27
28 public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo) {
29         return flowInfo;
30 }
31
32 // allows us to trap completion & selection nodes
33 public void aboutToResolve(Scope scope) {}
34 /*
35  * Answer a base type reference (can be an array of base type).
36  */
37 //public static final TypeReference baseTypeReference(int baseType, int dim) {
38 //      
39 //      if (dim == 0) {
40 //              switch (baseType) {
41 //                      case (T_void) :
42 //                              return new SingleTypeReference(VoidBinding.simpleName, 0);
43 //                      case (T_boolean) :
44 //                              return new SingleTypeReference(BooleanBinding.simpleName, 0);
45 //                      case (T_char) :
46 //                              return new SingleTypeReference(CharBinding.simpleName, 0);
47 //                      case (T_float) :
48 //                              return new SingleTypeReference(FloatBinding.simpleName, 0);
49 //                      case (T_double) :
50 //                              return new SingleTypeReference(DoubleBinding.simpleName, 0);
51 //                      case (T_byte) :
52 //                              return new SingleTypeReference(ByteBinding.simpleName, 0);
53 //                      case (T_short) :
54 //                              return new SingleTypeReference(ShortBinding.simpleName, 0);
55 //                      case (T_int) :
56 //                              return new SingleTypeReference(IntBinding.simpleName, 0);
57 //                      default : //T_long      
58 //                              return new SingleTypeReference(LongBinding.simpleName, 0);
59 //              }
60 //      }
61 //      switch (baseType) {
62 //              case (T_void) :
63 //                      return new ArrayTypeReference(VoidBinding.simpleName, dim, 0);
64 //              case (T_boolean) :
65 //                      return new ArrayTypeReference(BooleanBinding.simpleName, dim, 0);
66 //              case (T_char) :
67 //                      return new ArrayTypeReference(CharBinding.simpleName, dim, 0);
68 //              case (T_float) :
69 //                      return new ArrayTypeReference(FloatBinding.simpleName, dim, 0);
70 //              case (T_double) :
71 //                      return new ArrayTypeReference(DoubleBinding.simpleName, dim, 0);
72 //              case (T_byte) :
73 //                      return new ArrayTypeReference(ByteBinding.simpleName, dim, 0);
74 //              case (T_short) :
75 //                      return new ArrayTypeReference(ShortBinding.simpleName, dim, 0);
76 //              case (T_int) :
77 //                      return new ArrayTypeReference(IntBinding.simpleName, dim, 0);
78 //              default : //T_long      
79 //                      return new ArrayTypeReference(LongBinding.simpleName, dim, 0);
80 //      }
81 //}
82 public abstract TypeReference copyDims(int dim);
83 public int dimensions() {
84         return 0;
85 }
86 public abstract TypeBinding getTypeBinding(Scope scope);
87 /**
88  * @return char[][]
89  */
90 public abstract char [][] getTypeName() ;
91 public boolean isTypeReference() {
92         return true;
93 }
94 public TypeBinding resolveType(BlockScope scope) {
95         // handle the error here
96         constant = NotAConstant;
97         if (this.resolvedType != null) { // is a shared type reference which was already resolved
98                 if (!this.resolvedType.isValidBinding())
99                         return null; // already reported error
100         } else {
101                 this.resolvedType = getTypeBinding(scope);
102                 if (!this.resolvedType.isValidBinding()) {
103                         scope.problemReporter().invalidType(this, this.resolvedType);
104                         return null;
105                 }
106                 if (isTypeUseDeprecated(this.resolvedType, scope))
107                         scope.problemReporter().deprecatedType(this.resolvedType, this);
108         }
109         return this.resolvedType;
110 }
111 public abstract void traverse(IAbstractSyntaxTreeVisitor visitor, ClassScope classScope);
112 }