| <html> |
| <head> |
| |
| <meta http-equiv="Content-Type" |
| content="text/html; charset=windows-1252"> |
| <title>Changes to the EMF Code Merge</title> |
| |
| <link rel="stylesheet" href="http://www.eclipse.org/emf/docs/book.css"> |
| </head> |
| <body link="#0000ff" vlink="#800080"> |
| |
| <h1 align="center">Changes to the EMF Code Merge</h1> |
| |
| <blockquote><b>Summary</b> <br> |
| |
| This document outlines the changes to the behaviour of EMF code merge |
| due to the new implementation of the source code manipulation API. |
| |
| <p> |
| November 15, 2006</p> |
| </blockquote> |
| |
| <hr width="100%"> |
| |
| |
| |
| <h2><a name="_Introduction"></a>Introduction</h2> |
| |
| <p>EMF relies on source code manipulation API to update the code |
| with the new changes to the model. The previous implementation of the |
| API does not support Java 5.0. The new implementation that supports Java |
| 5.0 has been created and became the default implementation used by EMF.</p> |
| |
| <p>The new implementation brings a few changes to the merge |
| behaviour. These changes are outlined in this document.</p> |
| |
| <p>If you are using EMF to generate and merge your code, see <a |
| href="#_EMF_Code_Merge">an overview of changes</a>.</p> |
| |
| <p>If your code is not Java 5.0 and you would like to use the |
| previous behaviour of EMF code merge, see <a |
| href="#_Switching_to_Previous_Implementation">Switching to Previous Implementation</a> section.</p> |
| |
| <p>If you are using custom merge rules or JMerger tool outside EMF, |
| see <a href="#_JMerger">detailed information</a> about |
| the changes to the behaviour of merge rules.</p> |
| |
| |
| |
| <h2><a name="_EMF_Code_Merge"></a>Changes to the EMF Code Merge</h2> |
| |
| |
| <p><b>The only comments that are merged are the Javadoc. |
| Previously, if a comment is merged, all preceding comments were |
| overwritten or not merged at all. </b> See <a |
| href="#_EMF_Code_Merge_Example1">Example 1</a>.</p> |
| |
| <p><b>If a field that is moved is followed by a declaration that |
| is removed, hanging comments between the field and the declaration will |
| be kept and moved with the field. Previously, all comments preceding the |
| removed declaration were removed. </b> See <a |
| href="#_EMF_Code_Merge_Example2">Example 2</a>.</p> |
| |
| <p><b>Comments that immediately follow declarations may cause no |
| empty lines inserted between moved or new declarations. </b> See <a |
| href="#_EMF_Code_Merge_Example2">Example 2</a>.</p> |
| |
| <p><b>Empty lines are not added for new imports generated by |
| changes in the model. </b> |
| |
| <h3><a name="_EMF_Code_Merge_Example1">Example 1 - Merged |
| Comments</a></h3> |
| |
| <ol> |
| <li> |
| |
| <p>Code originally generated by EMF:</p> |
| |
| <blockquote><!-- ======================================================== --> |
| <!-- = Java Sourcecode to HTML automatically converted code = --> <!-- = Java2Html Converter 5.0 [2006-03-04] by Markus Gebhard markus@jave.de = --> |
| <!-- = Further information: http://www.java2html.de = --> |
| <div align="left" class="java"> |
| <table border="0" cellpadding="3" cellspacing="0" bgcolor="#ffffff"> |
| <tr> |
| |
| <!-- start source code --> |
| <td nowrap="nowrap" valign="top" align="left"><code> <font |
| color="#7f0055"><b>public abstract class </b></font><font |
| color="#000000">BookImpl </font><font color="#7f0055"><b>extends </b></font><font |
| color="#000000">EObjectImpl </font><font color="#7f0055"><b>implements </b></font><font |
| color="#000000">Book</font><br /> |
| |
| <font color="#000000">{</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">/**</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">* The default value of the '{</font><font |
| color="#7f9fbf">@link </font><font color="#3f5fbf">#getPublicationDate() </font><font |
| color="#7f7f9f"><em></font><font color="#3f5fbf">Publication Date</font><font |
| color="#7f7f9f"></em></font><font color="#3f5fbf">}' attribute.</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">* </font><font |
| color="#7f7f9f"><!-- begin-user-doc --></font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">* </font><font |
| color="#7f7f9f"><!-- end-user-doc --></font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">* @generated</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">* @ordered</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">*/</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#7f0055"><b>protected static final </b></font><font |
| color="#000000">Date PUBLICATION_DATE_EDEFAULT = </font><font |
| color="#7f0055"><b>null</b></font><font color="#000000">;</font><br /> |
| |
| <font color="#ffffff"></font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">/**</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">* The cached value of the '{</font><font |
| color="#7f9fbf">@link </font><font color="#3f5fbf">#getPublicationDate() </font><font |
| color="#7f7f9f"><em></font><font color="#3f5fbf">Publication Date</font><font |
| color="#7f7f9f"></em></font><font color="#3f5fbf">}' attribute.</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">* </font><font |
| color="#7f7f9f"><!-- begin-user-doc --></font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">* </font><font |
| color="#7f7f9f"><!-- end-user-doc --></font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">* @generated</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">* @ordered</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">*/</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#7f0055"><b>protected </b></font><font |
| color="#000000">Date publicationDate = PUBLICATION_DATE_EDEFAULT;</font><br /> |
| |
| <font color="#000000">}</font></code></td> |
| <!-- end source code --> |
| </tr> |
| |
| <!-- start Java2Html link -- |
| <tr> |
| <td align="right"> |
| <small> |
| <a href="http://www.java2html.de" target="_blank">Java2html</a> |
| </small> |
| </td> |
| </tr> |
| -- end Java2Html link --> |
| </table> |
| </div> |
| <!-- = END of automatically generated HTML code = --> <!-- ======================================================== --> |
| |
| |
| |
| |
| |
| </blockquote> |
| |
| </li> |
| <li> |
| |
| <p>User has modified Javadoc and added extra comments between the |
| nodes:</p> |
| |
| <blockquote><!-- ======================================================== --> |
| <!-- = Java Sourcecode to HTML automatically converted code = --> <!-- = Java2Html Converter 5.0 [2006-03-04] by Markus Gebhard markus@jave.de = --> |
| <!-- = Further information: http://www.java2html.de = --> |
| <div align="left" class="java"> |
| <table border="0" cellpadding="3" cellspacing="0" bgcolor="#ffffff"> |
| <tr> |
| |
| <!-- start source code --> |
| <td nowrap="nowrap" valign="top" align="left"><code> <font |
| color="#7f0055"><b>public abstract class </b></font><font |
| color="#000000">BookImpl </font><font color="#7f0055"><b>extends </b></font><font |
| color="#000000">EObjectImpl </font><font color="#7f0055"><b>implements </b></font><font |
| color="#000000">Book</font><br /> |
| |
| <font color="#000000">{</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f7f5f">// comment before PUBLICATION_DATE_EDEFAULT</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">/**</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">* </font><font |
| color="#7f7f9f"><!-- begin-user-doc --></font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">* </font><font |
| color="#7f7f9f"><p></font><font color="#3f5fbf">User comment for PUBLICATION_DATE_EDEFAULT</font><font |
| color="#7f7f9f"></p></font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">* </font><font |
| color="#7f7f9f"><!-- end-user-doc --></font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">* @generated</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">* @ordered</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">*/</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#7f0055"><b>protected static final </b></font><font |
| color="#000000">Date PUBLICATION_DATE_EDEFAULT = </font><font |
| color="#7f0055"><b>null</b></font><font color="#000000">; </font><font |
| color="#3f7f5f">// line comment at the end of PUBLICATION_DATE_EDEFAULT</font><br /> |
| |
| <font color="#ffffff"></font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f7f5f">// comments between fields</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f7f5f">/*</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f7f5f">* comments between fields</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f7f5f">*/</font><br /> |
| |
| <font color="#ffffff"> </font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f7f5f">// comment before publicationDate</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">/**</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">* </font><font |
| color="#7f7f9f"><!-- begin-user-doc --></font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">* </font><font |
| color="#7f7f9f"><p></font><font color="#3f5fbf">User comment for publicationDate</font><font |
| color="#7f7f9f"></p></font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">* </font><font |
| color="#7f7f9f"><!-- end-user-doc --></font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">* @generated</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">* @ordered</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">*/</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#7f0055"><b>protected </b></font><font |
| color="#000000">Date publicationDate = PUBLICATION_DATE_EDEFAULT;</font><br /> |
| |
| <font color="#000000">}</font></code></td> |
| <!-- end source code --> |
| </tr> |
| |
| <!-- start Java2Html link -- |
| <tr> |
| <td align="right"> |
| <small> |
| <a href="http://www.java2html.de" target="_blank">Java2html</a> |
| </small> |
| </td> |
| </tr> |
| -- end Java2Html link --> |
| </table> |
| </div> |
| <!-- = END of automatically generated HTML code = --> <!-- ======================================================== --> |
| |
| |
| </blockquote> |
| |
| </li> |
| <li> |
| |
| <p>Now code has been regenerated by EMF. Note that all the comments |
| are kept, and the changes are made to Javadoc only.</p> |
| |
| <blockquote><!-- ======================================================== --> |
| <!-- = Java Sourcecode to HTML automatically converted code = --> <!-- = Java2Html Converter 5.0 [2006-03-04] by Markus Gebhard markus@jave.de = --> |
| <!-- = Further information: http://www.java2html.de = --> |
| <div align="left" class="java"> |
| <table border="0" cellpadding="3" cellspacing="0" bgcolor="#ffffff"> |
| <tr> |
| |
| <!-- start source code --> |
| <td nowrap="nowrap" valign="top" align="left"><code> <font |
| color="#7f0055"><b>public abstract class </b></font><font |
| color="#000000">BookImpl </font><font color="#7f0055"><b>extends </b></font><font |
| color="#000000">EObjectImpl </font><font color="#7f0055"><b>implements </b></font><font |
| color="#000000">Book</font><br /> |
| |
| <font color="#000000">{</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f7f5f">// comment before PUBLICATION_DATE_EDEFAULT</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">/**</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">* The default value of the '{</font><font |
| color="#7f9fbf">@link </font><font color="#3f5fbf">#getPublicationDate() </font><font |
| color="#7f7f9f"><em></font><font color="#3f5fbf">Publication Date</font><font |
| color="#7f7f9f"></em></font><font color="#3f5fbf">}' attribute.</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">* </font><font |
| color="#7f7f9f"><!-- begin-user-doc --></font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">* </font><font |
| color="#7f7f9f"><p></font><font color="#3f5fbf">User comment for PUBLICATION_DATE_EDEFAULT</font><font |
| color="#7f7f9f"></p></font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">* </font><font |
| color="#7f7f9f"><!-- end-user-doc --></font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">* @generated</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">* @ordered</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">*/</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#7f0055"><b>protected static final </b></font><font |
| color="#000000">Date PUBLICATION_DATE_EDEFAULT = </font><font |
| color="#7f0055"><b>null</b></font><font color="#000000">; </font><font |
| color="#3f7f5f">// line comment at the end of PUBLICATION_DATE_EDEFAULT</font><br /> |
| |
| <font color="#ffffff"></font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f7f5f">// comments between fields</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f7f5f">/*</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f7f5f">* comments between fields</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f7f5f">*/</font><br /> |
| |
| <font color="#ffffff"> </font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f7f5f">// comment before publicationDate</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">/**</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">* The cached value of the '{</font><font |
| color="#7f9fbf">@link </font><font color="#3f5fbf">#getPublicationDate() </font><font |
| color="#7f7f9f"><em></font><font color="#3f5fbf">Publication Date</font><font |
| color="#7f7f9f"></em></font><font color="#3f5fbf">}' attribute.</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">* </font><font |
| color="#7f7f9f"><!-- begin-user-doc --></font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">* </font><font |
| color="#7f7f9f"><p></font><font color="#3f5fbf">User comment for publicationDate</font><font |
| color="#7f7f9f"></p></font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">* </font><font |
| color="#7f7f9f"><!-- end-user-doc --></font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">* @generated</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">* @ordered</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">*/</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#7f0055"><b>protected </b></font><font |
| color="#000000">Date publicationDate = PUBLICATION_DATE_EDEFAULT;</font><br /> |
| |
| <font color="#000000">}</font></code></td> |
| <!-- end source code --> |
| </tr> |
| |
| <!-- start Java2Html link -- |
| <tr> |
| <td align="right"> |
| <small> |
| <a href="http://www.java2html.de" target="_blank">Java2html</a> |
| </small> |
| </td> |
| </tr> |
| -- end Java2Html link --> |
| </table> |
| </div> |
| <!-- = END of automatically generated HTML code = --> <!-- ======================================================== --> |
| |
| |
| |
| </blockquote> |
| |
| </li> |
| <li> |
| |
| <p>Below is the output produced by previous implementation. Note |
| that all the comments between the nodes have been removed.</p> |
| |
| <blockquote><!-- ======================================================== --> |
| <!-- = Java Sourcecode to HTML automatically converted code = --> <!-- = Java2Html Converter 5.0 [2006-03-04] by Markus Gebhard markus@jave.de = --> |
| <!-- = Further information: http://www.java2html.de = --> |
| <div align="left" class="java"> |
| <table border="0" cellpadding="3" cellspacing="0" bgcolor="#ffffff"> |
| <tr> |
| |
| <!-- start source code --> |
| <td nowrap="nowrap" valign="top" align="left"><code> <font |
| color="#7f0055"><b>public abstract class </b></font><font |
| color="#000000">BookImpl </font><font color="#7f0055"><b>extends </b></font><font |
| color="#000000">EObjectImpl </font><font color="#7f0055"><b>implements </b></font><font |
| color="#000000">Book</font><br /> |
| |
| <font color="#000000">{</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">/**</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">* The default value of the '{</font><font |
| color="#7f9fbf">@link </font><font color="#3f5fbf">#getPublicationDate() </font><font |
| color="#7f7f9f"><em></font><font color="#3f5fbf">Publication Date</font><font |
| color="#7f7f9f"></em></font><font color="#3f5fbf">}' attribute.</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">* </font><font |
| color="#7f7f9f"><!-- begin-user-doc --></font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">* </font><font |
| color="#7f7f9f"><p></font><font color="#3f5fbf">User comment for PUBLICATION_DATE_EDEFAULT</font><font |
| color="#7f7f9f"></p></font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">* </font><font |
| color="#7f7f9f"><!-- end-user-doc --></font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">* @generated</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">* @ordered</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">*/</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#7f0055"><b>protected static final </b></font><font |
| color="#000000">Date PUBLICATION_DATE_EDEFAULT = </font><font |
| color="#7f0055"><b>null</b></font><font color="#000000">; </font><font |
| color="#3f7f5f">// line comment at the end of PUBLICATION_DATE_EDEFAULT</font><br /> |
| |
| <font color="#ffffff"></font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">/**</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">* The cached value of the '{</font><font |
| color="#7f9fbf">@link </font><font color="#3f5fbf">#getPublicationDate() </font><font |
| color="#7f7f9f"><em></font><font color="#3f5fbf">Publication Date</font><font |
| color="#7f7f9f"></em></font><font color="#3f5fbf">}' attribute.</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">* </font><font |
| color="#7f7f9f"><!-- begin-user-doc --></font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">* </font><font |
| color="#7f7f9f"><p></font><font color="#3f5fbf">User comment for publicationDate</font><font |
| color="#7f7f9f"></p></font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">* </font><font |
| color="#7f7f9f"><!-- end-user-doc --></font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">* @generated</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">* @ordered</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">*/</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#7f0055"><b>protected </b></font><font |
| color="#000000">Date publicationDate = PUBLICATION_DATE_EDEFAULT;</font><br /> |
| |
| <font color="#000000">}</font></code></td> |
| <!-- end source code --> |
| </tr> |
| |
| <!-- start Java2Html link -- |
| <tr> |
| <td align="right"> |
| <small> |
| <a href="http://www.java2html.de" target="_blank">Java2html</a> |
| </small> |
| </td> |
| </tr> |
| -- end Java2Html link --> |
| </table> |
| </div> |
| <!-- = END of automatically generated HTML code = --> <!-- ======================================================== --> |
| |
| |
| </blockquote> |
| |
| </li> |
| </ol> |
| |
| <h3><a name="_EMF_Code_Merge_Example2">Example 2 - Moved and |
| Removed Declarations</a></h3> |
| |
| Note that some irrelevant parts of Javadoc comments have not been shown |
| in this example. |
| |
| <ol> |
| <li> |
| <p>Code originally generated by EMF:</p> |
| |
| <blockquote><!-- ======================================================== --> |
| <!-- = Java Sourcecode to HTML automatically converted code = --> <!-- = Java2Html Converter 5.0 [2006-03-04] by Markus Gebhard markus@jave.de = --> |
| <!-- = Further information: http://www.java2html.de = --> |
| <div align="left" class="java"> |
| <table border="0" cellpadding="3" cellspacing="0" bgcolor="#ffffff"> |
| <tr> |
| |
| <!-- start source code --> |
| <td nowrap="nowrap" valign="top" align="left"><code> <font |
| color="#7f0055"><b>public abstract class </b></font><font |
| color="#000000">BookImpl </font><font color="#7f0055"><b>extends </b></font><font |
| color="#000000">EObjectImpl </font><font color="#7f0055"><b>implements </b></font><font |
| color="#000000">Book</font><br /> |
| |
| <font color="#000000">{</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">/**</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">* @generated</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">* @ordered</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">*/</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#7f0055"><b>protected static final </b></font><font |
| color="#000000">Date PUBLICATION_DATE_EDEFAULT = </font><font |
| color="#7f0055"><b>null</b></font><font color="#000000">;</font><br /> |
| |
| <font color="#ffffff"></font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">/**</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">* @generated</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">* @ordered</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">*/</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#7f0055"><b>protected </b></font><font |
| color="#000000">Date publicationDate = PUBLICATION_DATE_EDEFAULT;</font><br /> |
| |
| <font color="#ffffff"> </font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">/**</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">* @generated</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">* @ordered</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">*/</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#7f0055"><b>protected static final </b></font><font |
| color="#000000">String AUTHOR_EDEFAULT = </font><font |
| color="#7f0055"><b>null</b></font><font color="#000000">;</font><br /> |
| |
| <font color="#ffffff"></font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">/**</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">* @generated</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">* @ordered</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">*/</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#7f0055"><b>protected </b></font><font |
| color="#000000">String author = AUTHOR_EDEFAULT; </font><br /> |
| |
| <font color="#ffffff"> </font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">/**</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">* @generated</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">* @ordered</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">*/</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#7f0055"><b>protected static final </b></font><font |
| color="#000000">String TITLE_EDEFAULT = </font><font |
| color="#7f0055"><b>null</b></font><font color="#000000">;</font><br /> |
| |
| <font color="#ffffff"></font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">/**</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">* @generated</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">* @ordered</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">*/</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#7f0055"><b>protected </b></font><font |
| color="#000000">String title = TITLE_EDEFAULT;</font><br /> |
| |
| <font color="#000000">}</font></code></td> |
| <!-- end source code --> |
| </tr> |
| |
| </table> |
| </div> |
| <!-- = END of automatically generated HTML code = --> <!-- ======================================================== --> |
| |
| </blockquote> |
| |
| </li> |
| <li> |
| |
| <p>User has moved <code>title</code> field and added extra |
| comments.</p> |
| <p>Here is the new code:</p> |
| |
| <blockquote><!-- ======================================================== --> |
| <!-- = Java Sourcecode to HTML automatically converted code = --> <!-- = Java2Html Converter 5.0 [2006-03-04] by Markus Gebhard markus@jave.de = --> |
| <!-- = Further information: http://www.java2html.de = --> |
| <div align="left" class="java"> |
| <table border="0" cellpadding="3" cellspacing="0" bgcolor="#ffffff"> |
| <tr> |
| |
| <!-- start source code --> |
| <td nowrap="nowrap" valign="top" align="left"><code> <font |
| color="#7f0055"><b>public abstract class </b></font><font |
| color="#000000">BookImpl </font><font color="#7f0055"><b>extends </b></font><font |
| color="#000000">EObjectImpl </font><font color="#7f0055"><b>implements </b></font><font |
| color="#000000">Book</font><br /> |
| |
| <font color="#000000">{</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">/**</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">* @generated</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">* @ordered</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">*/</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#7f0055"><b>protected static final </b></font><font |
| color="#000000">Date PUBLICATION_DATE_EDEFAULT = </font><font |
| color="#7f0055"><b>null</b></font><font color="#000000">;</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f7f5f">// comment immediately following the PUBLICATION_DATE_EDEFAULT will make the 'title' field</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f7f5f">// inserted without empty lines after the move</font><br /> |
| |
| <font color="#ffffff"> </font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">/**</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">* @generated</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">* @ordered</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">*/</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#7f0055"><b>protected </b></font><font |
| color="#000000">Date publicationDate = PUBLICATION_DATE_EDEFAULT;</font><br /> |
| |
| <font color="#ffffff"> </font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f7f5f">// preceding comments will be moved with 'TITLE_EDEFAULT'</font><br /> |
| |
| <font color="#ffffff"> </font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">/**</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">* @generated</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">* @ordered</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">*/</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#7f0055"><b>protected static final </b></font><font |
| color="#000000">String TITLE_EDEFAULT = </font><font |
| color="#7f0055"><b>null</b></font><font color="#000000">;</font><br /> |
| |
| <font color="#ffffff"></font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">/**</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">* @generated</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">* @ordered</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">*/</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#7f0055"><b>protected </b></font><font |
| color="#000000">String title = TITLE_EDEFAULT;</font><br /> |
| |
| <font color="#ffffff"> </font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f7f5f">// hanging comments after 'title' before removed 'isbn' one will be moved with 'title'</font><br /> |
| |
| <font color="#ffffff"> </font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f7f5f">// preceding comment will be removed with 'ISBN_DEFAULT'</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">/**</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">* @generated</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">* @ordered</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">*/</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#7f0055"><b>protected static final </b></font><font |
| color="#000000">String ISBN_EDEFAULT = </font><font |
| color="#7f0055"><b>null</b></font><font color="#000000">;</font><br /> |
| |
| <font color="#ffffff"></font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f7f5f">// comments between removed fields are removed</font><br /> |
| |
| <font color="#ffffff"> </font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">/**</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">* @generated</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">* @ordered</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">*/</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#7f0055"><b>protected </b></font><font |
| color="#000000">String isbn = ISBN_EDEFAULT; </font><font |
| color="#3f7f5f">// comment at the last line will be removed</font><br /> |
| |
| <font color="#ffffff"> </font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f7f5f">// comments after removed 'isbn' are kept</font><br /> |
| |
| <font color="#ffffff"> </font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">/**</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">* @generated</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">* @ordered</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">*/</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#7f0055"><b>protected static final </b></font><font |
| color="#000000">String AUTHOR_EDEFAULT = </font><font |
| color="#7f0055"><b>null</b></font><font color="#000000">;</font><br /> |
| |
| <font color="#ffffff"></font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">/**</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">* @generated</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">* @ordered</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">*/</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#7f0055"><b>protected </b></font><font |
| color="#000000">String author = AUTHOR_EDEFAULT; </font><br /> |
| |
| <font color="#000000">}</font></code></td> |
| <!-- end source code --> |
| </tr> |
| |
| </table> |
| </div> |
| <!-- = END of automatically generated HTML code = --> <!-- ======================================================== --> |
| |
| |
| </blockquote> |
| |
| |
| </li> |
| |
| <li> |
| |
| <p>User has removed <code>isbn</code> field in the model, and |
| regenerated the code.</p> |
| <p>Here is the output code:</p> |
| |
| <blockquote><!-- ======================================================== --> |
| <!-- = Java Sourcecode to HTML automatically converted code = --> <!-- = Java2Html Converter 5.0 [2006-03-04] by Markus Gebhard markus@jave.de = --> |
| <!-- = Further information: http://www.java2html.de = --> |
| <div align="left" class="java"> |
| <table border="0" cellpadding="3" cellspacing="0" bgcolor="#ffffff"> |
| <tr> |
| |
| <!-- start source code --> |
| <td nowrap="nowrap" valign="top" align="left"><code> <font |
| color="#7f0055"><b>public abstract class </b></font><font |
| color="#000000">BookImpl </font><font color="#7f0055"><b>extends </b></font><font |
| color="#000000">EObjectImpl </font><font color="#7f0055"><b>implements </b></font><font |
| color="#000000">Book</font><br /> |
| |
| <font color="#000000">{</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">/**</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">* @generated</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">* @ordered</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">*/</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#7f0055"><b>protected static final </b></font><font |
| color="#000000">Date PUBLICATION_DATE_EDEFAULT = </font><font |
| color="#7f0055"><b>null</b></font><font color="#000000">;</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f7f5f">// comment immediately following the PUBLICATION_DATE_EDEFAULT will make the 'title' field</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f7f5f">// inserted without empty lines after the move</font><br /> |
| |
| <font color="#ffffff"> </font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">/**</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">* @generated</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">* @ordered</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">*/</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#7f0055"><b>protected </b></font><font |
| color="#000000">Date publicationDate = PUBLICATION_DATE_EDEFAULT;</font><br /> |
| |
| <font color="#ffffff"> </font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f7f5f">// comments after removed 'isbn' are kept</font><br /> |
| |
| <font color="#ffffff"> </font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">/**</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">* @generated</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">* @ordered</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">*/</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#7f0055"><b>protected static final </b></font><font |
| color="#000000">String AUTHOR_EDEFAULT = </font><font |
| color="#7f0055"><b>null</b></font><font color="#000000">;</font><br /> |
| |
| <font color="#ffffff"></font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">/**</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">* @generated</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">* @ordered</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">*/</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#7f0055"><b>protected </b></font><font |
| color="#000000">String author = AUTHOR_EDEFAULT;</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f7f5f">// preceding comments will be moved with 'TITLE_EDEFAULT'</font><br /> |
| |
| <font color="#ffffff"> </font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">/**</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">* @generated</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">* @ordered</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">*/</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#7f0055"><b>protected static final </b></font><font |
| color="#000000">String TITLE_EDEFAULT = </font><font |
| color="#7f0055"><b>null</b></font><font color="#000000">;</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">/**</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">* @generated</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">* @ordered</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f5fbf">*/</font><br /> |
| |
| <font color="#ffffff"> </font><font color="#7f0055"><b>protected </b></font><font |
| color="#000000">String title = TITLE_EDEFAULT;</font><br /> |
| |
| <font color="#ffffff"> </font><br /> |
| |
| <font color="#ffffff"> </font><font color="#3f7f5f">// hanging comments after 'title' before removed 'isbn' one will be moved with 'title' </font><br /> |
| |
| <font color="#000000">}</font></code></td> |
| <!-- end source code --> |
| </tr> |
| |
| </table> |
| </div> |
| <!-- = END of automatically generated HTML code = --> <!-- ======================================================== --> |
| |
| |
| |
| </blockquote> |
| |
| |
| </li> |
| |
| <li> |
| |
| <p>Note that hanging comments before removed <code>isbn</code> |
| field have been kept and moved with <code>title</code> field. Previous |
| implementation removes all the comments preceding removed nodes.</p> |
| <p>There are no empty lines before <code>title</code> field due the |
| line comments immediately following <code>PUBLICATION_DATE_EDEFAULT</code> |
| field.</p> |
| |
| </li> |
| |
| </ol> |
| |
| <h2><a name="_Switching_to_Previous_Implementation"></a>Switching |
| to the Previous Behaviour of EMF Code Merge</h2> |
| |
| <p>If you do not like the new behaviour of code merge, you can |
| switch to the previous behaviour. Note that the previous behaviour does |
| not support Java 5.0.</p> |
| |
| <p>To switch to the previous behaviour of EMF code merge, follow |
| these steps:</p> |
| |
| <ol> |
| |
| <li> |
| <p>Open <b>Properties View</b> for your <code>.genmodel</code> |
| file.</p> |
| <ol> |
| |
| <li> |
| <p>To open EMF Generator, double-click on your <code>.genmodel</code> |
| file.</p> |
| </li> |
| |
| <li> |
| <p>Right-click on your model and select <b>Show Properties |
| View</b>.</p> |
| <p><img src="images/show_properties_view.png" /> |
| </p> |
| </li> |
| |
| </ol> |
| </li> |
| |
| <li> |
| <p>In <b>Properties</b> window, set <b>Templates & Merge |
| > Facade Helper Class</b> to <b>org.eclipse.emf.codegen.merge.java.facade.jdom.JDOMFacadeHelper</b>. |
| This property sets the implementation class of the source code |
| manipulation API.</p> |
| <p><img src="images/facade_helper_property.png" /> |
| </p> |
| </li> |
| |
| </ol> |
| |
| <p>If you would like to switch back to the new behaviour at a later |
| time, set the above property to <b>org.eclipse.emf.codegen.merge.java.facade.ast.ASTFacadeHelper</b>.</p> |
| |
| |
| <h2><a name="_JMerger"></a>Changes to the JMerger Behaviour</h2> |
| |
| <p>JMerger now uses a new implementation of source code manipulation |
| API for merging Java code. The new implementation uses JDT AST package, |
| and adds support for Java 5.0. Previously, JMerger used implementation |
| of the API based on JDOM package.</p> |
| |
| <p>There are some changes in behaviour of JMerger rules due to the |
| new implementation.</p> |
| |
| <h3>Comments Handling</h3> |
| |
| <h4>GetComment and SetComment Methods</h4> |
| |
| <p>Methods getComment and setComment of a Member node operate only |
| on Javadoc immediately preceding the Member.</p> |
| |
| <h4>New Nodes</h4> |
| |
| <p>When any Node is copied from source to target, the Javadoc |
| immediately preceding the Node and a line comment at the last line of |
| the Node are the only surrounding comments that are copied with the |
| Node. No other leading or trailing comments are copied.</p> |
| |
| <h4>Sort Rule</h4> |
| |
| <p>If Fields are moved (sort rule), Javadoc, all comments preceding |
| the Field, and a line comment at the last line of the Field are moved |
| with the Field. However, when the first Field of the Type is moved, |
| preceding hanging comments are not moved with the Field.</p> |
| |
| <h4>Sweep Rule</h4> |
| |
| <p>If Member is removed, Javadoc, all comments preceding the Member, |
| and a line comment at the last line of the Member are removed. The |
| hanging comments between Member nodes are kept if at most one of the two |
| Member nodes surrounding the comments is removed. If the removed Member |
| is preceded by a Field that is being moved, comments between these nodes |
| will be moved with the Field.</p> |
| |
| <h4>JDOM Implementation Behaviour</h4> |
| |
| <p>JDOM implementation uses all preceding comments in the |
| getComment/setComment methods. In addition, all preceding comments and |
| the line comment at the last line of the node are moved, copied, and |
| removed with the node.</p> |
| |
| <h3>Indentation</h3> |
| |
| <p>AST uses formatter options from Javacore to format the code and |
| to calculate the indentation of the inserted and moved nodes. Therefore, |
| it is important that Javacore options are set correctly.</p> |
| |
| <p>The <code>indent</code> parameter in <code>merge.xml</code> (or |
| another XML file used for initialization of <code>JControlModel</code>) |
| allows overwriting of the options from Javacore. If <code>indent</code> |
| option is set, AST Facade implementation determines the indentation |
| options as follows. Tab character is set to tab or space based on the |
| first character of <code>indent</code> string. Tab size and indentation |
| size are both set to be the length of <code>indent</code> string.</p> |
| |
| <p>Here is an example of the fragment of <code>merge.xml</code> file |
| that sets indentation to be two spaces.</p> |
| |
| <pre><code> |
| <?xml version="1.0" encoding="UTF-8"?> |
| <merge:options |
| indent=" " |
| xmlns:merge="http://www.eclipse.org/org/eclipse/emf/codegen/jmerge/Options"> |
| </code></pre> |
| |
| <p>To set the indent to be one tab character, use <code>indent="&#x9;"</code> |
| instead.</p> |
| |
| <p>Note that AST implementation same as JDOM replaces all leading |
| tab characters on each line by indent string when nodes are copied from |
| the source to the target.</p> |
| |
| <h3>Brace Style</h3> |
| |
| AST implementation uses brace style that is used in source and target |
| files. JDOM implementation always uses standard brace style for the |
| opening brace of the class and interface. With JDOM implementation, |
| option |
| <code>braceStyle</code> |
| in |
| <code>merge.xml</code> |
| has to be used to correct this behaviour. |
| |
| <h3>Empty Lines</h3> |
| |
| <p>When Member nodes are inserted, empty lines surrounding new |
| Member nodes are inserted based on existing nodes. If there are comments |
| surrounding existing nodes in the target file, new lines might not be |
| inserted as desired.</p> |
| |
| <h3>Using Code Manipulation API (Facade) Implementation Outside |
| JMerger</h3> |
| |
| <p>If you are developing a custom code manipulation tool based on |
| the AST Facade implementation (<code>org.eclipse.emf.codegen.merge.java.facade.ast</code> |
| package), you should be aware of some limitations of this |
| implementation.</p> |
| |
| <ol> |
| <li> |
| <p>Changes made to the tree are not reflected by <code>get()</code> |
| methods. Therefore, all information must be gathered before making |
| changes to the nodes. |
| </li> |
| <li> |
| <p>Nodes copied (i.e. from the source to the target tree) by |
| calling <code>cloneNode(...)</code> do not have an internal structure |
| or content for attributes and child nodes.</p> |
| </li> |
| </ol> |
| |
| <p>There are a few reasons for such limitations. AST does not keep |
| contents of each node in the node itself. Since JMerger is string based, |
| <code>set()</code> methods replace the nodes with string placeholder |
| nodes that do not have an internal structure. Nodes are cloned and moved |
| by using similar string placeholders. In situations where a node is |
| cloned, moved, inserted, or replaced by string content, it would be an |
| extra overhead to keep the original content for each child and attribute |
| of the node.</p> |
| |
| <p>For more information about the AST Facade implementation, see |
| Javadoc for classes in <code>org.eclipse.emf.codegen.merge.java.facade.ast</code> |
| package.</p> |
| </body> |
| </html> |