* Weird case: if JDT determines that this local class is totally
* uninstantiable, it won't bother allocating a local name.
*/
return false;
}
JDeclaredType type = (JDeclaredType) typeMap.get(binding);
try {
// Create an override for getClass().
if (type instanceof JClassType
&& type != program.getTypeJavaLangObject()
&& type != program.getIndexedType("Array")) {
JMethod getClassMethod = program.createMethod(
type.getSourceInfo().makeChild(BuildDeclMapVisitor.class,
"Synthetic getClass()"), "getClass".toCharArray(), type,
program.getTypeJavaLangClass(), false, false, false, false, false);
assert (type.getMethods().get(2) == getClassMethod);
getClassMethod.freezeParamTypes();
}
if (binding.isNestedType() && !binding.isStatic()) {
// add synthetic fields for outer this and locals
assert (type instanceof JClassType);
NestedTypeBinding nestedBinding = (NestedTypeBinding) binding;
if (nestedBinding.enclosingInstances != null) {
for (int i = 0; i < nestedBinding.enclosingInstances.length; ++i) {
SyntheticArgumentBinding arg = nestedBinding.enclosingInstances[i];
if (arg.matchingField != null) {
createField(arg, type);
}
}
}
if (nestedBinding.outerLocalVariables != null) {
for (int i = 0; i < nestedBinding.outerLocalVariables.length; ++i) {
SyntheticArgumentBinding arg = nestedBinding.outerLocalVariables[i];
createField(arg, type);
}
}
}
ReferenceBinding superClassBinding = binding.superclass();
if (superClassBinding != null) {
// TODO: handle separately?
assert (binding.superclass().isClass() || binding.superclass().isEnum());
JClassType superClass = (JClassType) typeMap.get(superClassBinding);
type.setSuperClass(superClass);
}
ReferenceBinding[] superInterfaces = binding.superInterfaces();
for (int i = 0; i < superInterfaces.length; ++i) {
ReferenceBinding superInterfaceBinding = superInterfaces[i];
assert (superInterfaceBinding.isInterface());
JInterfaceType superInterface = (JInterfaceType) typeMap.get(superInterfaceBinding);
type.addImplements(superInterface);
}
if (type instanceof JEnumType) {
processEnumType(binding, (JEnumType) type);
}