replacingType= (ArrayType) typeEvent.getNewValue();
editGroup= getEditGroup(typeEvent);
Type newType= replacingType.getElementType();
Type oldType= getElementType(arrayType);
if (!newType.equals(oldType)) {
SourceRange range= getExtendedRange(oldType);
int offset= range.getStartPosition();
int length= range.getLength();
doTextRemove(offset, length, editGroup);
doTextInsert(offset, newType, 0, false, editGroup);
}
}
try {
// dimension node with expressions and/or annotations
RewriteEvent dimEvent= getEvent(node, ArrayCreation.DIMENSIONS_PROPERTY);
boolean hasDimensionChanges= (dimEvent != null && dimEvent.getChangeKind() != RewriteEvent.UNCHANGED);
RewriteEvent[] events= hasDimensionChanges ? dimEvent.getChildren() : null;
ArrayType currentLevel = astLevelGTE8 ? null : (ArrayType) replacingType.getElementType().getParent();
int replacingTypeDimensions = replacingType.getDimensions();
int i=0, dimSize= (events == null) ? 0 : events.length;
Type elementType= arrayType.getElementType();
int offset= elementType.getStartPosition() + elementType.getLength();
editGroup = null;
while(currentLevel != null || astLevelGTE8) {
if (i < dimSize) {
if (astLevelGTE8)
rewriteAnnotationsOnDimension(arrayType, replacingType, i, offset, typeReplaced, editGroup);
offset= getScanner().getTokenEndOffset(TerminalTokens.TokenNameLBRACKET, offset);
if (hasDimensionChanges) {
RewriteEvent event= events[i];
int changeKind= event.getChangeKind();
if (changeKind == RewriteEvent.INSERTED) { // insert new dimension
editGroup= getEditGroup(event);
int endPos= getScanner().getTokenStartOffset(TerminalTokens.TokenNameRBRACKET, offset);
doTextRemove(offset, endPos - offset, editGroup);
doTextInsert(offset, (ASTNode) event.getNewValue(), 0, false, editGroup);
} else {
ASTNode elem= (ASTNode) event.getOriginalValue();
int elemEnd= elem.getStartPosition() + elem.getLength();
int endPos= getScanner().getTokenStartOffset(TerminalTokens.TokenNameRBRACKET, elemEnd);
if (changeKind == RewriteEvent.REMOVED) {
editGroup= getEditGroup(event);
doTextRemoveAndVisit(offset, endPos - offset, elem, editGroup);
} else if (changeKind == RewriteEvent.REPLACED) {
editGroup= getEditGroup(event);
SourceRange range= getExtendedRange(elem);
int elemOffset= range.getStartPosition();
int elemLength= range.getLength();
doTextRemoveAndVisit(elemOffset, elemLength, elem, editGroup);
doTextInsert(elemOffset, (ASTNode) event.getNewValue(), 0, false, editGroup);
} else {
voidVisit(elem);
}