public static TypeDeclaration findTypeDeclaration(CompilationUnit root, ITypeBinding binding) { ArrayList names= new ArrayList(5); while (binding != null) { names.add(binding.getName()); binding= binding.getDeclaringClass(); } List types= root.types(); for (int i= names.size() - 1; i >= 0; i--) { String name= (String) names.get(i); TypeDeclaration decl= findTypeDeclaration(types, name); if (decl == null || i == 0) { return decl;
private static TypeDeclaration findTypeDeclaration(List decls, String name) { for (Iterator iter= decls.iterator(); iter.hasNext();) { ASTNode elem= (ASTNode) iter.next(); if (elem instanceof TypeDeclaration) { TypeDeclaration decl= (TypeDeclaration) elem; if (name.equals(decl.getName().getIdentifier())) { return decl; }
	public static TypeDeclaration findTypeDeclaration(CompilationUnit root, ITypeBinding binding) {		ArrayList names= new ArrayList(5);		while (binding != null) {			names.add(binding.getName());			binding= binding.getDeclaringClass();		}		List types= root.types();		for (int i= names.size() - 1; i >= 0; i--) {			String name= (String) names.get(i);			TypeDeclaration decl= findTypeDeclaration(types, name);			if (decl == null || i == 0) {				return decl;			}			types= decl.bodyDeclarations();		}		return null;	}