try {
IDOMNode node = (IDOMNode) ContentAssistUtils.getNodeAt(viewer, offset);
IStructuredDocumentRegion startStructuredDocumentRegion = node.getStartStructuredDocumentRegion();
ITextRegion region = (startStructuredDocumentRegion == null) ? null : startStructuredDocumentRegion.getRegionAtCharacterOffset(offset);
if (region != null) {
group.addPosition(new LinkedPosition(document, startStructuredDocumentRegion.getStartOffset() + region.getStart(), region.getTextLength(), 0));
if ((region.getType() == DOMRegionContext.XML_TAG_NAME) && (node.getEndStructuredDocumentRegion() != null)) {
region = node.getEndStructuredDocumentRegion().getRegions().get(1);
if (region != null) {
group.addPosition(new LinkedPosition(document, node.getEndStructuredDocumentRegion().getStartOffset() + region.getStart(), region.getTextLength(), 1));
}
}
}
else {
IStructuredDocumentRegion endStructuredDocumentRegion = node.getEndStructuredDocumentRegion();
region = (endStructuredDocumentRegion == null) ? null : endStructuredDocumentRegion.getRegionAtCharacterOffset(offset);
if (region != null) {
if ((region.getType() == DOMRegionContext.XML_TAG_NAME) && (node.getStartStructuredDocumentRegion() != null)) {
ITextRegion startTagNameRegion = node.getStartStructuredDocumentRegion().getRegions().get(1);
if (region != null) {
group.addPosition(new LinkedPosition(document, node.getStartStructuredDocumentRegion().getStartOffset() + startTagNameRegion.getStart(), startTagNameRegion.getTextLength(), 0));
group.addPosition(new LinkedPosition(document, endStructuredDocumentRegion.getStartOffset() + region.getStart(), region.getTextLength(), 1));
}
}
else {
group.addPosition(new LinkedPosition(document, endStructuredDocumentRegion.getStartOffset() + region.getStart(), region.getTextLength(), 0));
}
}
}
// TODO CompletionProposalPopup#insertProposal() calls