* @param workspaceModuleNameResolver the module name resolver to use to generate an appropriate module name
* @param treeViewDisplayMode the display mode for the tree.
* @return a node for the module.
*/
private NavModuleNode makeModuleNode(final MetaModule metaModule, final ModuleNameResolver workspaceModuleNameResolver, TreeViewDisplayMode treeViewDisplayMode) {
ModuleTypeInfo moduleInfo = metaModule.getTypeInfo();
NavModuleNode moduleNode = new NavModuleNode(metaModule, workspaceModuleNameResolver, treeViewDisplayMode);
urlToNodeMap.put(moduleNode.getAddress(), moduleNode);
// Load all functions.
FunctionalAgent[] entities = moduleInfo.getFunctionalAgents();
if (entities.length > 0) {
NavVaultNode functionsNode = new NavFunctionVaultNode();
List<NavFunctionNode> functionNodes = new ArrayList<NavFunctionNode>();
for (final FunctionalAgent entity : entities) {
if (entity instanceof Function) {
functionNodes.add(new NavFunctionNode((Function) entity));
}
}
if (functionNodes.size() > 0) {
moduleNode.add(functionsNode);
urlToNodeMap.put(functionsNode.getAddress(), functionsNode);
addAllNodes(functionsNode, functionNodes, false);
}
}
// Load all the type constructors.
int constructorCount = moduleInfo.getNTypeConstructors();
if (constructorCount > 0) {
List<NavTreeNode> typeConstructorNodes = new ArrayList<NavTreeNode>(constructorCount);
for (int i = 0; i < constructorCount; i++) {
TypeConstructor typeConstructor = moduleInfo.getNthTypeConstructor(i);
NavTreeNode typeConstructorNode = new NavTypeConstructorNode(typeConstructor);
typeConstructorNodes.add(typeConstructorNode);
// Load the data constructors.
int dataConstructorCount = typeConstructor.getNDataConstructors();
for (int n = 0; n < dataConstructorCount; n++) {
NavTreeNode dataConstructorNode = new NavDataConstructorNode(typeConstructor.getNthDataConstructor(n));
typeConstructorNode.add(dataConstructorNode);
urlToNodeMap.put(dataConstructorNode.getAddress(), dataConstructorNode);
}
}
NavVaultNode typeConstructorsNode = new NavTypeConstructorVaultNode();
moduleNode.add(typeConstructorsNode);
urlToNodeMap.put(typeConstructorsNode.getAddress(), typeConstructorsNode);
addAllNodes(typeConstructorsNode, typeConstructorNodes, false);
}
// Load all the type classes.
int classCount = moduleInfo.getNTypeClasses();
if (classCount > 0) {
List<NavTreeNode> classNodes = new ArrayList<NavTreeNode>(classCount);
for (int i = 0; i < classCount; i++) {
TypeClass typeClass = moduleInfo.getNthTypeClass(i);
NavTreeNode typeClassNode = new NavTypeClassNode(typeClass);
classNodes.add(typeClassNode);
// Load the class methods.
int methodCount = typeClass.getNClassMethods();
if (methodCount > 0) {
List<NavClassMethodNode> classMethodNodes = new ArrayList<NavClassMethodNode>(methodCount);
for (int n = 0; n < methodCount; n++) {
classMethodNodes.add(new NavClassMethodNode(typeClass.getNthClassMethod(n)));
}
addAllNodes(typeClassNode, classMethodNodes, false);
}
}
NavVaultNode classesNode = new NavTypeClassVaultNode();
moduleNode.add(classesNode);
urlToNodeMap.put(classesNode.getAddress(), classesNode);
addAllNodes(classesNode, classNodes, false);
}
// Load all the class instances
int instanceCount = moduleInfo.getNClassInstances();
if (instanceCount > 0) {
List<NavTreeNode> classInstanceNodes = new ArrayList<NavTreeNode>(instanceCount);
for (int n = 0; n < instanceCount; n++) {
ClassInstance instance = moduleInfo.getNthClassInstance(n);
NavTreeNode classInstanceNode = new NavClassInstanceNode(moduleInfo.getNthClassInstance(n), moduleInfo);
classInstanceNodes.add(classInstanceNode);
// Load the instance methods.
int methodCount = instance.getNInstanceMethods();
if (methodCount > 0) {
List<NavInstanceMethodNode> instanceMethodNodes = new ArrayList<NavInstanceMethodNode>(methodCount);
for (int k = 0; k < methodCount; k++) {
String methodName = instance.getTypeClass().getNthClassMethod(k).getName().getUnqualifiedName();
instanceMethodNodes.add(new NavInstanceMethodNode(moduleInfo.getNthClassInstance(n), methodName, moduleInfo));
}
addAllNodes(classInstanceNode, instanceMethodNodes, false);
}
}