typeClassClass.setJavaDoc(jdc);
// Build up a list of TypeClass names and sort.
List<String> typeClassNames = new ArrayList<String>();
for (int i = 0, n = moduleTypeInfo.getNTypeClasses(); i < n; ++i) {
TypeClass tc = moduleTypeInfo.getNthTypeClass(i);
if (tc.getScope().isPublic() != publicEntities) {
continue;
}
typeClassNames.add(tc.getName().getUnqualifiedName());
}
Collections.sort(typeClassNames);
if (typeClassNames.size() == 0) {
return;
}
bindingClass.addInnerClass(typeClassClass);
// Generate a QualifiedName field for each type class.
for (final String typeClassName : typeClassNames) {
TypeClass tc = moduleTypeInfo.getTypeClass(typeClassName);
// Add a field for the TypeClass name.
// 'static final String typeClassName = "typeClassName";'
// We need to check for conflict between the functionName
// and java keywords. It is valid to have a CAL
// function called assert but not valid to have java code
// 'static final QualifiedName assert = ...
String fieldName = fixupVarName(typeClassName);
// Since TypeClass names are capitalized it's possible to have a conflict
// between the name of the field and the name of the top level class.
if (fieldName.equals(this.bindingClassName)) {
fieldName = fieldName + "_";
}
JavaFieldDeclaration jfd =
makeQualifiedNameDeclaration(fieldName, typeClassName);
// Add JavaDoc. We use any CALDoc for the type class if available.
JavaDocComment comment;
CALDocComment cdc = tc.getCALDocComment();
if (cdc != null) {
comment = new JavaDocComment(calDocCommentToJavaComment(cdc, null, false));
} else {
comment = new JavaDocComment("/** Name binding for TypeClass: " + tc.getName().getQualifiedName() + ". */");
}
jfd.setJavaDoc(comment);
typeClassClass.addFieldDeclaration(jfd);
}