File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -137,6 +137,21 @@ string getFieldToken(FieldContent fc) {
137
137
fc .getField ( ) .getName ( )
138
138
}
139
139
140
+ /**
141
+ * Returns a valid Java token naming the synthtic field `fc`,
142
+ * assuming that the name of that field consists only of characters valid in a Java identifier and `.`.
143
+ */
144
+ string getSyntheticFieldToken ( SyntheticFieldContent fc ) {
145
+ exists ( string name , int parts |
146
+ name = fc .getField ( ) and
147
+ parts = count ( name .splitAt ( "." ) )
148
+ |
149
+ if parts = 1
150
+ then result = name
151
+ else result = name .splitAt ( "." , parts - 2 ) + "_" + name .splitAt ( "." , parts - 1 )
152
+ )
153
+ }
154
+
140
155
/**
141
156
* Returns a token suitable for incorporation into a Java method name describing content `c`.
142
157
*/
@@ -150,6 +165,8 @@ string contentToken(Content c) {
150
165
c instanceof MapValueContent and result = "MapValue"
151
166
or
152
167
result = getFieldToken ( c )
168
+ or
169
+ result = getSyntheticFieldToken ( c )
153
170
}
154
171
155
172
/**
@@ -422,6 +439,8 @@ class TestCase extends TTestCase {
422
439
content instanceof CollectionContent and result = "Element"
423
440
or
424
441
result = "Field[" + content .( FieldContent ) .getField ( ) .getQualifiedName ( ) + "]"
442
+ or
443
+ result = "SyntheticField[" + content .( SyntheticFieldContent ) .getField ( ) + "]"
425
444
)
426
445
)
427
446
}
You can’t perform that action at this time.
0 commit comments