}
public void visitFunction(final Function oldFunction){
//ok, so I get an old function: is it modified in the new pkg? is it even present on it?
Function newFunction = newPkg.getFunction(oldFunction.getName());
if (newFunction == null){
//the old function is not present on the new package. Add it to
//removed rules list.
listener.debug("BinaryResourceDiffProducerImpl: "+oldFunction+" is not present anymore. Adding to removed list.");
this.removedDefinitions.add(oldFunction);
return;
}
//it is possible that the old function doesn't exist anymore in the current
//pkg. This is because maybe some other resouce updated its definition
//and after that the same resource removed it. If that is the case,
//this resource (the one we are processing) still contain a reference
//to the function, but it is no present on kbase anymore. If this is the
//case, we wan't to skip this function. Remember that someone
//modified it and removed it before this resource. We don't even
//add it to removedDefinitions, because it is no present on kbase. What
//we have to do is remove it from the new pkg so it won't reapears.
if (currentPkg.getFunction(oldFunction.getName()) == null){
listener.debug("BinaryResourceDiffProducerImpl: "+oldFunction+" is not present on current PKG. Removing from new package.");
newPkg.removeFunction(oldFunction.getName());
return;
}
//is newFunction equal to oldFunction?
if (newFunction.equals(oldFunction)){
//if so, we don't need the function in the new Package.
listener.debug("BinaryResourceDiffProducerImpl: "+oldFunction+" didn't change. Removing from diff package and adding it to unmodified list.");
newPkg.removeFunction(newFunction.getName());
this.unmodifiedDefinitions.add(oldFunction);
}else{
//it seems that the kbase doesn't overrides function's definitions.
//that's why we need to mark this function as removed, but don't
//remove it from the new pkg.