}
return result;
}
private SourceCodeChange extractParameterChange(Insert insert) {
SourceCodeChange result = null;
if (insert.getChangedEntity().getType() == JavaEntityType.PARAMETER) {
// SingleVariableDeclaration has changed, but the type node (child)
// remains the same => PARAMETER_RENAMING
Move mov =
findMoveOperation(
insert.getRootEntity().getType(),
insert.getRootEntity().getUniqueName(),
JavaEntityType.PARAMETER,
null,
JavaEntityType.PARAMETER,
insert.getChangedEntity().getUniqueName(),
null,
null);
Delete del =
findDeleteOperation(
insert.getRootEntity().getType(),
insert.getRootEntity().getUniqueName(),
JavaEntityType.PARAMETERS,
"",
JavaEntityType.PARAMETER,
insert.getChangedEntity().getUniqueName());
// parameter renaming
if (mov != null) {
Delete d =
findDeleteOperation(
insert.getRootEntity().getType(),
insert.getRootEntity().getUniqueName(),
JavaEntityType.PARAMETERS,
"",
JavaEntityType.PARAMETER,
mov.getParentEntity().getUniqueName());
if (d == null) {
insert.setChangeType(ChangeType.PARAMETER_INSERT);
result = insert;
} else {
result =
new Update(
insert.getRootEntity(),
insert.getChangedEntity(),
d.getChangedEntity(),
insert.getParentEntity());
result.setChangeType(ChangeType.PARAMETER_RENAMING);
fMoves.remove(mov);
fDeletes.remove(d);
}
// SingleVariableDeclaration remains the same but the type
// node (child) are not equal => PARAMETER_TYPE_CHANGE
} else if (del != null) {
Delete dell =
findDeleteOperation(
insert.getRootEntity().getType(),
insert.getRootEntity().getUniqueName(),
del.getChangedEntity().getType(),
del.getChangedEntity().getUniqueName(),
null,
null);
if (dell == null) {
insert.setChangeType(ChangeType.PARAMETER_INSERT);
result = insert;
} else {
// WTF how to remove the insert?
Insert i =
findInsertOperation(insert.getRootEntity().getType(), insert.getRootEntity()
.getUniqueName(), insert.getChangedEntity().getType(), insert.getChangedEntity()
.getUniqueName(), null, null);
if (i == null) {
insert.setChangeType(ChangeType.PARAMETER_INSERT);
result = insert;
} else {
result =
new Update(
insert.getRootEntity(),
dell.getChangedEntity(),
i.getChangedEntity(),
insert.getChangedEntity());
result.setChangeType(ChangeType.PARAMETER_TYPE_CHANGE);
fDeletes.remove(del);
fDeletes.remove(dell);
fInsertsToDelete.add(i);
}
}