File: annotations.tpl

package info (click to toggle)
ruby-rgen 0.10.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,428 kB
  • sloc: ruby: 11,344; xml: 1,368; yacc: 72; makefile: 10
file content (37 lines) | stat: -rw-r--r-- 1,259 bytes parent folder | download | duplicates (11)
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
<% define 'Annotations', :for => EPackage do %>
	<% for a in eAnnotations %>
		annotation <% expand 'AnnotationArgs', :for => a %>
	<% end %>
<% end %>

<% define 'Annotations', :for => EClass do %>
	<% for a in eAnnotations %>
		annotation <% expand 'AnnotationArgs', :for => a %>
	<% end %>
<% end %>

<% define 'Annotations', :for => EStructuralFeature do %>
	<% oppositeAnnotations = (this.respond_to?(:eOpposite) && eOpposite && eOpposite.eAnnotations) || [] %>
	<% if eAnnotations.size > 0 || oppositeAnnotations.size > 0 %>
		do<%iinc%>
			<% for a in eAnnotations %>
				annotation <% expand 'AnnotationArgs', :for => a %>
			<% end %>
			<% for a in oppositeAnnotations %>
				opposite_annotation <% expand 'AnnotationArgs', :for => a %>
			<% end %><%idec%>
		end<%nows%>
	<% end %>
<% end %>

<% define 'AnnotationArgs', :for => EAnnotation do %>
	<% if source.nil? %>
		<% expand 'Details' %>
	<% else %>
		:source => "<%= source.to_s %>", :details => {<% expand 'Details' %>}<%nows%>
	<% end %>
<% end %>

<% define 'Details', :for => EAnnotation do %>
	<%= details.sort{|a,b| a.key<=>b.key}.collect{ |d| "\'" + d.key + "\' => \'"+ (d.value || "").gsub('\'','\\\'').to_s + "\'"}.join(', ') %><%nows%>
<% end %>