Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 347925 - Computation of ReferenceChange(Left/Right)Target is incorrect
Summary: Computation of ReferenceChange(Left/Right)Target is incorrect
Status: CLOSED FIXED
Alias: None
Product: EMFCompare
Classification: Modeling
Component: Core (show other bugs)
Version: unspecified   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: EMF Compare CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-06-01 08:46 EDT by Mikaël Barbero CLA
Modified: 2011-06-10 06:45 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mikaël Barbero CLA 2011-06-01 08:46:44 EDT
If an EReference references an EObject not being matched (i.e. outside of the resource set), ReferencesCheck#createNonConflictingReferencesUpdate(DiffGroup, EReference, EObject, EObject) and ReferencesCheck#checkReferenceUpdates(DiffGroup, Match3Elements, ERerefence) does not check for referencing the same EObject.

It can be corrected by removing identical EObject from addedReferences and deletedReferences lists:

// check that added references are not in deleted references (FIXME: may be necessary to add non
// resolved proxy handling)
for (EObject addedReference : new ArrayList<EObject>(addedReferences)) {
	if (deletedReferences.contains(addedReference)) {
		deletedReferences.remove(addedReference);
		addedReferences.remove(addedReference);
	}
}

It has to be added at first position inside the last 'else' of createNonConflictingReferencesUpdate() and checkReferenceUpdates()

Mika
Comment 1 Mikaël Barbero CLA 2011-06-01 08:57:03 EDT
You obviously don't even have to check for list containment: 

for (EObject addedReference : new ArrayList<EObject>(addedReferences)) {
	deletedReferences.remove(addedReference);
	addedReferences.remove(addedReference);
}
Comment 2 Mikaël Barbero CLA 2011-06-01 09:10:59 EDT
It also has to be done on deletedReferences list:

for (EObject deletedReference : new ArrayList<EObject>(deletedReferences)) {
	deletedReferences.remove(deletedReference);
	addedReferences.remove(deletedReference);
}
Comment 3 Laurent Goubet CLA 2011-06-10 06:45:45 EDT
Fixed on master and backported for 1.2.1