Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 127319 - Changing properties doesn't update the Java annotations when @generated is missing
Summary: Changing properties doesn't update the Java annotations when @generated is mi...
Status: RESOLVED WONTFIX
Alias: None
Product: EMF
Classification: Modeling
Component: Tools (show other bugs)
Version: 2.2   Edit
Hardware: All All
: P3 minor (vote)
Target Milestone: ---   Edit
Assignee: Dave Steinberg CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-02-10 14:50 EST by Aaron Digulla CLA
Modified: 2006-02-10 15:36 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Aaron Digulla CLA 2006-02-10 14:50:41 EST
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.
Comment 1 Ed Merks CLA 2006-02-10 15:02:29 EST
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*&lt;!--\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.
Comment 2 Aaron Digulla CLA 2006-02-10 15:23:46 EST
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.
Comment 3 Ed Merks CLA 2006-02-10 15:36:24 EST
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.