| Summary: | [Typesystem][UML] does not support all Built-In Primitive Types | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Modeling] M2T | Reporter: | Christian Dietrich <christian.dietrich.opensource> | ||||
| Component: | Xpand | Assignee: | Karsten Thoms <karsten.thoms> | ||||
| Status: | CLOSED FIXED | QA Contact: | |||||
| Severity: | normal | ||||||
| Priority: | P3 | Flags: | karsten.thoms:
iplog-
karsten.thoms: kepler+ |
||||
| Version: | unspecified | ||||||
| Target Milestone: | M4 | ||||||
| Hardware: | PC | ||||||
| OS: | Windows 7 | ||||||
| Whiteboard: | |||||||
| Attachments: |
|
||||||
|
Description
Christian Dietrich
Created attachment 186123 [details]
Sample Project and Possible Workaround
Here a Possible Workarround
package model;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.emf.mwe.utils.Mapping;
import org.eclipse.xtend.typesystem.Type;
import org.eclipse.xtend.typesystem.uml2.UML2MetaModel;
public class ExtendedUML2Metamodel extends UML2MetaModel {
private Map<String,String> mappings = new HashMap<String,String>();
public void addMapping(Mapping mapping) {
mappings.put(mapping.getFrom(), mapping.getTo());
}
@Override
public Type getTypeForName(String typeName) {
Type mappedType = null;
String mappedTypeName = mappings.get(typeName);
if (mappedTypeName != null) {
mappedType = getTypeForName(mappedTypeName);
if (mappedType != null) {
return mappedType;
}
}
return super.getTypeForName(typeName);
}
}
<component class="org.eclipse.xpand2.Generator">
<metaModel class="org.eclipse.xtend.typesystem.uml2.profile.ProfileMetaModel">
<profile value="platform:/resource/xpand.uml.profile.sample/src/model/test.profile.uml" />
</metaModel>
<metaModel class="model.ExtendedUML2Metamodel">
<mapping from="EcorePrimitiveTypes::EString" to="ecore::EString" />
</metaModel>
<expand value="template::Template::main FOR model" />
<outlet path="src-gen" >
<postprocessor class="org.eclipse.xpand2.output.JavaBeautifier" />
</outlet>
</component>
I prefer to come along without configurable mappings yet. The EcorePrimitiveTypes library is discrete, thus the contained types can be mapped hard coded like the other primitive type mappings in UML2MetaModelBase.
The provided example revealed another issue: The classifier "Class" is contained in the package "UML". This was former "uml" with lower case, like the EPackage name. This leads to fail if getTypeForName("UML::Class") is invoked when trying to resolve the Stereotype's super type. Thus, queried types starting with "UML::" have to be mapped to "uml::<Name>".
The mentioned additional issue is reported as bug#388232 Pushed to master Part of Kepler M4 (Version 1.3.0) Requested via bug 522520. -M. Requested via bug 522520. -M. |