void generateUsageIndicesForTypeConsOrTypeClass(ScopedEntity documentedEntity, Map<QualifiedName, Map<ModuleName, Pair<TreeSet<FunctionalAgent>, TreeSet<FunctionalAgent>>>> usageIndices) {
if (!(documentedEntity instanceof TypeConstructor || documentedEntity instanceof TypeClass)) {
throw new IllegalArgumentException();
}
ModuleName moduleName = documentedEntity.getName().getModuleName();
// obtain the argument and return type indices from the usageIndices map
Map<ModuleName, Pair<TreeSet<FunctionalAgent>, TreeSet<FunctionalAgent>>> theMap = usageIndices.get(documentedEntity.getName());
////
/// generate for the defining module first
//
Pair<TreeSet<FunctionalAgent>, TreeSet<FunctionalAgent>> usageIndicesForTypeConsForDefiningModule = (theMap != null) ? theMap.get(moduleName) : null;
generateUsageIndicesForDependentModule(documentedEntity, moduleName, usageIndicesForTypeConsForDefiningModule);
////
/// then generate for the other dependent modules:
//
// get a new list for the names of the directly dependent modules, so that it can be filtered and sorted later
Set<ModuleName> directlyDependentModuleNamesSet = getDirectlyDependentModuleNames(moduleName);
List<ModuleName> directlyDependentModuleNames = new ArrayList<ModuleName>(directlyDependentModuleNamesSet);
// filter the list of dependent modules
directlyDependentModuleNames = filterModuleNames(directlyDependentModuleNames);
// sort the list of dependent modules
Collections.sort(directlyDependentModuleNames);
// loop through each directly dependent module (excluding the defining module) and document the usages in each.
int nDependentModules = directlyDependentModuleNames.size();
for (int j = 0; j < nDependentModules; j++) {
ModuleName dependentModuleName = directlyDependentModuleNames.get(j);
Pair<TreeSet<FunctionalAgent>, TreeSet<FunctionalAgent>> usageIndicesForTypeCons = (theMap != null) ? theMap.get(dependentModuleName) : null;
if (!dependentModuleName.equals(moduleName)) {
generateUsageIndicesForDependentModule(documentedEntity, dependentModuleName, usageIndicesForTypeCons);
}
}
}