final Map<String, List<HaxeClassInfo>> result = new THashMap<String, List<HaxeClassInfo>>(classes.size());
final Map<String, String> qNameCache = new THashMap<String, String>();
for (AbstractHaxeTypeDefImpl haxeTypeDef : classes) {
final HaxeClassInfo value = new HaxeClassInfo(haxeTypeDef.getQualifiedName(), HaxeComponentType.typeOf(haxeTypeDef));
final HaxeTypeOrAnonymous haxeTypeOrAnonymous = haxeTypeDef.getTypeOrAnonymous();
final HaxeType type = haxeTypeOrAnonymous == null ? null : haxeTypeOrAnonymous.getType();
final HaxeAnonymousType anonymousType = haxeTypeOrAnonymous == null ? null : haxeTypeOrAnonymous.getAnonymousType();
if (anonymousType != null) {
final HaxeTypeExtends typeExtends = anonymousType.getAnonymousTypeBody().getTypeExtends();
if (typeExtends != null) {
final String classNameCandidate = typeExtends.getType().getText();
final String key = classNameCandidate.indexOf('.') != -1 ?
classNameCandidate :
getQNameAndCache(qNameCache, fileChildren, classNameCandidate);
put(result, key, value);
}
}
else if (type != null) {
final String classNameCandidate = type.getText();
final String qName = classNameCandidate.indexOf('.') != -1 ?
classNameCandidate :
getQNameAndCache(qNameCache, fileChildren, classNameCandidate);
put(result, qName, value);
}