Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 346607 - IMatchScope are not used to filter out model roots in GenericMatchEngine
Summary: IMatchScope are not used to filter out model roots in GenericMatchEngine
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-05-20 04:45 EDT by Mikaël Barbero CLA
Modified: 2012-05-22 09:29 EDT (History)
2 users (show)

See Also:
laurent.goubet: iplog+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mikaël Barbero CLA 2011-05-20 04:45:35 EDT
In GenericMatchEngine, MatchModel.leftRoots and MatchModel.rightRoots are always referencing all left and right resources roots without taking into account given IMatchScope. 

I think it is a bug as there is no reason to consider model roots as elements that can not be filtered out.

Here is the new setModelRoots(MatchModel, EObject, EObject, EObject) method. 

protected void setModelRoots(MatchModel modelRoot, EObject left, IMatchScope leftScope, EObject right, IMatchScope rightScope, EObject ancestor, IMatchScope ancestorScope) {
	// Sets values of left, right and ancestor model roots
	if (left != null && left.eResource() != null) {
		for (EObject contents : left.eResource().getContents()) {
			if (leftScope.isInScope(contents)) {
				modelRoot.getLeftRoots().add(contents);
			}
		}
	}
	if (right != null && right.eResource() != null) {
		for (EObject contents : right.eResource().getContents()) {
			if (rightScope.isInScope(contents)) {
				modelRoot.getRightRoots().add(contents);
			}
		}
	}
	if (ancestor != null && ancestor.eResource() != null) {
		for (EObject contents : ancestor.eResource().getContents()) {
			if (ancestorScope.isInScope(contents)) {
				modelRoot.getAncestorRoots().add(contents);
			}
		}
	}
}

and its direct caller for two-ways diff:

protected void setModelRoots(MatchModel modelRoot, EObject left, IMatchScope leftScope, EObject right, IMatchScope rightScope) {
	setModelRoots(modelRoot, left, leftScope, right, rightScope, null, null);
}

Then you just have to fix compilation errors by calling the new methods adding appropriate scopes (4 calls in GenericMatchEngine)
Comment 1 Laurent Goubet CLA 2011-07-21 05:53:28 EDT
Thanks for the feedback. This has now been fixed on master and will also find its way in the 1.2.1.