Set<String> removedMembers = new HashSet<String>(existingKeySet);
removedMembers.removeAll(newKeySet);
for(String memberName: commonMembers) {
Object value = newMemberValues.get(memberName);
MemberValuePair memberValuePair =
ASTTools.memberValuePair(normalAnnotation, memberName);
if (value != null) {
MemberValuePair newValuePair = createMemberValuePair(ast, memberName, value);
listRewrite.replace(memberValuePair, newValuePair, null);
} else {
listRewrite.remove(memberValuePair, null);
}
}
for(String memberName: newMembers) {
Object value = newMemberValues.get(memberName);
if (value != null) {
MemberValuePair newValuePair = createMemberValuePair(ast, memberName, value);
// TODO: should attempt to preserve order
listRewrite.insertLast(newValuePair, null);
} else {
// nothing to do
}
}
for(String memberName: removedMembers) {
MemberValuePair memberValuePair =
ASTTools.memberValuePair(normalAnnotation, memberName);
listRewrite.remove(memberValuePair, null);
}
// TODO: earlier implementation; to remove