summaryrefslogtreecommitdiffstats
authorghillairet2012-05-17 11:51:04 (EDT)
committer mgolubev2012-05-17 11:51:04 (EDT)
commitfa2e9f4fe44fb57aeaa17bd7ddb47014db6a5b33 (patch) (side-by-side diff)
tree28392d4a8aab7bb0e4fc85a90907368f62283f53
parente6160349c0ff23db9fee594b58a1de84d278921e (diff)
downloadorg.eclipse.gmf-tooling-fa2e9f4fe44fb57aeaa17bd7ddb47014db6a5b33.zip
org.eclipse.gmf-tooling-fa2e9f4fe44fb57aeaa17bd7ddb47014db6a5b33.tar.gz
org.eclipse.gmf-tooling-fa2e9f4fe44fb57aeaa17bd7ddb47014db6a5b33.tar.bz2
Renamed Map2GenUtil as Utils
Removed CompartmentMapping helpers Moved ElementType hepers into Mappings
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--plugins/org.eclipse.gmf.bridge/transforms/Map2GenUtil.qvto174
-rw-r--r--plugins/org.eclipse.gmf.bridge/transforms/Utils.qvto113
2 files changed, 113 insertions, 174 deletions
diff --git a/plugins/org.eclipse.gmf.bridge/transforms/Map2GenUtil.qvto b/plugins/org.eclipse.gmf.bridge/transforms/Map2GenUtil.qvto
deleted file mode 100644
index 039e6a2..0000000
--- a/plugins/org.eclipse.gmf.bridge/transforms/Map2GenUtil.qvto
+++ b/dev/null
@@ -1,174 +0,0 @@
-/**
- * Copyright (c) 2009, 2011, 2012 Borland Software Corporation & others
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Artem Tikhomirov (Borland) - initial API and implementation
- * Guillaume Hillairet (Montages A.G.)
- */
-library Map2GenUtil;
-
-modeltype GMFMAP uses mappings('http://www.eclipse.org/gmf/2006/mappings');
-modeltype ECORE uses ecore('http://www.eclipse.org/emf/2002/Ecore');
-modeltype GENMODEL uses genmodel('http://www.eclipse.org/emf/2002/GenModel');
-modeltype GMFGEN uses gmfgen('http://www.eclipse.org/gmf/2009/GenModel');
-
---
--- Properties
---
-
-property allChildReferences: Sequence(ChildReference) = Sequence{};
-property childReferences: Sequence(ChildReference) = Sequence{};
-property equivalentChild: Dict(ChildReference, Sequence(ChildReference)) = Dict{};
-property genModel : GENMODEL::GenModel = null;
-property processedNodeMappings: Sequence(NodeMapping) = Sequence{};
-property compartmentsHistory: Sequence(Tuple(c: CompartmentMapping, n: NodeMapping, r: NodeReference)) = Sequence{};
-
--- XXX ElementType as return value, disjunct?
-mapping GENMODEL::GenClass::gmfRuntimeMetamodelType() : GMFGEN::MetamodelType {}
-
---
--- Helpers
---
-
-helper GMFMAP::ChildReference::matchChildReferenceFeatures(node: GMFMAP::ChildReference) : Boolean {
- var containmentFeatureMatch : Boolean;
- var childrenFeatureMatch : Boolean;
- var childMatch: Boolean;
-
- if node.containmentFeature.oclIsUndefined() then
- containmentFeatureMatch := self.containmentFeature.oclIsUndefined()
- else {
- containmentFeatureMatch := self.containmentFeature = node.containmentFeature
- } endif;
-
- if node.childrenFeature.oclIsUndefined() then
- childrenFeatureMatch := self.childrenFeature.oclIsUndefined()
- else
- if self.childrenFeature.oclIsUndefined() then
- childrenFeatureMatch := node.childrenFeature = node.containmentFeature
- else
- childrenFeatureMatch := node.childrenFeature = self.childrenFeature
- endif
- endif;
-
- childMatch := node.referencedChild = self.child or node.child = self.child;
-
- return containmentFeatureMatch and childrenFeatureMatch and childMatch;
-}
-
--- XXX review - Specialization type is created again and again - why not reuse it?
--- static, for some reasons, helpers couldn't specify 'inout' for context element
--- XXX, actually, don't need GenNode here, GenClass should be sufficient
-helper setupElementType(inout genNode : GMFGEN::GenNode) {
- if genNode.modelFacet.oclIsUndefined() then genNode.elementType := object GMFGEN::NotationType {}
- else genNode.elementType := genNode.modelFacet.metaClass.getOrCreateRuntimeMetamodelType() endif;
- return;
-}
-
-helper setupElementType(inout genLink : GMFGEN::GenLink) {
- if genLink.modelFacet.oclIsUndefined() then genLink.elementType := object GMFGEN::NotationType {}
- else if genLink.modelFacet.oclIsKindOf(GMFGEN::TypeModelFacet) then
- genLink.elementType := genLink.modelFacet.oclAsType(GMFGEN::TypeModelFacet).metaClass.getOrCreateRuntimeMetamodelType()
- else{ -- ref-based link; specialize null
- genLink.elementType := object GMFGEN::SpecializationType {};
- genLink.elementType.displayName := genLink.modelFacet.oclAsType(FeatureLinkModelFacet).metaFeature.ecoreFeature.name.firstToUpper();}
- endif
- endif;
- return;
-}
-
---
--- Queries
---
-
-query GMFMAP::Mapping::getChildReferences(): Sequence(ChildReference) {
- var rs : Sequence(ChildReference) := Sequence{};
-
- allChildReferences := self.nodes->collect(e | e.child.getChildReferences());
- allChildReferences->forEach(c) {
- var equi: ChildReference = equivalentChild->keys()->selectOne(e | e.matchChildReferenceFeatures(c));
- if equi.oclIsUndefined() then {
- rs += c;
- equivalentChild->put(c, Sequence{});
- } else {
- var seq := equivalentChild->get(equi);
- seq += c;
- equivalentChild->put(equi, seq);
- } endif
- };
-
- return rs
- -- ->reject(e | e.compartment.oclIsUndefined() and
- -- e.containmentFeature = e.childrenFeature and
- -- not e.referencedChild.oclIsUndefined());
-}
-
-query GMFMAP::ChildReference::findProcessableChildReference(): ChildReference {
- return if childReferences->includes(self) then
- self
- else
- equivalentChild->keys()->selectOne(e | equivalentChild->get(e)->includes(self))
- endif
-}
-
-query GENMODEL::GenClass::getOrCreateRuntimeMetamodelType() : GMFGEN::ElementType {
- var mmt = self.resolveoneIn(GENMODEL::GenClass::gmfRuntimeMetamodelType, GMFGEN::MetamodelType);
- if mmt.oclIsUndefined() then
- return self.map gmfRuntimeMetamodelType()
- endif;
- return object GMFGEN::SpecializationType { metamodelType := mmt }
-}
-
-query NodeMapping::getChildReferences(): Sequence(ChildReference) {
- processedNodeMappings += self;
- return self.children->collect(e |
- Sequence{e}->union(if processedNodeMappings->includes(e.child) then Sequence {}
- else
- e.child.getChildReferences()
- endif))
-}
-
-query GMFMAP::Mapping::getCompartments(): Sequence(Tuple(c: CompartmentMapping, n: NodeMapping, r: NodeReference)) {
- return
- if compartmentsHistory->notEmpty() then compartmentsHistory else
- self.nodes->collect(e |
- if not e.child.oclIsUndefined() then
- e.child.compartments->collect(comp | comp.getSubCompartments(e.child, e)
- )->flatten()
- endif)->flatten()
- endif;
-}
-
-query GMFMAP::CompartmentMapping::getSubCompartments(_mapping: NodeMapping, container: NodeReference): Sequence(Tuple(c: CompartmentMapping, n: NodeMapping, r: NodeReference)) {
- compartmentsHistory += Tuple{c = self, n = _mapping, r = container};
-
- return Sequence{Tuple{c = self, n = _mapping, r = container}}->union(
- _mapping.children->collect(e |
- if not e.child.oclIsUndefined() then
- e.child.compartments->collect(c |
- if not compartmentsHistory->exists(t | t.c = c and t.n = e.child and t.r = e) then
- c.getSubCompartments(e.child, e)
- endif)
- endif))->flatten();
-}
-
-query ECORE::EClass::findGenClass() : GENMODEL::GenClass =
- self.ePackage.findGenPackage().genClassifiers[GenClass]->select(gc | gc.ecoreClass.name = self.name)->first();
-
-query ECORE::EPackage::findGenPackage() : GENMODEL::GenPackage =
- -- XXX GenModel.findGenPackage does more than this (staticGenPackage and nestedGenPackages). FIXME
- -- ->union(genModel.staticGenPackages)
- this.genModel.genPackages->union(
- this.genModel.usedGenPackages)->select(gp |
- gp.ecorePackage.nsURI = self.nsURI)->asSequence()->first();
-
-query ECORE::EStructuralFeature::findGenFeature() : GENMODEL::GenFeature =
- self.eContainingClass.findGenClass().genFeatures->select(f | f.ecoreFeature = self)->first();
-
-query GMFMAP::NodeMapping::isPureLabelNode() : Boolean =
- self.labelMappings->size() = 1 and self.children->isEmpty() and self.labelMappings->first().diagramLabel = self.diagramNode;
diff --git a/plugins/org.eclipse.gmf.bridge/transforms/Utils.qvto b/plugins/org.eclipse.gmf.bridge/transforms/Utils.qvto
new file mode 100644
index 0000000..52b7639
--- a/dev/null
+++ b/plugins/org.eclipse.gmf.bridge/transforms/Utils.qvto
@@ -0,0 +1,113 @@
+/**
+ * Copyright (c) 2009, 2011, 2012 Borland Software Corporation & others
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Artem Tikhomirov (Borland) - initial API and implementation
+ * Guillaume Hillairet (Montages A.G.)
+ */
+library Utils;
+
+modeltype GMFMAP uses mappings('http://www.eclipse.org/gmf/2006/mappings');
+modeltype ECORE uses ecore('http://www.eclipse.org/emf/2002/Ecore');
+modeltype GENMODEL uses genmodel('http://www.eclipse.org/emf/2002/GenModel');
+modeltype GMFGEN uses gmfgen('http://www.eclipse.org/gmf/2009/GenModel');
+
+--
+-- Properties
+--
+
+property allChildReferences: Sequence(ChildReference) = Sequence{};
+property childReferences: Sequence(ChildReference) = Sequence{};
+property equivalentChild: Dict(ChildReference, Sequence(ChildReference)) = Dict{};
+property genModel : GENMODEL::GenModel = null;
+property processedNodeMappings: Sequence(NodeMapping) = Sequence{};
+
+--
+-- Helpers
+--
+
+helper GMFMAP::ChildReference::matchChildReferenceFeatures(node: GMFMAP::ChildReference) : Boolean {
+ var containmentFeatureMatch : Boolean;
+ var childrenFeatureMatch : Boolean;
+ var childMatch: Boolean;
+
+ if node.containmentFeature.oclIsUndefined() then
+ containmentFeatureMatch := self.containmentFeature.oclIsUndefined()
+ else {
+ containmentFeatureMatch := self.containmentFeature = node.containmentFeature
+ } endif;
+
+ if node.childrenFeature.oclIsUndefined() then
+ childrenFeatureMatch := self.childrenFeature.oclIsUndefined()
+ else
+ if self.childrenFeature.oclIsUndefined() then
+ childrenFeatureMatch := node.childrenFeature = node.containmentFeature
+ else
+ childrenFeatureMatch := node.childrenFeature = self.childrenFeature
+ endif
+ endif;
+
+ childMatch := node.referencedChild = self.child or node.child = self.child;
+
+ return containmentFeatureMatch and childrenFeatureMatch and childMatch;
+}
+
+--
+-- Queries
+--
+
+query GMFMAP::Mapping::getChildReferences(): Sequence(ChildReference) {
+ var rs : Sequence(ChildReference) := Sequence{};
+
+ allChildReferences := self.nodes->collect(e | e.child.getChildReferences());
+ allChildReferences->forEach(c) {
+ var equi: ChildReference = equivalentChild->keys()->selectOne(e | e.matchChildReferenceFeatures(c));
+ if equi.oclIsUndefined() then {
+ rs += c;
+ equivalentChild->put(c, Sequence{});
+ } else {
+ var seq := equivalentChild->get(equi);
+ seq += c;
+ equivalentChild->put(equi, seq);
+ } endif
+ };
+
+ return rs
+}
+
+query GMFMAP::ChildReference::findProcessableChildReference(): ChildReference =
+ if childReferences->includes(self) then
+ self
+ else
+ equivalentChild->keys()->selectOne(e | equivalentChild->get(e)->includes(self))
+ endif;
+
+query NodeMapping::getChildReferences(): Sequence(ChildReference) {
+ processedNodeMappings += self;
+ return self.children->collect(e |
+ Sequence{e}->union(if processedNodeMappings->includes(e.child) then Sequence {}
+ else
+ e.child.getChildReferences()
+ endif))
+}
+
+query ECORE::EClass::findGenClass() : GENMODEL::GenClass =
+ self.ePackage.findGenPackage().genClassifiers[GenClass]->select(gc | gc.ecoreClass.name = self.name)->first();
+
+query ECORE::EPackage::findGenPackage() : GENMODEL::GenPackage =
+ -- XXX GenModel.findGenPackage does more than this (staticGenPackage and nestedGenPackages). FIXME
+ -- ->union(genModel.staticGenPackages)
+ this.genModel.genPackages->union(
+ this.genModel.usedGenPackages)->select(gp |
+ gp.ecorePackage.nsURI = self.nsURI)->asSequence()->first();
+
+query ECORE::EStructuralFeature::findGenFeature() : GENMODEL::GenFeature =
+ self.eContainingClass.findGenClass().genFeatures->select(f | f.ecoreFeature = self)->first();
+
+query GMFMAP::NodeMapping::isPureLabelNode() : Boolean =
+ self.labelMappings->size() = 1 and self.children->isEmpty() and self.labelMappings->first().diagramLabel = self.diagramNode;