in src/com/intellij/idea/plugin/hybris/system/type/model/generator/XSDModelLoader.java [328:440]
public void processType(
final XSComplexTypeDefinition def,
final List<XSModel> models,
final Map<String, TypeDesc> jtMap,
final Map<String, NamespaceDesc> nsdMap,
final ArrayList<XSComplexTypeDefinition> toAdd
) throws Exception {
if (!nsdMap.containsKey(def.getNamespace())) {
Util.log("Namespace desc not found for: " + def);
}
final String typeName = toJavaTypeName(def, nsdMap);
TypeDesc td = jtMap.get(model.toJavaQualifiedTypeName(def, nsdMap, false));
if (td != null) {
if (td.fdMap.size() == 0) {
// Util.log("Reusing forward decl: "+typeName);
} else {
Util.logerr("merging: type names collision: " + typeName);
}
} else {
td = new TypeDesc(def.getName(), def.getNamespace(), typeName, TypeDesc.TypeEnum.CLASS);
}
final XSObjectList anns = def.getAnnotations();
td.documentation = parseAnnotationString(
"Type " + def.getNamespace() + ':' + def.getName() + " documentation",
anns != null && anns.getLength() > 0 ? ((XSAnnotation) anns.item(0)).getAnnotationString() : null
);
TypeDesc tdBase = null;
if (checkComplexType(def.getBaseType())) {
final XSComplexTypeDefinition base = (XSComplexTypeDefinition) def.getBaseType();
final String typeNameBase = toJavaTypeName(base, nsdMap);
if ((tdBase = jtMap.get(model.toJavaQualifiedTypeName(base, nsdMap, false))) == null) {
// logwarn("forward decl: "+et);
tdBase = new TypeDesc(base.getName(), base.getNamespace(), typeNameBase, TypeDesc.TypeEnum.CLASS);
jtMap.put(model.toJavaQualifiedTypeName(base, nsdMap, false), tdBase);
}
}
if (def.getSimpleType() != null || def.getContentType() == XSComplexTypeDefinition.CONTENTTYPE_MIXED) {
final FieldDesc fd = new FieldDesc(FieldDesc.SIMPLE, "value", "String", null, "null", true);
fd.realIndex = td.fdMap.size();
td.fdMap.put(fd.name, fd);
}
final XSObjectList attrs = def.getAttributeUses();
for (int i = 0; i < attrs.getLength(); i++) {
final XSAttributeUse au = (XSAttributeUse) attrs.item(i);
final XSAttributeDeclaration ad = au.getAttrDeclaration();
final XSSimpleTypeDefinition atd = ad.getTypeDefinition();
final XSAnnotation ann = ad.getAnnotation();
final String documentation = parseAnnotationString(
"Attribute " + ad.getNamespace() + ':' + ad.getName() + " documentation",
ann != null ? ann.getAnnotationString() : null
);
// skip "ID" and "FIXED"
if ("ID".equals(atd.getName())) {
continue;
}
// "language", "dewey-versionType", "boolean"
if (ad.getConstraintType() == XSConstants.VC_FIXED) {
continue;
}
final FieldDesc fd1 = new FieldDesc(
FieldDesc.ATTR,
Util.toJavaFieldName(ad.getName()),
"String",
null,
"null",
au.getRequired()
);
fd1.tagName = ad.getName();
fd1.documentation = documentation;
fd1.realIndex = td.fdMap.size();
td.duplicates = Util.addToNameMap(td.fdMap, fd1, false) || td.duplicates;
// TODO: HACK !"collectiontype".equals(ad.getName()) &&
if (!"collectiontype".equals(ad.getName()) && checkEnumType(ad.getTypeDefinition())) {
XSTypeDefinition etRoot = ad.getTypeDefinition();
if (etRoot.getAnonymous()) {
etRoot = makeTypeFromAnonymous(ad);
if (toAdd != null) {
toAdd.add((XSComplexTypeDefinition) etRoot);
}
}
fd1.type = toJavaTypeName(etRoot, nsdMap);
fd1.contentQualifiedName = model.toJavaQualifiedTypeName(etRoot, nsdMap, true);
// forward decl
if (jtMap.get(fd1.contentQualifiedName) == null) {
// logwarn("forward decl: "+et);
final TypeDesc ftd = new TypeDesc(
etRoot.getName(),
etRoot.getNamespace(),
fd1.type,
TypeDesc.TypeEnum.ENUM
);
jtMap.put(fd1.contentQualifiedName, ftd);
// // anonymous (simple type) enum
// if (ad.getTypeDefinition().getAnonymous()) {
// processEnumType(ad.getTypeDefinition(), jtMap, nsdMap);
// }
}
} else {
fd1.simpleTypesString = getSimpleTypesString(ad.getTypeDefinition());
}
}
final LinkedList<PEntry> plist = new LinkedList<>();
if (def.getParticle() != null) {
plist.add(new PEntry(def.getParticle(), false));
}
processParticles(def, plist, nsdMap, jtMap, td, models, toAdd, tdBase);
jtMap.put(model.toJavaQualifiedTypeName(def, nsdMap, false), td);
if (td.fdMap.size() == 1 && def.getSimpleType() != null) {
// calc type hierarchy for simple content
final FieldDesc fd = td.fdMap.get("value");
fd.simpleTypesString = getSimpleTypesString(def);
}
}