MARTE errors on genmodel [message #1850859] |
Fri, 18 March 2022 13:04  |
Eclipse User |
|
|
|
Hello everybody,
I've created an UML profile that depends on MARTE 1.2.2.
Then I've created the file .genmodel to generate the java classes of the profile.
When I open the file .genmodel, it returns the attached errors related to MARTE.
Do you know why it happens?
Moreover, if I try to generate the java classes, some of them needs MARTE files that do not exists, such as:
org.eclipse.papyrus.MARTE_Library.BasicNFP_Types.NFP_Integer;
org.eclipse.papyrus.MARTE_Library.BasicNFP_Types.NFP_Real;
org.eclipse.papyrus.MARTE_Library.BasicNFP_Types.NFP_String;
I'm using Eclipse 03-2021.
Thanks,
Alberto
|
|
|
|
|
|
Re: MARTE errors on genmodel [message #1851006 is a reply to message #1850994] |
Thu, 24 March 2022 08:44   |
Eclipse User |
|
|
|
Sure, here it is. I haven't tested it in a while, so your mileage may vary:
diff --git a/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/util/UMLUtil.java b/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/util/UMLUtil.java
index c78760f..7eb961f 100644
--- a/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/util/UMLUtil.java
+++ b/plugins/org.eclipse.uml2.uml/src/org/eclipse/uml2/uml/util/UMLUtil.java
@@ -16,6 +16,7 @@
* E.D.Willink - 420338, 512439
* Christian W. Damus - 444588, 497359, 501740
* Camille Letavernier - 528925, 529564
+ * CEA: Patch that returns strings for MARTE datatypes
*
*/
package org.eclipse.uml2.uml.util;
@@ -4671,7 +4672,13 @@ public class UMLUtil
@Override
public Boolean caseDataType(DataType dataType) {
- return Boolean.TRUE;
+ // CEA modification
+ if(mapDataTypeToString(dataType)) {
+ return Boolean.FALSE;
+ }
+ else {
+ return Boolean.TRUE;
+ }
}
@Override
@@ -4801,17 +4808,33 @@ public class UMLUtil
.getNearestPackage();
if (package_ != null) {
- EClass eClass = EcoreFactory.eINSTANCE.createEClass();
- elementToEModelElementMap.put(dataType, eClass);
- EPackage ePackage = (EPackage) doSwitch(package_);
- ePackage.getEClassifiers().add(eClass);
+ // CEA modification
+ if(mapDataTypeToString(dataType)) {
+ EDataType eDataType = EcoreFactory.eINSTANCE.createEDataType();
+ elementToEModelElementMap.put(dataType, eDataType);
- setName(eClass, dataType);
+ EPackage ePackage = (EPackage)doSwitch(package_);
+ ePackage.getEClassifiers().add(eDataType);
- defaultCase(dataType);
+ setName(eDataType, dataType);
+ eDataType.setInstanceClassName("java.lang.String"); //$NON-NLS-1$
- return eClass;
+ return eDataType;
+ }
+ else {
+ EClass eClass = EcoreFactory.eINSTANCE.createEClass();
+ elementToEModelElementMap.put(dataType, eClass);
+
+ EPackage ePackage = (EPackage) doSwitch(package_);
+ ePackage.getEClassifiers().add(eClass);
+
+ setName(eClass, dataType);
+
+ defaultCase(dataType);
+
+ return eClass;
+ }
}
}
return super.caseDataType(dataType);
@@ -5214,7 +5237,13 @@ public class UMLUtil
setName(eDataType, primitiveType);
- eDataType.setInstanceClassName(eDataType.getName());
+ // CEA modification
+ if(mapDataTypeToString(primitiveType)) {
+ eDataType.setInstanceClassName("java.lang.String"); //$NON-NLS-1$
+ }
+ else {
+ eDataType.setInstanceClassName(eDataType.getName());
+ }
defaultCase(primitiveType);
@@ -13478,7 +13507,7 @@ public class UMLUtil
if (resourceSet != null) {
Map<String, Object> contentTypeToFactoryMap = resourceSet
.getResourceFactoryRegistry().getContentTypeToFactoryMap();
-
+
contentTypeToFactoryMap.put(
UML402UMLResource.UML_4_0_0_CONTENT_TYPE_IDENTIFIER,
UML402UMLResource.Factory.INSTANCE);
@@ -13746,4 +13775,15 @@ public class UMLUtil
return allSubsetFeatures;
}
+ /**
+ * CEA: Map certain data types to string. This is useful for instance for MARTE types
+ *
+ * @param dataType
+ * @return true, if data-type should be mapped to a string
+ */
+ private static boolean mapDataTypeToString(DataType dataType) {
+ // currently: map all data types to string
+ return true;
+ }
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.30920 seconds