Bug 567903 - [Robotics, ROS2] Move ROS2 independent parts into a new plugin
- Avoid creation of ROS2 CDT project in CopyPackageModels (which is used by ZMQ as well)
- TODO: move to common plugin
- Minor comment/whitespace corrections
Change-Id: Ia9fa74fc7b59ee77e57e2032d56dfb3e34d0873a
Signed-off-by: Ansgar Radermacher <ansgar.radermacher@cea.fr>
diff --git a/plugins/codegen/org.eclipse.papyrus.robotics.codegen.common/src/org/eclipse/papyrus/robotics/codegen/common/utils/PackageTools.xtend b/plugins/codegen/org.eclipse.papyrus.robotics.codegen.common/src/org/eclipse/papyrus/robotics/codegen/common/utils/PackageTools.xtend
index 3ec6ceb..1dd69a1 100644
--- a/plugins/codegen/org.eclipse.papyrus.robotics.codegen.common/src/org/eclipse/papyrus/robotics/codegen/common/utils/PackageTools.xtend
+++ b/plugins/codegen/org.eclipse.papyrus.robotics.codegen.common/src/org/eclipse/papyrus/robotics/codegen/common/utils/PackageTools.xtend
@@ -41,7 +41,7 @@
*/
def static String pkgName(Package model) {
if (model === null) {
- System.err.println("Haeh");
+ throw new TransformationException("pkgName is invoked with a null model (internal generator error)");
}
if (StereotypeUtil.isApplied(model, ServiceDefinitionModel)) {
return model.name.toLowerCase
diff --git a/plugins/customization/textedit/org.eclipse.papyrus.robotics.xtext.compdef/src/org/eclipse/papyrus/robotics/xtext/compdef/CompDef.xtext b/plugins/customization/textedit/org.eclipse.papyrus.robotics.xtext.compdef/src/org/eclipse/papyrus/robotics/xtext/compdef/CompDef.xtext
index 0b6e131..70066f8 100644
--- a/plugins/customization/textedit/org.eclipse.papyrus.robotics.xtext.compdef/src/org/eclipse/papyrus/robotics/xtext/compdef/CompDef.xtext
+++ b/plugins/customization/textedit/org.eclipse.papyrus.robotics.xtext.compdef/src/org/eclipse/papyrus/robotics/xtext/compdef/CompDef.xtext
@@ -24,7 +24,7 @@
terminal VSL_COMMENT : '//' !('\n'|'\r')* ('\r'? '\n')?;
Parameter:
- 'parameter' name=ID (':' (type=TypeRule | typeUndefined?="<Undefined>"))?
+ 'parameter' name = ID (':' (type=TypeRule | typeUndefined?="<Undefined>"))?
(multiplicity = MultiplicityRule)?
('=' value = Value)?
(comment = VSL_COMMENT)?
diff --git a/plugins/ros2/org.eclipse.papyrus.robotics.ros2.codegen/src/org/eclipse/papyrus/robotics/ros2/codegen/CopyPackageModels.xtend b/plugins/ros2/org.eclipse.papyrus.robotics.ros2.codegen/src/org/eclipse/papyrus/robotics/ros2/codegen/CopyPackageModels.xtend
index 787a2aa..62efa02 100644
--- a/plugins/ros2/org.eclipse.papyrus.robotics.ros2.codegen/src/org/eclipse/papyrus/robotics/ros2/codegen/CopyPackageModels.xtend
+++ b/plugins/ros2/org.eclipse.papyrus.robotics.ros2.codegen/src/org/eclipse/papyrus/robotics/ros2/codegen/CopyPackageModels.xtend
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2018 CEA LIST.
+ * Copyright (c) 2018, 2021 CEA LIST.
*
*
* All rights reserved. This program and the accompanying materials
@@ -18,16 +18,22 @@
import org.eclipse.papyrus.designer.transformation.core.m2minterfaces.IM2MTrafoCDP
import org.eclipse.papyrus.designer.transformation.core.transformations.TransformationContext
import org.eclipse.papyrus.designer.transformation.profile.Transformation.M2MTrafo
-import org.eclipse.papyrus.robotics.ros2.codegen.utils.ProjectTools
import org.eclipse.uml2.uml.Package
import static extension org.eclipse.papyrus.robotics.codegen.common.utils.PackageTools.*
+import org.eclipse.papyrus.designer.transformation.base.utils.ProjectManagement
+/**
+ * If code generation is launched from a component within a package, the
+ * resource set will likely not have the complete set of models defined in
+ * that package as these are needed to generate the complete set.
+ * The goal of this function is to trigger loading these models.
+ * TODO: move-to common location, check whether we can provide a better solution.
+ */
class CopyPackageModels implements IM2MTrafoCDP {
override applyTrafo(M2MTrafo trafo, Package rootPkg) throws TransformationException {
- // assure that Common and C++ profiles is applied
- val project = ProjectTools.getProject(TransformationContext.initialSourceRoot.projectName)
+ val project = ProjectManagement.getNamedProject(TransformationContext.initialSourceRoot.projectName)
if (project !== null) {
project.compDefs
project.system
diff --git a/plugins/ros2/org.eclipse.papyrus.robotics.ros2.codegen/src/org/eclipse/papyrus/robotics/ros2/codegen/component/RoboticsCppCreator.java b/plugins/ros2/org.eclipse.papyrus.robotics.ros2.codegen/src/org/eclipse/papyrus/robotics/ros2/codegen/component/RoboticsCppCreator.java
index 94cce75..0ebff74 100644
--- a/plugins/ros2/org.eclipse.papyrus.robotics.ros2.codegen/src/org/eclipse/papyrus/robotics/ros2/codegen/component/RoboticsCppCreator.java
+++ b/plugins/ros2/org.eclipse.papyrus.robotics.ros2.codegen/src/org/eclipse/papyrus/robotics/ros2/codegen/component/RoboticsCppCreator.java
@@ -80,7 +80,7 @@
protected void generateFile(String fileName, String content) {
// don't generate, if indexer is active (non-idle)
if (TransformationContext.monitor.isCanceled()) {
- // use xtend trick to sneak a non
+ // use xtend trick to throw a non-declared exception
throw Exceptions.sneakyThrow(new TransformationException(ExecuteTransformationChain.USER_CANCEL));
}
ProjectTools.waitForCDT();