Code generation is non-deterministic [message #516252] |
Tue, 23 February 2010 11:44 |
Dennis Hendriks Messages: 75 Registered: January 2010 Location: The Netherlands |
Member |
|
|
Hello all,
I have an Ecore and corresponding GMF mappings etc. I've created diagram code from it. I need quite a bit of custom code, resulting in '@generated NOT' in the code). If I regenerate the diagram code, the output changes all over the place, like this diff shows:
Index: cifg2.1.0.diagram/src/cifg/diagram/edit/parts/UrgencyOperator2EditPart.java
===================================================================
--- cifg2.1.0.diagram/src/cifg/diagram/edit/parts/UrgencyOperator2EditPart.java (revision 220)
+++ cifg2.1.0.diagram/src/cifg/diagram/edit/parts/UrgencyOperator2EditPart.java (working copy)
@@ -128,18 +128,18 @@
.getFigureUrgencyOperatorAnnotationsAnnotationsLabel());
return true;
}
+ if (childEditPart instanceof UrgencyOperatorAnnotationsHeaderLabel2EditPart) {
+ ((UrgencyOperatorAnnotationsHeaderLabel2EditPart) childEditPart)
+ .setLabel(getPrimaryShape()
+ .getFigureUrgencyOperatorAnnotationsHeaderLabel());
+ return true;
+ }
if (childEditPart instanceof UrgencyOperatorHeaderLabel2EditPart) {
((UrgencyOperatorHeaderLabel2EditPart) childEditPart)
.setLabel(getPrimaryShape()
.getFigureUrgencyOperatorHeaderLabel());
return true;
}
- if (childEditPart instanceof UrgencyOperatorAnnotationsHeaderLabel2EditPart) {
- ((UrgencyOperatorAnnotationsHeaderLabel2EditPart) childEditPart)
- .setLabel(getPrimaryShape()
- .getFigureUrgencyOperatorAnnotationsHeaderLabel());
- return true;
- }
if (childEditPart instanceof UrgencyOperatorUrgencyOperatorBodiesCompartment2EditPart) {
IFigure pane = getPrimaryShape()
.getFigureUrgencyOperatorBodiesShape();
@@ -162,10 +162,10 @@
if (childEditPart instanceof UrgencyOperatorAnnotations2EditPart) {
return true;
}
- if (childEditPart instanceof UrgencyOperatorHeaderLabel2EditPart) {
+ if (childEditPart instanceof UrgencyOperatorAnnotationsHeaderLabel2EditPart) {
return true;
}
- if (childEditPart instanceof UrgencyOperatorAnnotationsHeaderLabel2EditPart) {
+ if (childEditPart instanceof UrgencyOperatorHeaderLabel2EditPart) {
return true;
}
if (childEditPart instanceof UrgencyOperatorUrgencyOperatorBodiesCompartment2EditPart) {
I have some scripts to create patches for all custom code. I can remove all diagram code and regenerate it and see if the patch still fits. This way I can regenerate the code and get all changes of the gmfmap/gmfgraph etc, with minimal effort to readd the custom code. However, as the above diff shows, the generated diagram code is not deterministic. A lot of code gets shuffled around.
Questions:
1. Is there any way to have the benefit of full regeneration of diagram code, while still having a way to easily readd all the custom code?
2. Are there any plans to make the diagram code generation deterministic (the cases of the if-statements could be sorted or something)?
Any help would be greatly appreciated.
Dennis
|
|
|
|
|
|
Re: Code generation is non-deterministic [message #516567 is a reply to message #516534] |
Wed, 24 February 2010 12:25 |
Dennis Hendriks Messages: 75 Registered: January 2010 Location: The Netherlands |
Member |
|
|
OK, I tried the aspect thing and it works perfectly! Thanks again.
One more thing. In the .gmfgen, there is already code:
<viewmap
xsi:type="gmfgen:InnerClassViewmap"
className="SynchronizationOperatorFigure"
classBody="
/**
 * @generated
 */
public class SynchronizationOperatorFigure extends org.eclipse.draw2d.RectangleFigure {


	/**
	 * @generated
	 */
	private org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel fFigureSynchronizationOperatorHeaderLabel; 
	/**
	 * @generated
	 */
	private org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel fFigureSynchronizationOperatorActionsLabel; 
	/**
	 * @generated
	 */
	private
.............
I found that the 'createContents' method (which I would like to customize) is generated by these Xpand templates:
[... plugins]$ grep -i -r "createconten" .
./org.eclipse.gmf.templates.legacy_1.0.0.v20090614-0839/graphdef.codegen.templates/top/Figure.xpt: createContents();
./org.eclipse.gmf.templates.legacy_1.0.0.v20090614-0839/graphdef.codegen.templates/top/Figure.xpt: createContents();
./org.eclipse.gmf.templates.legacy_1.0.0.v20090614-0839/graphdef.codegen.templates/top/Figure.xpt: private void createContents(){
./org.eclipse.gmf.templates.legacy_1.0.0.v20090614-0839/graphdef.codegen.templates/Children.xpt: private void createContents(){
as part of the creation of the .gmfgen file from the .gmfmap file.
Is there a way to customize these templates as well?
Dennis
|
|
|
Powered by
FUDForum. Page generated in 0.25457 seconds