Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2000, 2013 IBM Corporation and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html Contributors: IBM Corporation - initial API and implementation Stephan Herrmann - Contribution for Bug 342671 - ClassCastException: org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding cannot be cast to org.eclipse.jdt.internal.compiler.lookup.ArrayBinding /
  
  package org.eclipse.jdt.core.dom;
  
  import java.util.HashMap;
  import java.util.Map;
  
Internal class for resolving bindings using old ASTs.

IMPORTANT: The methods on this class are synchronized. This is required because there may be multiple clients in separate threads concurrently reading an AST and asking for bindings for its nodes. These requests all end up invoking instance methods on this class. There are various internal tables and caches which are built and maintained in the course of looking up bindings. To ensure that they remain coherent in the presence of multiple threads, the methods are synchronized on the DefaultBindingResolver instance.

  
  
  	/*
  	 * Holds on binding tables that can be shared by several ASTs.
  	 */
  	static class BindingTables {

This map is used to get a binding from its binding key.
  
This map is used to keep the correspondance between new bindings and the compiler bindings as well as new annotation instances to their internal counterpart. This is an identity map. We should only create one object for one binding or annotation.
  
  
  		BindingTables() {
  			this. = new HashMap();
 		}
 
 	}
This map is used to retrieve the corresponding block scope for a ast node
 
This map is used to get an ast node from its binding (new binding) or DOM
 
 
 	/*
 	 * The shared binding tables accros ASTs.
 	 */
This map is used to retrieve an old ast node using the new ast node. This is not an identity map, as several nested DOM nodes may be associated with the same "larger" compiler AST node. E.g., an ArrayAllocationExpression "new MyType[1]" will appear as the right-hand value for the SimpleType "MyType", the ArrayType "MyType[1]", and the ArrayCreation "new MyType[1]".
 
Compilation unit scope
 
The working copy owner that defines the context in which this resolver is creating the bindings.
 
Toggle controlling whether DOM bindings should be created when missing internal compiler bindings..
 
Set to true if initialized from a java project
 
 	boolean fromJavaProject;

Constructor for DefaultBindingResolver.
 
 	DefaultBindingResolver(CompilationUnitScope scopeWorkingCopyOwner workingCopyOwnerBindingTables bindingTablesboolean isRecoveringBindingsboolean fromJavaProject) {
 		this. = new HashMap();
 		this. = new HashMap();
 		this. = new HashMap();
 		this. = bindingTables;
 		this. = scope;
 		this. = workingCopyOwner;
 		this. = isRecoveringBindings;
 		this. = fromJavaProject;
 	}
 
 	DefaultBindingResolver(LookupEnvironment lookupEnvironmentWorkingCopyOwner workingCopyOwnerBindingTables bindingTablesboolean isRecoveringBindingsboolean fromJavaProject) {
 		this. = new HashMap();
 		this. = new HashMap();
 		this. = new HashMap();
 		this. = bindingTables;
 		this. = new CompilationUnitScope(new CompilationUnitDeclaration(nullnull, -1), lookupEnvironment);
 		this. = workingCopyOwner;
 		this. = isRecoveringBindings;
 		this. = fromJavaProject;
 	}
 
 	/*
 	 * Method declared on BindingResolver.
 	 */
 	synchronized ASTNode findDeclaringNode(IBinding binding) {
 		if (binding == null) {
 			return null;
 		}
 		if (binding instanceof IMethodBinding) {
 			IMethodBinding methodBinding = (IMethodBindingbinding;
 			return (ASTNodethis..get(methodBinding.getMethodDeclaration());
 		} else if (binding instanceof ITypeBinding) {
 			ITypeBinding typeBinding = (ITypeBindingbinding;
 			return (ASTNodethis..get(typeBinding.getTypeDeclaration());
 		} else if (binding instanceof IVariableBinding) {
 			IVariableBinding variableBinding = (IVariableBindingbinding;
 			return (ASTNodethis..get(variableBinding.getVariableDeclaration());
 		}
 		return (ASTNodethis..get(binding);
 	}
 
 	synchronized ASTNode findDeclaringNode(String bindingKey) {
 		if (bindingKey == null) {
 			return null;
 		}
 		Object binding = this...get(bindingKey);
 		if (binding == null)
 			return null;
 		return (ASTNodethis..get(binding);
 	}
 
 		switch (binding.kind()) {
 			case .:
 				return new TypeBinding(this, (org.eclipse.jdt.internal.compiler.lookup.TypeBindingbinding);
 			case .:
 			case .:
 			case .:
 		}
 		return null;
 	}
 
 		return new Util.BindingsToNodesMap() {
 			}
 		};
 	}
 
 		return (org.eclipse.jdt.internal.compiler.ast.ASTNodethis..get(currentNode);
 	}
 
 	/*
 	 * Method declared on BindingResolver.
 	 */
  		if (methodBinding != null && !methodBinding.isValidBinding()) {
 			methodBinding = problemMethodBinding.closestMatch;
  		}
 
 		if (methodBinding != null) {
 			if (!this. && ((methodBinding.tagBits & .) != 0)) {
 				return null;
 			}
 			if (binding != null) {
 				return binding;
 			}
 			binding = new MethodBinding(thismethodBinding);
 			this...put(methodBindingbinding);
 			return binding;
 		}
 		return null;
 	}
 
 		if (valuePair == null || valuePair.binding == nullreturn null;
 		if (binding != null)
 			return binding;
 		binding = new MemberValuePairBinding(valuePairthis);
 		this...put(valuePairbinding);
 		return binding;
 	}
 
 	/*
 	 * Method declared on BindingResolver.
 	 */
 		if (packageBinding == null) {
 			return null;
 		}
 		if (binding != null) {
 			return binding;
 		}
 		binding = new PackageBinding(packageBindingthis);
 		this...put(packageBindingbinding);
 		return binding;
 	}
 	private int getTypeArguments(ParameterizedQualifiedTypeReference typeReference) {
 		TypeReference[][] typeArguments = typeReference.typeArguments;
 		int value = 0;
 		for (int i = 0, max = typeArguments.lengthi < maxi++) {
 			if ((typeArguments[i] != null) || (value != 0)) {
 				value++;
 			}
 		}
 		return value;
 	}

Returns the new type binding corresponding to the given variable declaration. This is used for recovered binding only.

The default implementation of this method returns null. Subclasses may reimplement.

Parameters:
variableDeclaration the given variable declaration
Returns:
the new type binding
 
 	synchronized ITypeBinding getTypeBinding(VariableDeclaration variableDeclaration) {
 		ITypeBinding binding = (ITypeBindingthis...get(variableDeclaration);
 		if (binding != null) {
 			return binding;
 		}
 		binding = new RecoveredTypeBinding(thisvariableDeclaration);
 		this...put(variableDeclarationbinding);
 		return binding;
 	}

Returns the new type binding corresponding to the given type. This is used for recovered binding only.

The default implementation of this method returns null. Subclasses may reimplement.

Parameters:
type the given type
Returns:
the new type binding
 
 	synchronized ITypeBinding getTypeBinding(Type type) {
 		if (binding != null) {
 			return binding;
 		}
 		binding = new RecoveredTypeBinding(thistype);
 		return binding;
 	}
 
 	/*
 	 * Method declared on BindingResolver.
 	 */
 		if (referenceBinding == null) {
 			return null;
 		} else if (!referenceBinding.isValidBinding()) {
 			switch(referenceBinding.problemId()) {
 					if (referenceBinding instanceof ProblemReferenceBinding) {
 						ProblemReferenceBinding problemReferenceBinding = (ProblemReferenceBindingreferenceBinding;
 						org.eclipse.jdt.internal.compiler.lookup.TypeBinding binding2 = problemReferenceBinding.closestMatch();
 						if (binding != null) {
 							return binding;
 						}
 						binding = new TypeBinding(thisbinding2);
 						return binding;
 					}
 					break;
 					if (!this.) {
 						return null;
 					}
 					if (binding != null) {
 						return binding;
 					}
 					if ((referenceBinding.tagBits & .) != 0) {
 						binding = new TypeBinding(thisreferenceBinding);
 					} else {
 						binding = new RecoveredTypeBinding(thisreferenceBinding);
 					}
 					this...put(referenceBindingbinding);
 					return binding;
 			}
 			return null;
 		} else {
 			if ((referenceBinding.tagBits & .) != 0 && !this.) {
 				return null;
 			}
 			if (binding != null) {
 				return binding;
 			}
 			binding = new TypeBinding(thisreferenceBinding);
 			this...put(referenceBindingbinding);
 			return binding;
 		}
 	}
 
 	/*
 	 * Method declared on BindingResolver.
 	 */
 	synchronized ITypeBinding getTypeBinding(RecoveredTypeBinding recoveredTypeBindingint dimensions) {
 		if (recoveredTypeBinding== null) {
 			return null;
 		}
 		return new RecoveredTypeBinding(thisrecoveredTypeBindingdimensions);
 	}
 
 	synchronized IVariableBinding getVariableBinding(org.eclipse.jdt.internal.compiler.lookup.VariableBinding variableBindingVariableDeclaration variableDeclaration) {
 		if (this.) {
 			if (variableBinding != null) {
 				if (variableBinding.isValidBinding()) {
 					if (binding != null) {
 						return binding;
 					}
 					if (variableBinding.type != null) {
 						binding = new VariableBinding(thisvariableBinding);
 					} else {
 						binding = new RecoveredVariableBinding(thisvariableDeclaration);
 					}
 					this...put(variableBindingbinding);
 					return binding;
 				} else {
 					/*
 					 * http://dev.eclipse.org/bugs/show_bug.cgi?id=24449
 					 */
 					if (variableBinding instanceof ProblemFieldBinding) {
 						ProblemFieldBinding problemFieldBinding = (ProblemFieldBindingvariableBinding;
 						switch(problemFieldBinding.problemId()) {
 								ReferenceBinding declaringClass = problemFieldBinding.declaringClass;
 								FieldBinding exactBinding = declaringClass.getField(problemFieldBinding.nametrue /*resolve*/);
 								if (exactBinding != null) {
 									if (variableBinding2 != null) {
 										return variableBinding2;
 									}
 									variableBinding2 = new VariableBinding(thisexactBinding);
 									this...put(exactBindingvariableBinding2);
 									return variableBinding2;
 								}
 								break;
 						}
 					}
 				}
 			}
 			return null;
 		}
 		return this.getVariableBinding(variableBinding);
 	}
 
 		return this.;
 	}
 
 	/*
 	 * Method declared on BindingResolver.
 	 */
 		if (variableBinding != null) {
 			if (variableBinding.isValidBinding()) {
 				org.eclipse.jdt.internal.compiler.lookup.TypeBinding variableType = variableBinding.type;
 				if (variableType != null) {
 					if (!this. && ((variableType.tagBits & .) != 0)) {
 						return null;
 					}
 					if (binding != null) {
 						return binding;
 					}
 					binding = new VariableBinding(thisvariableBinding);
 					this...put(variableBindingbinding);
 					return binding;
 				}
 			} else {
 				/*
 				 * http://dev.eclipse.org/bugs/show_bug.cgi?id=24449
 				 */
 				if (variableBinding instanceof ProblemFieldBinding) {
 					ProblemFieldBinding problemFieldBinding = (ProblemFieldBindingvariableBinding;
 					switch(problemFieldBinding.problemId()) {
 							ReferenceBinding declaringClass = problemFieldBinding.declaringClass;
 							FieldBinding exactBinding = declaringClass.getField(problemFieldBinding.nametrue /*resolve*/);
 							if (exactBinding != null) {
 								if (variableBinding2 != null) {
 									return variableBinding2;
 								}
 								variableBinding2 = new VariableBinding(thisexactBinding);
 								this...put(exactBindingvariableBinding2);
 								return variableBinding2;
 							}
 							break;
 					}
 				}
 			}
 		}
 		return null;
 	}
 
 		if (internalInstance == nullreturn null;
 		ReferenceBinding annotationType = internalInstance.getAnnotationType();
 		if (!this.) {
 			if (annotationType == null || ((annotationType.tagBits & .) != 0)) {
 				return null;
 			}
 		}
 		IAnnotationBinding domInstance =
 		if (domInstance != null)
 			return domInstance;
 		domInstance = new AnnotationBinding(internalInstancethis);
 		this...put(internalInstancedomInstance);
 		return domInstance;
 	}
 
 		Object oldNode = this..get(methodInvocation);
 		if (oldNode instanceof MessageSend) {
 			MessageSend messageSend = (MessageSendoldNode;
 			org.eclipse.jdt.internal.compiler.lookup.MethodBinding methodBinding = messageSend.binding;
 			if (methodBinding instanceof ParameterizedGenericMethodBinding) {
 				ParameterizedGenericMethodBinding genericMethodBinding = (ParameterizedGenericMethodBindingmethodBinding;
 				return genericMethodBinding.inferredReturnType;
 			}
 		}
 		return false;
 	}
 
 		Object oldNode = this..get(superMethodInvocation);
 		if (oldNode instanceof MessageSend) {
 			MessageSend messageSend = (MessageSendoldNode;
 			org.eclipse.jdt.internal.compiler.lookup.MethodBinding methodBinding = messageSend.binding;
 			if (methodBinding instanceof ParameterizedGenericMethodBinding) {
 				ParameterizedGenericMethodBinding genericMethodBinding = (ParameterizedGenericMethodBindingmethodBinding;
 				return genericMethodBinding.inferredReturnType;
 			}
 		}
 		return false;
 	}
 
 		Object oldNode = this..get(classInstanceCreation);
 		if (oldNode instanceof AllocationExpression) {
 			AllocationExpression allocationExpression = (AllocationExpressionoldNode;
 			return allocationExpression.inferredReturnType;
 		}
 		return false;
 	}
 
 	/*
 	 * Method declared on BindingResolver.
 	 */
 		return this..environment();
 	}

 
 	synchronized void recordScope(ASTNode astNodeBlockScope blockScope) {
 		this..put(astNodeblockScope);
 	}
 
 	/*
 	 * @see BindingResolver#resolveBoxing(Expression)
 	 */
 	boolean resolveBoxing(Expression expression) {
 		if (node instanceof org.eclipse.jdt.internal.compiler.ast.Expression) {
 			return (compilerExpression.implicitConversion & .) != 0;
 		}
 		return false;
 	}
 
 	/*
 	 * @see BindingResolver#resolveUnboxing(Expression)
 	 */
 	boolean resolveUnboxing(Expression expression) {
 		if (node instanceof org.eclipse.jdt.internal.compiler.ast.Expression) {
 			return (compilerExpression.implicitConversion & .) != 0;
 		}
 		return false;
 	}
 
 	/*
 	 * @see BindingResolver#resolveConstantExpressionValue(Expression)
 	 */
 		if (node instanceof org.eclipse.jdt.internal.compiler.ast.Expression) {
 			Constant constant = compilerExpression.constant;
 			if (constant != null && constant != .) {
 				switch (constant.typeID()) {
 					case . : return new Integer(constant.intValue());
 					case . : return new Byte(constant.byteValue());
 					case . : return new Short(constant.shortValue());
 					case . : return new Character(constant.charValue());
 					case . : return new Float(constant.floatValue());
 					case . : return new Double(constant.doubleValue());
 					case . : return constant.booleanValue() ? . : .;
 					case . : return new Long(constant.longValue());
 					case . : return constant.stringValue();
 				}
 				return null;
 			}
 		}
 		return null;
 	}
 
 	/*
 	 * @see BindingResolver#resolveConstructor(ClassInstanceCreation)
 	 */
 		if (node != null && (node.bits & .......) != 0) {
 			return getMethodBinding(anonymousLocalTypeDeclaration.allocation.binding);
 		} else if (node instanceof AllocationExpression) {
 		}
 		return null;
 	}
 
 	/*
 	 * @see BindingResolver#resolveConstructor(ConstructorInvocation)
 	 */
 		if (node instanceof ExplicitConstructorCall) {
 			ExplicitConstructorCall explicitConstructorCall = (ExplicitConstructorCallnode;
 			return getMethodBinding(explicitConstructorCall.binding);
 		}
 		return null;
 	}
 
 	/* (non-Javadoc)
 	 * @see org.eclipse.jdt.core.dom.BindingResolver#resolveConstructor(org.eclipse.jdt.core.dom.EnumConstantDeclaration)
 	 */
 		if (node instanceof org.eclipse.jdt.internal.compiler.ast.FieldDeclaration) {
 			if (fieldDeclaration.getKind() == . && fieldDeclaration.initialization != null) {
 				AllocationExpression allocationExpression = (AllocationExpressionfieldDeclaration.initialization;
 				return getMethodBinding(allocationExpression.binding);
 			}
 		}
 		return null;
 	}
 
 	/*
 	 * @see BindingResolver#resolveConstructor(SuperConstructorInvocation)
 	 */
 		if (node instanceof ExplicitConstructorCall) {
 			ExplicitConstructorCall explicitConstructorCall = (ExplicitConstructorCallnode;
 			return getMethodBinding(explicitConstructorCall.binding);
 		}
 		return null;
 	}
 	/*
 	 * Method declared on BindingResolver.
 	 */
 	synchronized ITypeBinding resolveExpressionType(Expression expression) {
 		try {
 			switch(expression.getNodeType()) {
 					if (astNode instanceof org.eclipse.jdt.internal.compiler.ast.TypeDeclaration) {
 						// anonymous type case
 						ITypeBinding typeBinding = this.getTypeBinding(typeDeclaration.binding);
 						if (typeBinding != null) {
 							return typeBinding;
 						}
 					} else if (astNode instanceof AllocationExpression) {
 						// should be an AllocationExpression
 						AllocationExpression allocationExpression = (AllocationExpressionastNode;
 						return this.getTypeBinding(allocationExpression.resolvedType);
 					}
 					break;
 					return resolveTypeBindingForName((Nameexpression);
 					if (compilerExpression != null) {
 						return this.getTypeBinding(compilerExpression.resolvedType);
 					}
 					break;
 					if (this. != null) {
 						return this.getTypeBinding(this..getJavaLangString());
 					}
 					break;
 					Literal literal = (Literalthis..get(expression);
 					if (literal != null) {
 						return this.getTypeBinding(literal.literalType(null));
 					}
 					break;
 					ThisReference thisReference = (ThisReferencethis..get(expression);
 					BlockScope blockScope = (BlockScopethis..get(expression);
 					if (blockScope != null) {
 						return this.getTypeBinding(thisReference.resolveType(blockScope));
 					}
 					break;
 					ParenthesizedExpression parenthesizedExpression = (ParenthesizedExpressionexpression;
 					return resolveExpressionType(parenthesizedExpression.getExpression());
 					VariableDeclarationExpression variableDeclarationExpression = (VariableDeclarationExpressionexpression;
 					Type type = variableDeclarationExpression.getType();
 					if (type != null) {
 						return type.resolveBinding();
 					}
 					break;
 			}
 		} catch (AbortCompilation e) {
 			// handle missing types
 		}
 		return null;
 	}
 
 	/*
 	 * @see BindingResolver#resolveField(FieldAccess)
 	 */
 	synchronized IVariableBinding resolveField(FieldAccess fieldAccess) {
 		Object oldNode = this..get(fieldAccess);
 		if (oldNode instanceof FieldReference) {
 			FieldReference fieldReference = (FieldReferenceoldNode;
 			return this.getVariableBinding(fieldReference.binding);
 		}
 		return null;
 	}
 
 	/*
 	 * @see BindingResolver#resolveField(SuperFieldAccess)
 	 */
 	synchronized IVariableBinding resolveField(SuperFieldAccess fieldAccess) {
 		Object oldNode = this..get(fieldAccess);
 		if (oldNode instanceof FieldReference) {
 			FieldReference fieldReference = (FieldReferenceoldNode;
 			return this.getVariableBinding(fieldReference.binding);
 		}
 		return null;
 	}
 
 	/*
 	 * @see BindingResolver#resolveImport(ImportDeclaration)
 	 */
 	synchronized IBinding resolveImport(ImportDeclaration importDeclaration) {
 		if (this. == nullreturn null;
 		try {
 			if (node instanceof ImportReference) {
 				ImportReference importReference = (ImportReferencenode;
 				final boolean isStatic = importReference.isStatic();
 				if ((importReference.bits & .......) != 0) {
 					Binding binding = this..getImport(CharOperation.subarray(importReference.tokens, 0, importReference.tokens.length), trueisStatic);
 					if (binding != null) {
 						if (isStatic) {
 							if (binding instanceof org.eclipse.jdt.internal.compiler.lookup.TypeBinding) {
 								return typeBinding == null ? null : typeBinding;
 							}
 						} else {
 							if ((binding.kind() & .) != 0) {
 								if (packageBinding == null) {
 									return null;
 								}
 								return packageBinding;
 							} else {
 								// if it is not a package, it has to be a type
 								if (typeBinding == null) {
 									return null;
 								}
 								return typeBinding;
 							}
 						}
 					}
 				} else {
 					Binding binding = this..getImport(importReference.tokensfalseisStatic);
 					if (binding != null) {
 						if (isStatic) {
 							if (binding instanceof org.eclipse.jdt.internal.compiler.lookup.TypeBinding) {
 								return typeBinding == null ? null : typeBinding;
 							} else if (binding instanceof FieldBinding) {
 								IVariableBinding variableBinding = this.getVariableBinding((FieldBindingbinding);
 								return variableBinding == null ? null : variableBinding;
 							} else if (binding instanceof org.eclipse.jdt.internal.compiler.lookup.MethodBinding) {
 								// it is a type
 							}
 						} else {
 							if (binding instanceof org.eclipse.jdt.internal.compiler.lookup.TypeBinding) {
 								return typeBinding == null ? null : typeBinding;
 							}
 						}
 					}
 				}
 			}
 		} 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
 		}
 		return null;
 	}
 
 	/* (non-Javadoc)
 	 * @see org.eclipse.jdt.core.dom.BindingResolver#resolveMember(org.eclipse.jdt.core.dom.AnnotationTypeMemberDeclaration)
 	 */
 		Object oldNode = this..get(declaration);
 		if (oldNode instanceof AbstractMethodDeclaration) {
 			AbstractMethodDeclaration methodDeclaration = (AbstractMethodDeclarationoldNode;
 			IMethodBinding methodBinding = getMethodBinding(methodDeclaration.binding);
 			if (methodBinding == null) {
 				return null;
 			}
 			this..put(methodBindingdeclaration);
 			String key = methodBinding.getKey();
 			if (key != null) {
 				this...put(keymethodBinding);
 			}
 			return methodBinding;
 		}
 		return null;
 	}
 
 	/*
 	 * Method declared on BindingResolver.
 	 */
 	synchronized IMethodBinding resolveMethod(MethodDeclaration method) {
 		Object oldNode = this..get(method);
 		if (oldNode instanceof AbstractMethodDeclaration) {
 			AbstractMethodDeclaration methodDeclaration = (AbstractMethodDeclarationoldNode;
 			IMethodBinding methodBinding = getMethodBinding(methodDeclaration.binding);
 			if (methodBinding == null) {
 				return null;
 			}
 			this..put(methodBindingmethod);
 			String key = methodBinding.getKey();
 			if (key != null) {
 				this...put(keymethodBinding);
 			}
 			return methodBinding;
 		}
 		return null;
 	}
 	/*
 	 * Method declared on BindingResolver.
 	 */
 	synchronized IMethodBinding resolveMethod(MethodInvocation method) {
 		Object oldNode = this..get(method);
 		if (oldNode instanceof MessageSend) {
 			MessageSend messageSend = (MessageSendoldNode;
 			return getMethodBinding(messageSend.binding);
 		}
 		return null;
 	}
 	/*
 	 * Method declared on BindingResolver.
 	 */
 		Object oldNode = this..get(method);
 		if (oldNode instanceof MessageSend) {
 			MessageSend messageSend = (MessageSendoldNode;
 			return getMethodBinding(messageSend.binding);
 		}
 		return null;
 	}
 
 	synchronized ITypeBinding resolveTypeBindingForName(Name name) {
 		int index = name.index;
 		if (node instanceof QualifiedNameReference) {
 			QualifiedNameReference qualifiedNameReference = (QualifiedNameReferencenode;
 			final char[][] tokens = qualifiedNameReference.tokens;
 			if (tokens.length == index) {
 				return this.getTypeBinding(qualifiedNameReference.resolvedType);
 			}
 			int indexOfFirstFieldBinding = qualifiedNameReference.indexOfFirstFieldBinding// one-based
 			if (index < indexOfFirstFieldBinding) {
 				// an extra lookup is required
 				BlockScope internalScope = (BlockScopethis..get(name);
 				Binding binding = null;
 				try {
 					if (internalScope == null) {
 						if (this. == nullreturn null;
 						binding = this..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
 				}
 			} 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 == nullreturn null;