}
else if (lastRegion.getType() == DOMRegionContext.XML_EMPTY_TAG_CLOSE) {
index = index - 2;
lastRegion = startStructuredDocumentRegion.getRegionAtCharacterOffset(index - 1);
}
MultiTextEdit multiTextEdit = new MultiTextEdit();
try {
for (int i = insertAttrs.size() - 1; i >= 0; i--) {
CMAttributeDeclaration attrDecl = (CMAttributeDeclaration) insertAttrs.get(i);
String requiredAttributeName = attrDecl.getAttrName();
String defaultValue = attrDecl.getDefaultValue();
if (defaultValue == null)
defaultValue = ""; //$NON-NLS-1$
String nameAndDefaultValue = " "; //$NON-NLS-1$
if (i == 0 && lastRegion.getLength() > lastRegion.getTextLength())
nameAndDefaultValue = ""; //$NON-NLS-1$
nameAndDefaultValue += requiredAttributeName + "=\"" + defaultValue + "\""; //$NON-NLS-1$ //$NON-NLS-2$
multiTextEdit.addChild(new InsertEdit(index, nameAndDefaultValue));
// BUG3381: MultiTextEdit applies all child
// TextEdit's basing on offsets
// in the document before the first TextEdit, not
// after each
// child TextEdit. Therefore, do not need to
// advance the index.
// index += nameAndDefaultValue.length();
}
multiTextEdit.apply(newNode.getStructuredDocument());
}
catch (BadLocationException e) {
// log or now, unless we find reason not to
Logger.log(Logger.INFO, e.getMessage());
}