@@ -1249,12 +1249,65 @@ predicate allowParameterReturnInSelf(ParameterNode p) {
12491249 )
12501250}
12511251
1252+ bindingset [ s]
1253+ private string getFirstChar ( string s ) {
1254+ result =
1255+ min ( int i , string c |
1256+ c = s .charAt ( i ) and c != "_"
1257+ or
1258+ c = "" and i = s .length ( )
1259+ |
1260+ c order by i
1261+ )
1262+ }
1263+
1264+ private string getAttributeContentFirstChar ( AttributeContent ac ) {
1265+ result = getFirstChar ( ac .getAttribute ( ) )
1266+ }
1267+
1268+ private string getDictionaryElementContentKeyFirstChar ( DictionaryElementContent dec ) {
1269+ result = getFirstChar ( dec .getKey ( ) )
1270+ }
1271+
1272+ private newtype TContentApprox =
1273+ TListElementContentApprox ( ) or
1274+ TSetElementContentApprox ( ) or
1275+ TTupleElementContentApprox ( ) or
1276+ TDictionaryElementContentApprox ( string first ) {
1277+ first = "" // for `TDictionaryElementAnyContent`
1278+ or
1279+ first = getDictionaryElementContentKeyFirstChar ( _)
1280+ } or
1281+ TAttributeContentApprox ( string first ) { first = getAttributeContentFirstChar ( _) } or
1282+ TCapturedVariableContentApprox ( )
1283+
12521284/** An approximated `Content`. */
1253- class ContentApprox = Unit ;
1285+ class ContentApprox extends TContentApprox {
1286+ /** Gets a textual representation of this element. */
1287+ string toString ( ) { result = "" }
1288+ }
12541289
12551290/** Gets an approximated value for content `c`. */
1256- pragma [ inline]
1257- ContentApprox getContentApprox ( Content c ) { any ( ) }
1291+ ContentApprox getContentApprox ( Content c ) {
1292+ c = TListElementContent ( ) and
1293+ result = TListElementContentApprox ( )
1294+ or
1295+ c = TSetElementContent ( ) and
1296+ result = TSetElementContentApprox ( )
1297+ or
1298+ c = TTupleElementContent ( _) and
1299+ result = TTupleElementContentApprox ( )
1300+ or
1301+ result = TDictionaryElementContentApprox ( getDictionaryElementContentKeyFirstChar ( c ) )
1302+ or
1303+ c = TDictionaryElementAnyContent ( ) and
1304+ result = TDictionaryElementContentApprox ( "" )
1305+ or
1306+ result = TAttributeContentApprox ( getAttributeContentFirstChar ( c ) )
1307+ or
1308+ c = TCapturedVariableContent ( _) and
1309+ result = TCapturedVariableContentApprox ( )
1310+ }
12581311
12591312/** Helper for `.getEnclosingCallable`. */
12601313DataFlowCallable getCallableScope ( Scope s ) {
0 commit comments