Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/org.eclipse.gmf.codegen/plugin.xml13
-rw-r--r--plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/internal/codegen/util/GMFGenResource.java6
-rw-r--r--plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/internal/codegen/util/Migrate2009.java14
3 files changed, 23 insertions, 10 deletions
diff --git a/plugins/org.eclipse.gmf.codegen/plugin.xml b/plugins/org.eclipse.gmf.codegen/plugin.xml
index c06317096..284f066cf 100644
--- a/plugins/org.eclipse.gmf.codegen/plugin.xml
+++ b/plugins/org.eclipse.gmf.codegen/plugin.xml
@@ -35,16 +35,17 @@
point="org.eclipse.emf.ecore.content_parser">
<parser
class="org.eclipse.gmf.internal.common.ToolingResourceFactory"
- contentTypeIdentifier="org.eclipse.gmf.gen">
- </parser>
+ contentTypeIdentifier="org.eclipse.gmf.gen"/>
+ <!-- Factory2 supports both 2.0 and 2.1, updating them to 2.2 -->
<parser
class="org.eclipse.gmf.internal.codegen.util.GMFGenResource$Factory2"
- contentTypeIdentifier="org.eclipse.gmf.gen_2_0">
- </parser>
+ contentTypeIdentifier="org.eclipse.gmf.gen_2_1"/>
+ <parser
+ class="org.eclipse.gmf.internal.codegen.util.GMFGenResource$Factory2"
+ contentTypeIdentifier="org.eclipse.gmf.gen_2_0"/>
<parser
class="org.eclipse.gmf.internal.codegen.util.GMFGenResource$Factory"
- contentTypeIdentifier="org.eclipse.gmf.gen_1_0">
- </parser>
+ contentTypeIdentifier="org.eclipse.gmf.gen_1_0"/>
</extension>
<extension
diff --git a/plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/internal/codegen/util/GMFGenResource.java b/plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/internal/codegen/util/GMFGenResource.java
index 8f536b64d..6cad07231 100644
--- a/plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/internal/codegen/util/GMFGenResource.java
+++ b/plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/internal/codegen/util/GMFGenResource.java
@@ -75,9 +75,11 @@ public class GMFGenResource extends MigrationResource {
if (ModelVersions.GMFGEN_2_0.equals(o.eClass().getEPackage().getNsURI())) {
final Migrate2008 migrate = new Migrate2008();
EObject m = migrate.go(o);
- if (m != null && migrate.wasMigrationApplied()) {
- needWarning = true;
+ if (m != null) {
result = m;
+ if (migrate.wasMigrationApplied()) {
+ needWarning = true;
+ }
}
}
if (ModelVersions.GMFGEN_2_1.equals(result.eClass().getEPackage().getNsURI())) {
diff --git a/plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/internal/codegen/util/Migrate2009.java b/plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/internal/codegen/util/Migrate2009.java
index 08c0f6d0d..4309530b2 100644
--- a/plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/internal/codegen/util/Migrate2009.java
+++ b/plugins/org.eclipse.gmf.codegen/src/org/eclipse/gmf/internal/codegen/util/Migrate2009.java
@@ -75,7 +75,7 @@ public class Migrate2009 {
// we don't really need to ignore model facets, just record all the uses
cc.ignore(labelModelFacet1);
cc.ignore(labelModelFacet2);
- EObject result = cc.go(o);
+ EObject result = cc.copy(o); // just structure. It's incomplete at this point, hence don't copy any references.
assert "GenEditorGenerator".equals(result.eClass().getName());
final EClass newGenParserClass = (EClass) myMetaPackage.getEClassifier("GenParsers");
@@ -122,6 +122,14 @@ public class Migrate2009 {
}
newOwner.eSet(newOwner.eClass().getEStructuralFeature(labelModelFacet2.getName()), newValue);
}
+ // now, we have whole model copied, hence may proceed with copying internal and external references
+ cc.copyReferences();
+
+ EObject oldGenDiagram = (EObject) o.eGet(o.eClass().getEStructuralFeature("diagram"));
+ if (oldGenDiagram == null) {
+ // although unlikely (the only known place is tests),
+ return result;
+ }
final HashMap<List<?>, EObject> methodsToParserImpl = new HashMap<List<?>, EObject>();
assert cc.getIgnoredOwners(viewMethod).size() == cc.getIgnoredOwners(editMethod).size();
@@ -143,7 +151,6 @@ public class Migrate2009 {
EObject new_flmf = cc.get(flmf);
new_flmf.eSet(lmfParser, parserImpl);
}
- EObject oldGenDiagram = (EObject) o.eGet(o.eClass().getEStructuralFeature("diagram"));
if (!implementations.isEmpty()) {
result.eSet(result.eClass().getEStructuralFeature("labelParsers"), newGenParser);
@@ -161,6 +168,9 @@ public class Migrate2009 {
loadResAction.eSet(genAction_qualifiedClassName, editorPackageName + '.' + oldGenDiagram.eGet(loadResourceActionClassName));
EObject diagramCtxMenu = myMetaPackage.getEFactoryInstance().create((EClass) myMetaPackage.getEClassifier("GenContextMenu"));
@SuppressWarnings("unchecked")
+ List<EObject> allContextMenus = (List<EObject>) result.eGet(result.eClass().getEStructuralFeature("contextMenus"));
+ allContextMenus.add(diagramCtxMenu);
+ @SuppressWarnings("unchecked")
List<EObject> ctxMenuContext = (List<EObject>) diagramCtxMenu.eGet(diagramCtxMenu.eClass().getEStructuralFeature("context"));
// genContextMenu.getContext().add(result.getDiagram());
ctxMenuContext.add((EObject) result.eGet(result.eClass().getEStructuralFeature("diagram")));

Back to the top