diff options
author | lgoubet | 2011-08-04 12:16:02 +0000 |
---|---|---|
committer | lgoubet | 2011-08-08 08:37:26 +0000 |
commit | fb8e006d4129ee4182540416454bb5882610492c (patch) | |
tree | 518ad4ee0596d3d245620e323fa023ff8c6cb5f3 | |
parent | 909684c0e41d5aa49e5604cd4abadcedbd04ff58 (diff) | |
download | org.eclipse.emf.compare-fb8e006d4129ee4182540416454bb5882610492c.tar.gz org.eclipse.emf.compare-fb8e006d4129ee4182540416454bb5882610492c.tar.xz org.eclipse.emf.compare-fb8e006d4129ee4182540416454bb5882610492c.zip |
Make sure that 3-way Comparisons of EObjects with no resource don't
fail.
-rw-r--r-- | plugins/org.eclipse.emf.compare.match/src/org/eclipse/emf/compare/match/engine/GenericMatchEngine.java | 53 |
1 files changed, 36 insertions, 17 deletions
diff --git a/plugins/org.eclipse.emf.compare.match/src/org/eclipse/emf/compare/match/engine/GenericMatchEngine.java b/plugins/org.eclipse.emf.compare.match/src/org/eclipse/emf/compare/match/engine/GenericMatchEngine.java index ed817d9c7..d9135422f 100644 --- a/plugins/org.eclipse.emf.compare.match/src/org/eclipse/emf/compare/match/engine/GenericMatchEngine.java +++ b/plugins/org.eclipse.emf.compare.match/src/org/eclipse/emf/compare/match/engine/GenericMatchEngine.java @@ -440,27 +440,47 @@ public class GenericMatchEngine implements IMatchEngine { // Creates and sizes progress monitor final Monitor monitor = createProgressMonitor(); int size = 1; - for (final EObject root : leftRoot.eResource().getContents()) { - final Iterator<EObject> rootContent = root.eAllContents(); + if (leftRoot.eResource() != null && rightRoot.eResource() != null) { + for (final EObject root : leftRoot.eResource().getContents()) { + final Iterator<EObject> rootContent = root.eAllContents(); + while (rootContent.hasNext()) { + rootContent.next(); + size++; + } + } + startMonitor(monitor, size); + + // see if scope provider was passed in via option, otherwise create default one + final IMatchScopeProvider scopeProvider = MatchScopeProviderUtil.getScopeProvider(optionMap, + leftRoot.eResource(), rightRoot.eResource(), ancestor.eResource()); + + final IMatchScope leftScope = scopeProvider.getLeftScope(); + final IMatchScope rightScope = scopeProvider.getRightScope(); + final IMatchScope ancestorScope = scopeProvider.getAncestorScope(); + + if (leftScope.isInScope(leftRoot.eResource()) && rightScope.isInScope(rightRoot.eResource()) + && ancestorScope.isInScope(ancestor.eResource())) { + result = doMatch(leftRoot.eResource(), leftScope, rightRoot.eResource(), rightScope, + ancestor.eResource(), ancestorScope, monitor); + } + } else { + final Iterator<EObject> rootContent = leftRoot.eAllContents(); while (rootContent.hasNext()) { rootContent.next(); size++; } - } - startMonitor(monitor, size << 1); - - // see if scope provider was passed in via option, otherwise create default one - final IMatchScopeProvider scopeProvider = MatchScopeProviderUtil.getScopeProvider(optionMap, - leftRoot.eResource(), rightRoot.eResource(), ancestor.eResource()); - - final IMatchScope leftScope = scopeProvider.getLeftScope(); - final IMatchScope rightScope = scopeProvider.getRightScope(); - final IMatchScope ancestorScope = scopeProvider.getAncestorScope(); + startMonitor(monitor, size); + IMatchScope alwaysInScope = new IMatchScope() { + public boolean isInScope(Resource resource) { + return true; + } - if (leftScope.isInScope(leftRoot.eResource()) && rightScope.isInScope(rightRoot.eResource()) - && ancestorScope.isInScope(ancestor.eResource())) { - result = doMatch(leftRoot.eResource(), leftScope, rightRoot.eResource(), rightScope, - ancestor.eResource(), ancestorScope, monitor); + public boolean isInScope(EObject eObject) { + return true; + } + }; + result = doContentMatch(leftRoot, alwaysInScope, rightRoot, alwaysInScope, ancestor, + alwaysInScope); } return result; @@ -509,7 +529,6 @@ public class GenericMatchEngine implements IMatchEngine { } startMonitor(monitor, size); IMatchScope alwaysInScope = new IMatchScope() { - public boolean isInScope(Resource resource) { return true; } |