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) {
140140 fc .getField ( ) .getName ( )
141141}
142142
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+
143158/**
144159 * Returns a token suitable for incorporation into a Java method name describing content `c`.
145160 */
@@ -153,6 +168,8 @@ string contentToken(Content c) {
153168 c instanceof MapValueContent and result = "MapValue"
154169 or
155170 result = getFieldToken ( c )
171+ or
172+ result = getSyntheticFieldToken ( c )
156173}
157174
158175/**
@@ -425,6 +442,8 @@ class TestCase extends TTestCase {
425442 content instanceof CollectionContent and result = "Element"
426443 or
427444 result = "Field[" + content .( FieldContent ) .getField ( ) .getQualifiedName ( ) + "]"
445+ or
446+ result = "SyntheticField[" + content .( SyntheticFieldContent ) .getField ( ) + "]"
428447 )
429448 )
430449 }
You can’t perform that action at this time.
0 commit comments