final SwiftJavaType swiftJavaType = new SwiftJavaType(documentContext.getNamespace(),
TemplateContextGenerator.mangleJavatypeName(type.getName()), javaNamespace);
if (visitable instanceof Typedef) {
// Typedef checks must be done before the type is added to the registry. Otherwise it would be possible
// to have a typedef point at itself.
final Typedef typedef = Typedef.class.cast(visitable);
LOG.debug("Checking typedef '{}' as '{}'.", typedef.getType(), typedef.getName());
final TypeToJavaConverter typeConverter = documentContext.getTypeConverter();
Preconditions.checkNotNull(typeConverter.convertType(typedef.getType()), "typedef %s uses unknown type %s!", typedef.getName(), typedef.getType().toString());
documentContext.getTypedefRegistry().add(swiftJavaType, typedef.getType());
}
LOG.debug("Registering type '{}'", swiftJavaType);
documentContext.getTypeRegistry().add(swiftJavaType);
}