ArrayType 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);
}
nNewBrackets= replacingType.getDimensions(); // is replaced type
}
voidVisit(arrayType);
try {
int offset= getScanner().getTokenStartOffset(TerminalTokens.TokenNameLBRACKET, arrayType.getStartPosition());
// dimension node with expressions
RewriteEvent dimEvent= getEvent(node, ArrayCreation.DIMENSIONS_PROPERTY);
boolean hasDimensionChanges= (dimEvent != null && dimEvent.getChangeKind() != RewriteEvent.UNCHANGED);
if (hasDimensionChanges) {
RewriteEvent[] events= dimEvent.getChildren();
// offset on first opening brace
for (int i= 0; i < events.length; i++) {
RewriteEvent event= events[i];
int changeKind= event.getChangeKind();
if (changeKind == RewriteEvent.INSERTED) { // insert new dimension
editGroup= getEditGroup(event);
doTextInsert(offset, "[", editGroup); //$NON-NLS-1$
doTextInsert(offset, (ASTNode) event.getNewValue(), 0, false, editGroup);
doTextInsert(offset, "]", editGroup); //$NON-NLS-1$
nNewBrackets--;
} else {
ASTNode elem= (ASTNode) event.getOriginalValue();
int elemEnd= elem.getStartPosition() + elem.getLength();
int endPos= getScanner().getTokenEndOffset(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);
nNewBrackets--;
} else {
voidVisit(elem);