private static IType findType(ICompilationUnit cu, String fullyQualifiedName) throws JavaModelException{ IType[] types= cu.getAllTypes(); for (int i= 0; i < types.length; i++) { IType type= types[i]; if (getFullyQualifiedName(type).equals(fullyQualifiedName)) return type; } return null; }
/** * Returns the fully qualified name of a type's container. (package name or enclosing type name) */ public static String getTypeContainerName(IType type) { IType outerType= type.getDeclaringType(); if (outerType != null) { return getFullyQualifiedName(outerType); } else { return type.getPackageFragment().getElementName(); } }
/** * Returns the fully qualified name of the given type using '.' as separators. * This is a replace for IType.getFullyQualifiedTypeName * which uses '$' as separators. As '$' is also a valid character in an id * this is ambiguous. JavaCore PR: 1GCFUNT */ public static String getFullyQualifiedName(IType type) { try { if (type.isBinary() && !type.isAnonymous()) { IType declaringType= type.getDeclaringType(); if (declaringType != null) { return getFullyQualifiedName(declaringType) + '.' + type.getElementName(); } } } catch (JavaModelException e) { // ignore } return type.getFullyQualifiedName('.'); }