Bug 573160 - [Designer, CDT integration] Don't replace operation parameters
- Remove return type update (would be broken due to changes in designer for bug 573160)
Change-Id: I5b108a710fe091dfd89b8e2d6d5f4f370580a562
Signed-off-by: Ansgar Radermacher <ansgar.radermacher@cea.fr>
diff --git a/plugins/ros2/org.eclipse.papyrus.robotics.ros2.cdteditor/src/org/eclipse/papyrus/robotics/ros2/cdteditor/sync/SyncRoboticsCDTtoModel.java b/plugins/ros2/org.eclipse.papyrus.robotics.ros2.cdteditor/src/org/eclipse/papyrus/robotics/ros2/cdteditor/sync/SyncRoboticsCDTtoModel.java
index 1b2cab4..4765754 100644
--- a/plugins/ros2/org.eclipse.papyrus.robotics.ros2.cdteditor/src/org/eclipse/papyrus/robotics/ros2/cdteditor/sync/SyncRoboticsCDTtoModel.java
+++ b/plugins/ros2/org.eclipse.papyrus.robotics.ros2.cdteditor/src/org/eclipse/papyrus/robotics/ros2/cdteditor/sync/SyncRoboticsCDTtoModel.java
@@ -18,7 +18,6 @@
import java.util.List;
import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
@@ -40,7 +39,6 @@
import org.eclipse.cdt.ui.CDTUITools;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.emf.common.util.BasicEList;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.URI;
import org.eclipse.papyrus.designer.languages.common.extensionpoints.ILangCodegen;
@@ -55,7 +53,6 @@
import org.eclipse.papyrus.robotics.core.utils.ScanUtils;
import org.eclipse.papyrus.robotics.ros2.cdteditor.TextEditorConstants;
import org.eclipse.papyrus.uml.tools.utils.StereotypeUtil;
-import org.eclipse.papyrus.uml.tools.utils.UMLUtil;
import org.eclipse.ui.IEditorInput;
import org.eclipse.uml2.uml.Behavior;
import org.eclipse.uml2.uml.BehavioralFeature;
@@ -63,13 +60,9 @@
import org.eclipse.uml2.uml.Classifier;
import org.eclipse.uml2.uml.Comment;
import org.eclipse.uml2.uml.NamedElement;
-import org.eclipse.uml2.uml.Namespace;
import org.eclipse.uml2.uml.OpaqueBehavior;
import org.eclipse.uml2.uml.PackageableElement;
import org.eclipse.uml2.uml.Parameter;
-import org.eclipse.uml2.uml.ParameterDirectionKind;
-import org.eclipse.uml2.uml.Type;
-import org.eclipse.uml2.uml.UMLFactory;
import org.eclipse.uml2.uml.UMLPackage;
public class SyncRoboticsCDTtoModel extends SyncCDTtoModel {
@@ -211,9 +204,8 @@
/**
* Update a method in the model based on the qualified name.
* Unlike the overridden method in designer, the code only updates the behavior, not an
- * operation. It also only updates the return type, not any in, out, inout parameters
- * as they are supposed to be added by the generator based on the function type
- * (handler, etc.). TODO: why is that different for the return type?
+ * operation. It also only updates the body, not the signature
+ * as the latter is supposed to be added by the generator based on the function type
*
* @param position
* The position of the method within the file. Used to identify
@@ -232,7 +224,7 @@
public NamedElement updateMethod(int position, IParent parent, String qualifiedName, String body,
IASTFunctionDeclarator declarator, SyncInformation syncInfo) {
- String names[] = qualifiedName.split(Namespace.SEPARATOR);
+ String names[] = qualifiedName.split(org.eclipse.papyrus.designer.languages.cpp.cdt.texteditor.TextEditorConstants.nsSep);
String name = names[names.length - 1];
Behavior behavior = null;
@@ -254,33 +246,6 @@
return null;
}
- // Remove all parameters from operation / behavior (they will be added later).
- // Calling parameters.clear() is not sufficient. Otherwise stereotype
- // applications to unresolved elements remain in the model
- List<Parameter> existingParameters = new BasicEList<Parameter>();
- UMLUtil.destroyElements(behavior.getOwnedParameters());
- if (behavior != null) {
- for (Parameter existingParameter : behavior.getOwnedParameters()) {
- Parameter existingParamCopy = UMLFactory.eINSTANCE.createParameter();
- existingParamCopy.setName(existingParameter.getName());
- existingParamCopy.setType(existingParameter.getType());
- existingParamCopy.setDirection(existingParameter.getDirection());
- existingParamCopy.setLower(existingParameter.getLower());
- existingParamCopy.setUpper(existingParameter.getUpper());
- existingParameters.add(existingParamCopy);
- }
- }
-
- IASTFunctionDefinition definition = (IASTFunctionDefinition) declarator.getParent();
- IASTDeclSpecifier declSpecifier = definition.getDeclSpecifier();
- Parameter existingParameter = getParameterViaName(existingParameters,
- declSpecifier.toString());
- Type paramType = getParameterType(null, declSpecifier.toString(), existingParameter);
- Parameter umlRetParameter = behavior.createOwnedParameter("ret", paramType); //$NON-NLS-1$
- umlRetParameter.setDirection(ParameterDirectionKind.RETURN_LITERAL);
- updateMultiplicity(umlRetParameter, existingParameter);
- // applyParameterModifiers(parameterType, umlParameter, modifiers);
-
if (behavior instanceof OpaqueBehavior) {
OpaqueBehavior ob = (OpaqueBehavior) behavior;
if (ob.getBodies().size() == 0) {