Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon McDuff2008-11-21 12:17:59 -0500
committerSimon McDuff2008-11-21 12:17:59 -0500
commit0409e06bec565f7d174f14d5f0f0981d2a816537 (patch)
treed7a41389c0c842abed34397ddfca63f41a674cb9 /plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util
parenta61db74f8accdeda95afe98c1c587a7c8a3e3289 (diff)
downloadcdo-0409e06bec565f7d174f14d5f0f0981d2a816537.tar.gz
cdo-0409e06bec565f7d174f14d5f0f0981d2a816537.tar.xz
cdo-0409e06bec565f7d174f14d5f0f0981d2a816537.zip
[256141] Lazy packageRegistry fail when adding instance with Eclass in a subpackage
https://bugs.eclipse.org/bugs/show_bug.cgi?id=256141
Diffstat (limited to 'plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util')
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/CDOPackageRegistryImpl.java15
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/PackageClosure.java24
2 files changed, 12 insertions, 27 deletions
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/CDOPackageRegistryImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/CDOPackageRegistryImpl.java
index fcdfad65fe..5759b847a6 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/CDOPackageRegistryImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/CDOPackageRegistryImpl.java
@@ -87,6 +87,9 @@ public class CDOPackageRegistryImpl extends EPackageRegistryImpl implements CDOP
put(uri, descriptor);
}
+ /**
+ * Insert the topPackage and its sub-packages by their URI
+ */
public EPackage putEPackage(EPackage ePackage) throws IllegalArgumentException
{
checkSession();
@@ -427,16 +430,8 @@ public class CDOPackageRegistryImpl extends EPackageRegistryImpl implements CDOP
if (!containsKey(ePackage.getNsURI()))
{
EPackage topLevelPackage = ModelUtil.getTopLevelPackage(ePackage);
- addPackageRecursively(topLevelPackage);
- }
- }
-
- private void addPackageRecursively(EPackage ePackage)
- {
- putEPackage(ePackage);
- for (EPackage subPackage : ePackage.getESubpackages())
- {
- addPackageRecursively(subPackage);
+ // PutEPackage
+ putEPackage(topLevelPackage);
}
}
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/PackageClosure.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/PackageClosure.java
index 4d260597d0..aa1c8f0819 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/PackageClosure.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/PackageClosure.java
@@ -18,6 +18,7 @@ import org.eclipse.net4j.util.om.trace.ContextTracer;
import org.eclipse.emf.ecore.EPackage;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
@@ -32,6 +33,11 @@ public abstract class PackageClosure implements IPackageClosure
{
}
+ public Set<EPackage> calculate(EPackage ePackage)
+ {
+ return calculate(Collections.singletonList(ePackage));
+ }
+
public Set<EPackage> calculate(Collection<EPackage> ePackages)
{
// Optimize no packages
@@ -40,14 +46,6 @@ public abstract class PackageClosure implements IPackageClosure
return EMPTY_CLOSURE;
}
- // Optimize 1 package
- if (ePackages.size() == 1)
- {
- EPackage ePackage = ePackages.iterator().next();
- return calculate(ePackage);
- }
-
- // Handle >1 packages
Set<EPackage> visited = new HashSet<EPackage>();
for (EPackage ePackage : ePackages)
{
@@ -57,20 +55,12 @@ public abstract class PackageClosure implements IPackageClosure
return visited;
}
- public Set<EPackage> calculate(EPackage ePackage)
+ private void doCollectContents(EPackage ePackage, Set<EPackage> visited)
{
if (TRACER.isEnabled())
{
TRACER.trace("Package closure for " + ePackage.getNsURI());
}
-
- Set<EPackage> visited = new HashSet<EPackage>();
- doCollectContents(ePackage, visited);
- return visited;
- }
-
- private void doCollectContents(EPackage ePackage, Set<EPackage> visited)
- {
collectContents(ePackage, visited);
for (EPackage subPackage : ePackage.getESubpackages())
{

Back to the top