return this.getTypeBinding(qualifiedNameReference.resolvedType);
}
int indexOfFirstFieldBinding = qualifiedNameReference.indexOfFirstFieldBinding; // one-based
if (index < indexOfFirstFieldBinding) {
// an extra lookup is required
BlockScope internalScope = (BlockScope) this.astNodesToBlockScope.get(name);
Binding binding = null;
try {
if (internalScope == null) {
if (this.scope == null) return null;
binding = this.scope.getTypeOrPackage(CharOperation.subarray(tokens, 0, index));
} else {
binding = internalScope.getTypeOrPackage(CharOperation.subarray(tokens, 0, index));
}
} catch (AbortCompilation e) {
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=53357
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=63550
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=64299
}
if (binding instanceof org.eclipse.jdt.internal.compiler.lookup.PackageBinding) {
return null;
} else if (binding instanceof org.eclipse.jdt.internal.compiler.lookup.TypeBinding) {
// it is a type
return this.getTypeBinding((org.eclipse.jdt.internal.compiler.lookup.TypeBinding)binding);
}
} else if (index == indexOfFirstFieldBinding) {
if (qualifiedNameReference.isTypeReference()) {
return this.getTypeBinding(qualifiedNameReference.resolvedType);
} else {
// in this case we want to get the next field declaring's class
if (qualifiedNameReference.otherBindings == null) {
return null;
}
FieldBinding fieldBinding = qualifiedNameReference.otherBindings[0];
if (fieldBinding == null) return null;
org.eclipse.jdt.internal.compiler.lookup.TypeBinding type = fieldBinding.declaringClass;
if (type == null) { // array length scenario
// use type from first binding (no capture needed for array type)
switch (qualifiedNameReference.bits & org.eclipse.jdt.internal.compiler.ast.ASTNode.RestrictiveFlagMASK) {
case Binding.FIELD:
type = ((FieldBinding) qualifiedNameReference.binding).type;
break;
case Binding.LOCAL:
type = ((LocalVariableBinding) qualifiedNameReference.binding).type;
break;
}
}
return this.getTypeBinding(type);
}
} else {
/* This is the case for a name which is part of a qualified name that
* cannot be resolved. See PR 13063.
*/
if (qualifiedNameReference.otherBindings == null) return null;
final int otherBindingsLength = qualifiedNameReference.otherBindings.length;
if (otherBindingsLength == (index - indexOfFirstFieldBinding)) {
return this.getTypeBinding(qualifiedNameReference.resolvedType);
}
FieldBinding fieldBinding = qualifiedNameReference.otherBindings[index - indexOfFirstFieldBinding];
if (fieldBinding == null) return null;
org.eclipse.jdt.internal.compiler.lookup.TypeBinding type = fieldBinding.declaringClass;
if (type == null) { // array length scenario
// use type from previous binding (no capture needed for array type)
fieldBinding = qualifiedNameReference.otherBindings[index - indexOfFirstFieldBinding - 1];
if (fieldBinding == null) return null;
type = fieldBinding.type;
}
return this.getTypeBinding(type);
}
} else if (node instanceof QualifiedTypeReference) {
QualifiedTypeReference qualifiedTypeReference = (QualifiedTypeReference) node;
if (qualifiedTypeReference.resolvedType == null) {
return null;
}
if (index == qualifiedTypeReference.tokens.length) {
if (!qualifiedTypeReference.resolvedType.isValidBinding() && qualifiedTypeReference instanceof JavadocQualifiedTypeReference) {
JavadocQualifiedTypeReference typeRef = (JavadocQualifiedTypeReference) node;
if (typeRef.packageBinding != null) {
return null;
}
}
return this.getTypeBinding(qualifiedTypeReference.resolvedType.leafComponentType());
} else {
if (index >= 0) {
BlockScope internalScope = (BlockScope) this.astNodesToBlockScope.get(name);
Binding binding = null;
try {
if (internalScope == null) {
if (this.scope == null) return null;
binding = this.scope.getTypeOrPackage(CharOperation.subarray(qualifiedTypeReference.tokens, 0, index));
} else {
binding = internalScope.getTypeOrPackage(CharOperation.subarray(qualifiedTypeReference.tokens, 0, index));
}
} catch (AbortCompilation e) {
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=53357
}
if (binding instanceof org.eclipse.jdt.internal.compiler.lookup.PackageBinding) {