blob: 08a231198fef9681fc453917adc0c5f513e2d56a [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2000, 2004 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.jdt.internal.compiler.lookup;
import org.eclipse.jdt.core.compiler.CharOperation;
public class UnresolvedReferenceBinding extends ReferenceBinding {
ReferenceBinding resolvedType;
TypeBinding[] wrappers;
UnresolvedReferenceBinding(char[][] compoundName, PackageBinding packageBinding) {
this.compoundName = compoundName;
this.sourceName = compoundName[compoundName.length - 1]; // reasonable guess
this.fPackage = packageBinding;
this.wrappers = null;
}
void addWrapper(TypeBinding wrapper) {
if (this.wrappers == null) {
this.wrappers = new TypeBinding[] {wrapper};
} else {
int length = this.wrappers.length;
System.arraycopy(this.wrappers, 0, this.wrappers = new TypeBinding[length + 1], 0, length);
this.wrappers[length] = wrapper;
}
}
public String debugName() {
return toString();
}
ReferenceBinding resolve(LookupEnvironment environment, ParameterizedTypeBinding parameterizedType, int rank) {
if (this.resolvedType != null) return this.resolvedType;
ReferenceBinding environmentType = this.fPackage.getType0(this.compoundName[this.compoundName.length - 1]);
if (environmentType == this)
environmentType = environment.askForType(this.compoundName);
if (environmentType != null && environmentType != this) { // could not resolve any better, error was already reported against it
this.resolvedType = environmentType;
// must ensure to update any other type bindings that can contain the resolved type
// otherwise we could create 2 : 1 for this unresolved type & 1 for the resolved type
if (this.wrappers != null)
for (int i = 0, l = this.wrappers.length; i < l; i++)
this.wrappers[i].swapUnresolved(this, environmentType);
environment.updateCaches(this, environmentType);
return environmentType; // when found, it replaces the unresolved type in the cache
}
environment.problemReporter.isClassPathCorrect(this.compoundName, null);
return null; // will not get here since the above error aborts the compilation
}
public String toString() {
return "Unresolved type " + ((compoundName != null) ? CharOperation.toString(compoundName) : "UNNAMED"); //$NON-NLS-1$ //$NON-NLS-2$
}
}