text.append("<br>");
text.append(wrapTextToHTMLLines(metadata.getLongDescription(), parent));
text.append("<br>");
} else {
// If there is neither a short nor a long description, display the CALDoc description instead.
CALDocComment caldoc = scopedEntity.getCALDocComment();
if (caldoc != null) {
String caldocDesc = getHTMLForBoundedToolTipText(
NavHtmlFactory.getHtmlForCALDocSummaryWithNoHyperlinks(caldoc, locale, true), TOOLTIP_MAX_WIDTH, 0, true, parent);
if (caldocDesc.length() > 0) {
text.append(caldocDesc);
} else {
text.append("<br>");
}
} else {
text.append("<br>");
}
}
if (metadata instanceof FunctionalAgentMetadata) {
FunctionalAgent envEntity = (FunctionalAgent)scopedEntity;
PolymorphicVarContext polymorphicVarContext = PolymorphicVarContext.make();
TypeExpr[] typePieces = envEntity.getTypeExpr().getTypePieces();
CALDocComment caldoc = envEntity.getCALDocComment();
// Add the result type.
text.append("<br>");
text.append("<b>");
text.append(GemCutter.getResourceString("ToolTipHelper_Returns"));
text.append("</b>");
text.append("<br>");
String returnValueIndicator = "<i>" + GemCutter.getResourceString("ToolTipHelper_ReturnValueIndicator") + "</i>";
String returnType = typePieces[typePieces.length - 1].toString(polymorphicVarContext, namingPolicy);
String returnValueMetadata;
if (metadata instanceof FunctionMetadata) {
returnValueMetadata = ((FunctionMetadata)metadata).getReturnValueDescription();
} else if (metadata instanceof ClassMethodMetadata) {
returnValueMetadata = ((ClassMethodMetadata)metadata).getReturnValueDescription();
} else {
returnValueMetadata = null;
}
CALDocComment.TextBlock returnValueCALDoc;
if (caldoc != null) {
returnValueCALDoc = caldoc.getReturnBlock();
} else {
returnValueCALDoc = null;
}
buildTypeSignatureAndDescription(parent, text, returnValueIndicator, returnType, returnValueMetadata, returnValueCALDoc, true);
// Add the argument descriptions
NavAddressHelper.isMetadataValid(envEntity, (FunctionalAgentMetadata) metadata);
ArgumentMetadata[] arguments = ((FunctionalAgentMetadata) metadata).getArguments();
NavAddressHelper.adjustArgumentNames(envEntity, arguments);
if (arguments.length > 0) {
text.append("<br>");
text.append("<b>");
text.append(GemCutter.getResourceString("ToolTipHelper_Arguments"));
text.append("</b>");
// Process the tagged blocks in the CALDoc to extract the @arg blocks.
text.append("<br>");
for (int i = 0; i < arguments.length; i++) {
String displayName = arguments[i].getDisplayName();
String type = typePieces[i].toString(polymorphicVarContext, namingPolicy);
String descriptionFromMetadata = arguments[i].getShortDescription();
CALDocComment.TextBlock descriptionFromCALDoc;
if (caldoc != null && i < caldoc.getNArgBlocks()) {
descriptionFromCALDoc = caldoc.getNthArgBlock(i).getTextBlock();
} else {
descriptionFromCALDoc = null;
}
boolean shouldEmitLineBreakSuffix = i < arguments.length - 1;