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 @@ -140,6 +140,21 @@ string getFieldToken(FieldContent fc) {
140
140
fc .getField ( ) .getName ( )
141
141
}
142
142
143
+ /**
144
+ * Returns a valid Java token naming the synthetic field `fc`,
145
+ * assuming that the name of that field consists only of characters valid in a Java identifier and `.`.
146
+ */
147
+ string getSyntheticFieldToken ( SyntheticFieldContent fc ) {
148
+ exists ( string name , int parts |
149
+ name = fc .getField ( ) and
150
+ parts = count ( name .splitAt ( "." ) )
151
+ |
152
+ if parts = 1
153
+ then result = name
154
+ else result = name .splitAt ( "." , parts - 2 ) + "_" + name .splitAt ( "." , parts - 1 )
155
+ )
156
+ }
157
+
143
158
/**
144
159
* Returns a token suitable for incorporation into a Java method name describing content `c`.
145
160
*/
@@ -153,6 +168,8 @@ string contentToken(Content c) {
153
168
c instanceof MapValueContent and result = "MapValue"
154
169
or
155
170
result = getFieldToken ( c )
171
+ or
172
+ result = getSyntheticFieldToken ( c )
156
173
}
157
174
158
175
/**
@@ -425,6 +442,8 @@ class TestCase extends TTestCase {
425
442
content instanceof CollectionContent and result = "Element"
426
443
or
427
444
result = "Field[" + content .( FieldContent ) .getField ( ) .getQualifiedName ( ) + "]"
445
+ or
446
+ result = "SyntheticField[" + content .( SyntheticFieldContent ) .getField ( ) + "]"
428
447
)
429
448
)
430
449
}
You can’t perform that action at this time.
0 commit comments