}
if (!nodeIterator.hasNext()) {
error = NLS.bind(XMLUIMessages.__Has_no_known_child, (new Object[]{parent.getNodeName()}));
}
while (nodeIterator.hasNext()) {
CMNode elementDecl = (CMNode) nodeIterator.next();
if (elementDecl != null) {
// only add proposals for the child element's that begin with the matchstring
String proposedText = null;
int cursorAdjustment = 0;
//determine if strict suggestion
boolean isStrictCMNodeSuggestion =
strictCMNodeSuggestions != null ? strictCMNodeSuggestions.contains(elementDecl) : false;
// do a check to see if partial attributes of partial tag names are in list
if (((node != null) && (node.getAttributes() != null) &&
(node.getAttributes().getLength() > 0) &&
attributeInList(node, parent, elementDecl)) ||
((node.getNodeType() != Node.TEXT_NODE) &&
node.getFirstStructuredDocumentRegion().isEnded())) {
proposedText = getRequiredName(parent, elementDecl);
cursorAdjustment = proposedText.length();
}
else {
proposedText = getRequiredName(parent, elementDecl);
cursorAdjustment = proposedText.length();
if (elementDecl instanceof CMElementDeclaration) {
CMElementDeclaration ed = (CMElementDeclaration) elementDecl;
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=89811
StringBuffer sb = new StringBuffer();
getContentGenerator().generateTag(parent, ed, sb);
// since it's a name proposal, assume '<' is already there
// only return the rest of the tag
proposedText = sb.toString().substring(1);
cursorAdjustment = getCursorPositionForProposedText(proposedText);
}
}
if (beginsWith(proposedText, matchString)) {
//get the proposal image
Image image = CMImageUtil.getImage(elementDecl);
if (image == null) {
if (strictCMNodeSuggestions != null) {
image = isStrictCMNodeSuggestion ? this.getEmphasizedTagImage() : this.getDeemphasizedTagImage();
} else {
image = this.getGenericTagImage();
}
}
int relevance = isStrictCMNodeSuggestion ? XMLRelevanceConstants.R_STRICTLY_VALID_TAG_NAME : XMLRelevanceConstants.R_TAG_NAME;
String proposedInfo = getAdditionalInfo(getCMElementDeclaration(parent), elementDecl);
CustomCompletionProposal proposal = new MarkupCompletionProposal(
proposedText, contentAssistRequest.getReplacementBeginPosition(),
contentAssistRequest.getReplacementLength(), cursorAdjustment, image,
getRequiredName(parent, elementDecl), null, proposedInfo,
relevance);
contentAssistRequest.addProposal(proposal);
}
}
}
if (contentAssistRequest.getProposals().size() == 0) {
if (error != null) {
setErrorMessage(error);
}
else if ((contentAssistRequest.getMatchString() != null) && (contentAssistRequest.getMatchString().length() > 0)) {
setErrorMessage(NLS.bind(
XMLUIMessages.No_known_child_tag_names,
(new Object[]{parent.getNodeName(), contentAssistRequest.getMatchString()})));
}
else {
setErrorMessage(NLS.bind(
XMLUIMessages.__Has_no_known_child,
(new Object[]{parent.getNodeName()})));
}
}
}
else if (parent.getNodeType() == Node.DOCUMENT_NODE) {
List childElements = getAvailableRootChildren((Document) parent, childPosition);
if ( childElements.size() == 0) {
//No doctype available , treat it as empty document
addEmptyDocumentProposals(contentAssistRequest, context);
}
for (int i = 0; i < childElements.size(); i++) {
CMNode ed = (CMNode) childElements.get(i);
if (ed == null) {
continue;
}
String proposedText = null;
int cursorAdjustment = 0;