}
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 = 0; i < fRequiredAttrs.size(); i++) {
CMAttributeDeclaration attrDecl = (CMAttributeDeclaration) fRequiredAttrs.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(viewer.getDocument());
}
catch (BadLocationException e) {
// log, for now, unless we find there's reasons why we get some
// here.
Logger.log(Logger.INFO, e.getMessage());