String[] typeElements= Bindings.getNameComponents(type); IJavaElement element= scope.findElement(getPathToCompilationUnit(type.getPackage(), typeElements[0])); IType candidate= null; if (element instanceof ICompilationUnit) { candidate= JavaModelUtil.toWorkingCopy((ICompilationUnit)element).getType(typeElements[0]); } else if (element instanceof IClassFile) { candidate= ((IClassFile)element).getType(); } else if (element == null){ if (type.isMember()) candidate= JavaModelUtil.findType(scope, Bindings.getFullyQualifiedImportName(type.getDeclaringClass())); else candidate= JavaModelUtil.findType(scope, Bindings.getFullyQualifiedImportName(type)); }  if (candidate == null || typeElements.length == 1) return candidate;  return findTypeInType(typeElements, candidate);
IType declaringClass = find(declaringClassBinding, in); if (declaringClass == null) return null; IField foundField= declaringClass.getField(field.getName()); if (! foundField.exists()) return null; return foundField;
	public static IType find(ITypeBinding type, IJavaProject scope) throws JavaModelException {		if (type.isPrimitive())			return null;		String[] typeElements= Bindings.getNameComponents(type);		IJavaElement element= scope.findElement(getPathToCompilationUnit(type.getPackage(), typeElements[0]));		IType candidate= null;		if (element instanceof ICompilationUnit) {			candidate= JavaModelUtil.toWorkingCopy((ICompilationUnit)element).getType(typeElements[0]);		} else if (element instanceof IClassFile) {			candidate= ((IClassFile)element).getType();		} else if (element == null){			if (type.isMember())				candidate= JavaModelUtil.findType(scope, Bindings.getFullyQualifiedImportName(type.getDeclaringClass()));			else				candidate= JavaModelUtil.findType(scope, Bindings.getFullyQualifiedImportName(type));		}				if (candidate == null || typeElements.length == 1)			return candidate;					return findTypeInType(typeElements, candidate);	}