A massive organize imports and formatting of the sources using default Eclipse code...
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / lookup / UnresolvedReferenceBinding.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.phpdt.internal.compiler.lookup;
12
13 import net.sourceforge.phpdt.core.compiler.CharOperation;
14
15 public class UnresolvedReferenceBinding extends ReferenceBinding {
16         ReferenceBinding resolvedType;
17
18         UnresolvedReferenceBinding(char[][] compoundName,
19                         PackageBinding packageBinding) {
20                 this.compoundName = compoundName;
21                 this.fPackage = packageBinding;
22         }
23
24         String debugName() {
25                 return toString();
26         }
27
28         ReferenceBinding resolve(LookupEnvironment environment) {
29                 if (resolvedType != null)
30                         return resolvedType;
31
32                 ReferenceBinding environmentType = fPackage
33                                 .getType0(compoundName[compoundName.length - 1]);
34                 if (environmentType == this)
35                         environmentType = environment.askForType(compoundName);
36                 if (environmentType != null && environmentType != this) { // could not
37                                                                                                                                         // resolve
38                                                                                                                                         // any
39                                                                                                                                         // better,
40                                                                                                                                         // error was
41                                                                                                                                         // already
42                                                                                                                                         // reported
43                                                                                                                                         // against
44                                                                                                                                         // it
45                         resolvedType = environmentType;
46                         environment.updateArrayCache(this, environmentType);
47                         return environmentType; // when found, it replaces the unresolved
48                                                                         // type in the cache
49                 }
50
51                 environment.problemReporter.isClassPathCorrect(compoundName, null);
52                 return null; // will not get here since the above error aborts the
53                                                 // compilation
54         }
55
56         public String toString() {
57                 return "Unresolved type " + ((compoundName != null) ? CharOperation.toString(compoundName) : "UNNAMED"); //$NON-NLS-1$ //$NON-NLS-2$
58         }
59 }