Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Goubet2013-01-31 16:08:39 +0000
committerLaurent Goubet2013-01-31 16:08:39 +0000
commit22a9332791c79cc07ffd31beb67a4b0644180afa (patch)
tree38bf61929541e75e95be6599e32425028cabc57f
parentdc773c407d3f20b949e50cea8bdb9e314b9d4310 (diff)
downloadorg.eclipse.emf.compare-22a9332791c79cc07ffd31beb67a4b0644180afa.tar.gz
org.eclipse.emf.compare-22a9332791c79cc07ffd31beb67a4b0644180afa.tar.xz
org.eclipse.emf.compare-22a9332791c79cc07ffd31beb67a4b0644180afa.zip
[399652] Resolve fragments when resolving using the sync model.
-rw-r--r--plugins/org.eclipse.emf.compare.ide/src/org/eclipse/emf/compare/ide/internal/utils/NotLoadingResourceSet.java56
-rw-r--r--plugins/org.eclipse.emf.compare.ide/src/org/eclipse/emf/compare/ide/internal/utils/SyncResourceSet.java7
2 files changed, 32 insertions, 31 deletions
diff --git a/plugins/org.eclipse.emf.compare.ide/src/org/eclipse/emf/compare/ide/internal/utils/NotLoadingResourceSet.java b/plugins/org.eclipse.emf.compare.ide/src/org/eclipse/emf/compare/ide/internal/utils/NotLoadingResourceSet.java
index efdef520a..8f87e6ce1 100644
--- a/plugins/org.eclipse.emf.compare.ide/src/org/eclipse/emf/compare/ide/internal/utils/NotLoadingResourceSet.java
+++ b/plugins/org.eclipse.emf.compare.ide/src/org/eclipse/emf/compare/ide/internal/utils/NotLoadingResourceSet.java
@@ -26,9 +26,7 @@ import java.util.Set;
import org.eclipse.core.resources.IStorage;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.emf.common.util.AbstractTreeIterator;
import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.common.util.TreeIterator;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.common.util.WrappedException;
import org.eclipse.emf.compare.ide.EMFCompareIDEPlugin;
@@ -135,13 +133,35 @@ public final class NotLoadingResourceSet extends ResourceSetImpl {
while (resourceContent.hasNext()) {
final EObject eObject = resourceContent.next();
resolveCrossReferences(eObject);
- final TreeIterator<EObject> childContent = basicEAllContents(eObject);
- while (childContent.hasNext()) {
- final EObject child = childContent.next();
+ resolveChildren(eObject);
+ }
+ resource.getContents().addAll(roots);
+ }
+
+ /**
+ * Recursively resolve all children of the given EObject, including (but stopping at) any proxy.
+ *
+ * @param eObject
+ * The eObject which children we are to resolve.
+ */
+ private void resolveChildren(EObject eObject) {
+ final List<EObject> list = eObject.eContents();
+ final ListIterator<EObject> childContent = ((InternalEList<EObject>)list).basicListIterator();
+ while (childContent.hasNext()) {
+ final EObject child = childContent.next();
+ if (child.eIsProxy()) {
+ final URI proxyURI = ((InternalEObject)child).eProxyURI();
+ final Resource targetRes = getResource(proxyURI.trimFragment(), false);
+ if (targetRes != null) {
+ // resolve this one
+ list.get(childContent.previousIndex());
+ }
+ resolveCrossReferences(child);
+ } else {
resolveCrossReferences(child);
+ resolveChildren(child);
}
}
- resource.getContents().addAll(roots);
}
/**
@@ -165,28 +185,4 @@ public final class NotLoadingResourceSet extends ResourceSetImpl {
}
}
}
-
- /**
- * An implementation of {@link EObject#eAllContents()} that will not resolve its proxies.
- *
- * @param eObject
- * The eobject for which contents we need an iterator.
- * @return The created {@link TreeIterator}.
- */
- private TreeIterator<EObject> basicEAllContents(final EObject eObject) {
- return new AbstractTreeIterator<EObject>(eObject, false) {
- /** Generated SUID. */
- private static final long serialVersionUID = 6874121606163401152L;
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.emf.common.util.AbstractTreeIterator#getChildren(java.lang.Object)
- */
- @Override
- public Iterator<EObject> getChildren(Object obj) {
- return ((InternalEList<EObject>)((EObject)obj).eContents()).basicIterator();
- }
- };
- }
}
diff --git a/plugins/org.eclipse.emf.compare.ide/src/org/eclipse/emf/compare/ide/internal/utils/SyncResourceSet.java b/plugins/org.eclipse.emf.compare.ide/src/org/eclipse/emf/compare/ide/internal/utils/SyncResourceSet.java
index 0af8d8f37..2889275a2 100644
--- a/plugins/org.eclipse.emf.compare.ide/src/org/eclipse/emf/compare/ide/internal/utils/SyncResourceSet.java
+++ b/plugins/org.eclipse.emf.compare.ide/src/org/eclipse/emf/compare/ide/internal/utils/SyncResourceSet.java
@@ -355,7 +355,12 @@ public final class SyncResourceSet extends ResourceSetImpl {
final TreeIterator<EObject> childContent = basicEAllContents(eObject);
while (childContent.hasNext()) {
final EObject child = childContent.next();
- resolveCrossReferences(child);
+ if (child.eIsProxy()) {
+ final URI proxyURI = ((InternalEObject)child).eProxyURI();
+ getResource(proxyURI.trimFragment(), false);
+ } else {
+ resolveCrossReferences(child);
+ }
}
}
resource.getContents().addAll(roots);

Back to the top