buffer.append(getAdditionalMetadataHtml(owner, metadata, null));
}
} else {
// add the basic metadata, then the metadata specific sections, and finally put the additional sections at the bottom
CALFeatureName featureName = url.toFeatureName();
// in the following if-else checks, if the metadata is null, it will fail all the instanceof checks
// and simply fall off the end with no additional HTML generated, which is what is intended in such cases.
if (metadata instanceof FunctionalAgentMetadata) {
QualifiedName qualifiedName = featureName.toQualifiedName();
ModuleTypeInfo moduleTypeInfoForFeature = owner.getPerspective().getMetaModule(qualifiedName.getModuleName()).getTypeInfo();
FunctionalAgent envEntity = moduleTypeInfoForFeature.getFunctionalAgent(qualifiedName.getUnqualifiedName());
boolean isRequiredClassMethod = false;
if (envEntity instanceof ClassMethod) {
ClassMethod method = (ClassMethod)envEntity;
isRequiredClassMethod = (method.getDefaultClassMethodName() == null); // no default -> required
}
CALDocComment caldoc = envEntity.getCALDocComment();
buffer.append(getBasicMetadataHtml(owner, metadata, caldoc));
buffer.append(getFunctionalAgentMetadataHtml(owner, (FunctionalAgentMetadata) metadata, url, caldoc, isRequiredClassMethod));
buffer.append(getAdditionalMetadataHtml(owner, metadata, caldoc));
} else if (metadata instanceof ModuleMetadata) {
ModuleName moduleName = featureName.toModuleName();
ModuleTypeInfo moduleTypeInfoForFeature = owner.getPerspective().getMetaModule(moduleName).getTypeInfo();
CALDocComment caldoc = moduleTypeInfoForFeature.getCALDocComment();
buffer.append(getBasicMetadataHtml(owner, metadata, caldoc));
buffer.append(getModuleMetadataHtml(owner, (ModuleMetadata) metadata));
buffer.append(getAdditionalMetadataHtml(owner, metadata, caldoc));
} else if (metadata instanceof TypeClassMetadata) {
QualifiedName qualifiedName = featureName.toQualifiedName();
ModuleTypeInfo moduleTypeInfoForFeature = owner.getPerspective().getMetaModule(qualifiedName.getModuleName()).getTypeInfo();
TypeClass typeClass = moduleTypeInfoForFeature.getTypeClass(qualifiedName.getUnqualifiedName());
CALDocComment caldoc = typeClass.getCALDocComment();
buffer.append(getBasicMetadataHtml(owner, metadata, caldoc));
buffer.append(getTypeClassMetadataHtml(owner, (TypeClassMetadata) metadata));
buffer.append(getAdditionalMetadataHtml(owner, metadata, caldoc));
} else if (metadata instanceof TypeConstructorMetadata) {
QualifiedName qualifiedName = featureName.toQualifiedName();
ModuleTypeInfo moduleTypeInfoForFeature = owner.getPerspective().getMetaModule(qualifiedName.getModuleName()).getTypeInfo();
TypeConstructor typeCons = moduleTypeInfoForFeature.getTypeConstructor(qualifiedName.getUnqualifiedName());
CALDocComment caldoc = typeCons.getCALDocComment();
buffer.append(getBasicMetadataHtml(owner, metadata, caldoc));
buffer.append(getTypeConstructorMetadataHtml(owner, (TypeConstructorMetadata) metadata));
buffer.append(getAdditionalMetadataHtml(owner, metadata, caldoc));
} else if (metadata instanceof ClassInstanceMetadata) {
ClassInstanceIdentifier classInstanceID = featureName.toInstanceIdentifier();
ModuleTypeInfo moduleTypeInfoForFeature = owner.getPerspective().getMetaModule(featureName.toModuleName()).getTypeInfo();
ClassInstance instance = moduleTypeInfoForFeature.getClassInstance(classInstanceID);
CALDocComment caldoc = instance.getCALDocComment();
buffer.append(getBasicMetadataHtml(owner, metadata, caldoc));
buffer.append(getClassInstanceMetadataHtml(owner, (ClassInstanceMetadata) metadata));
buffer.append(getAdditionalMetadataHtml(owner, metadata, caldoc));
} else if (metadata instanceof InstanceMethodMetadata) {
ClassInstanceIdentifier classInstanceID = featureName.toInstanceIdentifier();
ModuleTypeInfo moduleTypeInfoForFeature = owner.getPerspective().getMetaModule(featureName.toModuleName()).getTypeInfo();
ClassInstance instance = moduleTypeInfoForFeature.getClassInstance(classInstanceID);
CALDocComment caldoc = instance.getMethodCALDocComment(featureName.toInstanceMethodName());
buffer.append(getBasicMetadataHtml(owner, metadata, caldoc));
buffer.append(getInstanceMethodMetadataHtml(owner, (InstanceMethodMetadata) metadata, url, caldoc));
buffer.append(getAdditionalMetadataHtml(owner, metadata, caldoc));
}
}