if (!typeBinding.isFromSource()) { return null; } while (typeBinding != null && !typeBinding.isTopLevel()) { typeBinding= typeBinding.getDeclaringClass(); } if (typeBinding != null) { IPackageBinding pack= typeBinding.getPackage(); String packageName= pack.isUnnamed() ? "" : pack.getName(); IType type= project.findType(packageName, typeBinding.getName()); if (type != null) { return type.getCompilationUnit();
ICompilationUnit originalFindCompilationUnit= originalFindCompilationUnit(typeBinding, project); if (CHECK_CORE_BINDING_GET_JAVA_ELEMENT) { IType type= (IType) typeBinding.getJavaElement(); if (type == null) { if (originalFindCompilationUnit != null) { JavaPlugin.logRepeatedMessage("ITypeBinding#getJavaElement() is not supposed to be null", "typeBinding == " + typeBinding.getKey() + ", project == " + project.getElementName()); } } else { ICompilationUnit cu= type.getCompilationUnit(); if (cu != null && ! cu.equals(originalFindCompilationUnit) || cu == null && originalFindCompilationUnit != null) { JavaPlugin.logRepeatedMessage("ITypeBinding#getJavaElement() is not correct element", "typeBinding == " + typeBinding.getKey() + ", project == " + project.getElementName() + ", cu == " + cu + ", originalFindCompilationUnit == " + originalFindCompilationUnit); }
	public static ICompilationUnit findCompilationUnit(ITypeBinding typeBinding, IJavaProject project) throws JavaModelException {		if (!typeBinding.isFromSource()) {			return null;		}		while (typeBinding != null && !typeBinding.isTopLevel()) {			typeBinding= typeBinding.getDeclaringClass();		}		if (typeBinding != null) {			IPackageBinding pack= typeBinding.getPackage();			String packageName= pack.isUnnamed() ? "" : pack.getName(); //$NON-NLS-1$			IType type= project.findType(packageName, typeBinding.getName());			if (type != null) {				return type.getCompilationUnit();			}		}		return null;	}