File: merge.xml

package info (click to toggle)
eclipse-emf 2.5.0-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 50,912 kB
  • ctags: 60,697
  • sloc: java: 407,889; xml: 7,165; sh: 200; makefile: 13
file content (308 lines) | stat: -rwxr-xr-x 10,584 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
<?xml version="1.0" encoding="UTF-8"?>
<merge:options 
  indent="    "  
  braceStyle="standard"  
  redirect="Gen"
  xmlns:merge="http://www.eclipse.org/org/eclipse/emf/codegen/jmerge/Options">



<!-- PATTERNS -->
    <!--
    	Markup:  gen 
    	Applies: Member comments
    	Purpose: Recognized members (types, fields, ...) whose javadoc contains
			         @generated "... (...)" NL
    	-->
    <merge:dictionaryPattern
      name="generatedMembers" 
      select="Member/getComment" 
      match="\s*@\s*(gen)erated\s*(?:&quot;.*?&quot;)?\s*\n"/>

    <!--
    	Markup:  private 
    	Applies: Member comments
		Purpose: Recognize members marked as non-modifable via
		             @generated private "... (...)" NL
    	-->
    <merge:dictionaryPattern
      name="privateMembers" 
      select="Member/getComment" 
      match="\s*@\s*generated\s*(private)\s*(?:&quot;.*?&quot;)?\s*\n"/>

    <!-- 
    	Markup:  gen
    	Applies: Initializer Body
    	Purpose: Recognize initializers whose body contains
    	     		// @generated "... (...)" NL
    	Note:    This is necessary because JDOM doesn't associated Javadoc comments
		         with initializers
    	-->
    <merge:dictionaryPattern
      name="generatedInitializer"
      select="Initializer/getBody"
      match="//\s*@\s*(gen)erated\s*(?:&quot;.*?&quot;)?\s*\n"/>

    <!--
        Markup:  ordered 
        Applies: Field comment
		Purpose: Recognized field sorting marker 
		-->
    <merge:dictionaryPattern
      name="orderedMembers" 
      select="Field/getComment" 
      match="\s*@\s*(ordered)\s*\n"/>

    <!-- 
    	Markup:  generated.*user-code | gener
    	Applies: Method contents
    	Purpose: Recognize constructor (actually methods) with user editable sections in the body
    	Note:    The pattern must yield unique markups for the case where there is a user-code block
    	        and cases where there is not. In addition, the no user-code block case must have
    	        a markup that is distinct from other markups (^gen$ for general rules, ^generated$
    	        for no user-doc block. Unfortunately, JMerge doesn't let use be more explicit, but
    	          gen => node has a @generated tag
    	          gener => node is a method/constructor and has no user-code block
    	          generated => node java doc is @generated by has no user-doc block
    	        
    	--> 
    <merge:dictionaryPattern
      name="userCodeConstructor"
      select="Method/getContents"
      match="(?:\s*@\s*(generated\s*(?:&quot;.*?&quot;)?\s*\n.*?\s*//\s*begin-user-code).*?//\s*end-user-code\s*\n)|(?:\s*@\s*(gener)ated\s*(?:&quot;.*?&quot;)?\s*\n)" />

	<!--
		Markup:  user-doc.*generated  | generated.*user-doc | generated
		Applies: Member comment
		Purpose: Recognize javadoc comments that include both @generated and begin-user-doc/end-user-doc
				markers
    	Note:    The pattern must yield unique markups for the case where there is a user-doc block
    	        and cases where there is not. In addition, the no user-code block case must have
    	        a markup that is distinct from other markups (^gen$ for general rules, ^generated$
    	        for no user-doc block. Unfortunately, JMerge doesn't let use be more explicit, but
    	          gen => node has a @generated tag
    	          gener => node is a method/constructor and has no user-code block
    	          generated => node java doc is @generated but has no user-doc block
	-->
    <merge:dictionaryPattern
      name="userDocComment"
      select="Member/getComment"
      match="(?:\s*@\s*(generated\s*(?:&quot;.*?&quot;)?\s*\n.*?&lt;!--\s*begin-user-doc.*?\s*end-user-doc)\s*-->)|(?:&lt;!--\s*begin-(user-doc.*?\s*end-user-doc\s*-->.*?\s*@\s*generated)\s*(?:&quot;.*?&quot;)?\s*\n)|(?:\s*@\s*(generated)\s*(?:&quot;.*?&quot;)?\s*\n)" />

<!-- 
************ IMPORTANT NOTE ABOUT MATCHING Markups ************
	When JMerge uses sourceMarkup or targetMarkup patterns below, it treats ^ and $ as beginning of 
    line and end-of-line, respectively. 
    *** HOWEVER ***, some of the dictionary patterns above yeild multi-line markups (e.g. generated.*user-doc). 
    *** THEREFORE ***, in markup patterns below, you should consider whether your mean ^ or \A (beginning of input),
    and $ or \z (end of input).
    At the point of adding this comment, all of the patterns used \A and \z. You should probably do the same.
-->

  <merge:match
   markup="^gen$"
   get="Method/getName"
   signature="\s*((?:pre|post)Validate)?\w*\s*"/>
  <merge:match
   markup="^gen$"
   get="Method/getComment"
   signature="\s*@\s*uuid\s*(\S*)\s*\n"/>


<!-- PULL RULES 

	These rules transfer elements of the emitted code (JMerge calls this "source") into
	the existing code (JMerge calls this "target").
	
	Without a pull rules, JMerge will only transfer emitted elements that are not already in 
	the existing code.
	-->
	
	<!--
		Markup:  \Agen\z -> \Agenerated\z
		Applies: Member comments
		Purpose: Copy emitted comments to existing generated members who do
				not have begin-user-doc / end-user-doc comments.
	-->
    <merge:pull
      sourceMarkup="\Agen\z"
      sourceGet="Member/getComment"
      targetMarkup="\Agenerated\z"
      targetPut="Member/setComment"/>

	<!--
		Markup:  \Auser-doc.*generated\z|\Agenerated.*user-doc\z
		Purpose: Preserve existing comments between begin-user-doc / end-user-doc
				but update remainder of comment.
	-->
    <merge:pull 
      sourceMarkup="\Auser-doc.*generated\z|\Agenerated.*user-doc\z"
      sourceGet="Member/getComment"
      sourceTransfer="(\s*&lt;!--\s*begin-user-doc.*?end-user-doc\s*-->\s*)"
      targetMarkup="\Auser-doc.*generated\z|\Agenerated.*user-doc\z"
      targetPut="Member/setComment"/>

	<!--
		Markup: \Agen\z -> \Agen\z
		Applies: Member flags
		Purpose: Copy emitted member flags (public, private, static...) to existing
				generated members.
	-->
	<merge:pull
	  sourceMarkup="\Agen\z"
	  targetMarkup="\Agen\z"
	  sourceGet="Member/getFlags"
	  targetPut="Member/setFlags"/>
	  
	<!--
	   Markup:  \Agen\z -> \Agen\z
	   Applies: Field initializers
	   Purpose: Copy emitted initializers to existing fields.
	   -->
	<merge:pull
	  sourceMarkup="\Agen\z"
	  targetMarkup="\Agen\z"
	  sourceGet="Field/getInitializer"
	  targetPut="Field/setInitializer"/>
	  
	<!--
	   Markup:  \Agen\z -> \Agen\z
	   Applies: Field types
	   Purpose: Copy emitted Field types to existing fields.
	   -->
	<merge:pull
	  sourceMarkup="\Agen\z"
	  targetMarkup="\Agen\z"
	  sourceGet="Field/getType"
	  targetPut="Field/setType"/>
	  
	<!--
	   Markup:  \Agen\z -> \Agen\z
	   Applies: Method returntypes
	   Purpose: Copy emitted Method return types to existing methods.
	-->
	<merge:pull
	  sourceMarkup="\Agen\z"
	  targetMarkup="\Agen\z"
	  sourceGet="Method/getReturnType"
	  targetPut="Method/setReturnType"/>

	<!--
	   Markup:  \Agen\z -> \Agen\z
	   Applies: Method declared exceptions
	   Purpose: Copy emitted Method declared exceptions to existing methods.
	-->
	<merge:pull
	  sourceMarkup="\Agen\z"
	  targetMarkup="\Agen\z"
	  sourceGet="Method/getExceptions"
	  targetPut="Method/setExceptions"/>

	<!-- 
		Markup:  \Agen\z -> \Agener\z
		Applies: Method bodies
		Purpose: Copy entire method bodies from emitted code to existing methods
				that have generated tag, but no user-code block
		Note:	 See note for the Pattern "userCodeConstructor" for distinctions between
				\Agen\z, \Agener\z, and \Agenerated\z
	-->
	<merge:pull
	  sourceMarkup="\Agen\z"
	  targetMarkup="\Agener\z"
	  sourceGet="Method/getBody"
	  targetPut="Method/setBody"/>
	  
	<!--
		Markup:  \Agenerated.*user-code\z -> \Agenerated.*user-code\z
		Applies: Method bodies
		Purpose: Copy emitted method bodies to existing code, but preserving existing code
				within the begin-user-code / end-user-code blocks
	-->
	<merge:pull
	  sourceMarkup="\Agenerated.*user-code\z"
	  targetMarkup="\Agenerated.*user-code\z"
      sourceTransfer="(\s*//\s*begin-user-code.*?end-user-code\s*)\n"
	  sourceGet="Method/getBody"
	  targetPut="Method/setBody"/>
	  

	<!--
		Markup:  \Agen\z -> \Agen\z
		Applies  Type class (interface or class keyword)
		Purpose: Copy the emitted type (interface/class) to the existing type marked with @generated
	-->
	<!--
	<merge:pull
	  sourceMarkup="\Agen\z"
	  targetMarkup="\Agen\z"
	  sourceGet="Type/isClass"
	  targetPut="Type/setClass"/>
	-->
	
	<!--
		Markup:  \Agen\z -> \Agen\z
		Applies  Type supertype
		Purpose: Copy the emitted super type to the existing type marked with @generated
	-->
	<merge:pull
	  sourceMarkup="\Agen\z"
	  targetMarkup="\Agen\z"
	  sourceGet="Type/getSuperclass"
	  targetPut="Type/setSuperclass"/>
	  
	<!--
		Markup:  \Agen\z -> \Agen\z
		Applies: Type superInterfaces
		Purpose: Copy emitted super interfaces to existing types marked with @generated
	-->
	<merge:pull
	  sourceMarkup="\Agen\z"
	  targetMarkup="\Agen\z"
	  sourceGet="Type/getSuperInterfaces"
	  targetPut="Type/addSuperInterface"/>
		
	<!--
		Markup:  any
		Applies: Package name
		Purpose: Always update the existing package with the emitted package.
		Note:    This may be an acedemic exercise as a change in the package would result in a change
		         in file location, and we likely wouldn't be doing a re-apply.
	    ****** IMPORTANT ******
	    This rule is disabled for the following reasons:
	      1) its marginal value
	      2) JMerge dies a horrible death if it attempts to merge to/from a default package
	-->
	<!--  DISABLED <merge:pull
	  sourceGet="Package/getName"
	  targetPut="Package/setName"/> -->
	  
<!-- SWEEP RULES 

    These rules remove code from the target (so long as they have the identified markup)
    that were not present in the emitted source. (Presumably, these were once present in the
    emitted source.
    -->
    
    <!--
    	Markup:  gen
    	Purpose: Remove once generated methods that are no longer generated
    	-->
    <merge:sweep markup="\Agen\z" select="Field" action="rename" newName="DELETED_{0}"/>
    <merge:sweep markup="\Agen\z" select="Type" action="rename" newName="DELETED_{0}"/>
    <merge:sweep markup="\Agen\z" select="Method" action="rename" newName="DELETED_{0}"/>
    
    <!--
    	Markup:  private
    	Purpose: Remove once generated methods that are no longer generated
    	-->
    <merge:sweep markup="\Aprivate\z" select="Member" action="rename" newName="DELETED_{0}"/>


<!-- SORT RULES 
	
	These rules cause fields (with the identified markup) to be sorted in the target.
	-->
	
    <merge:sort markup="\Aordered\z" select="Member"/>

</merge:options>