Community
Participate
Working Groups
1. Create an EMF project from annotated Java. 2. Open the *.ecore file 2. Change the Lower Bound of an EAttribute to "1" (to make it "Required") or change the "Resolve Proxies" property of an EList. 3. Save the *.ecore 4. Regenerate the model 5. The annotations will still say "@model" instead of "@model required="true"", etc. I add this as minor because it's irritating but only a real problem if one wants to regenerate the ecore file again. Maybe the short-term solution would be to reduce all "@model ..." annotations to "@model" when an ecore is generated but when you do this, make sure that Undo works. Or move the annotations which you could process into "@model.old" or something.
As long as you ensure that the merge rule for comment merging is applicable, regeneration will update the comment correctly. This is the merge rule: <merge:pull sourceMarkup="^gen$" sourceGet="Member/getComment" sourceTransfer="(\s*<!--\s*begin-user-doc.*?end-user-doc\s*-->\s*)\n" targetMarkup="^gen$" targetPut="Member/setComment"/> This is an example to which it would be applicable: /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @model ... * @generated */ String getTitle(); Note that the merge rules can be dynamically changed as part of your dynamic templates, so removing the sourceTransfer guard would change the behavior to overwrite all your comments.
Ok, "@generated" does the trick but it's confusing. May I suggest that, when @generated is missing, you only update the part after @model? Reasoning: When I created the model from the annotations, I kind of linked the annotations with the model. When I change the model, I expect the annotations to follow. This only happens for all new fields which I define in the model. So for an unknown reason, part of my Java code can be manipulated with the model editor and another part just refuses to budge. On a related note, I think the model doesn't change when I edit the old @model lines. Maybe it would really be better when the first "create EMF from Java annotations" would add @generated below every @model line to make synching the default case. Maybe it would be a good idea to have EMF add FIXMEs to the code when the model demands a certain code but the code couldn't be updated because the @generated is missing.
Aaron, It's quite simple to change the merge rules, to delete the methods and allow them to be regenerated with all the necessary markup, or to insert the necessary markup at the start. And since we just don't have the resource to do everything that everyone might imagine or desire, or even to do all the really important things we'd like to do, I'm going to return this. Sorry.