@@ -203,24 +203,32 @@ class Content extends TContent {
203203
204204/** Provides different sub classes of `Content`. */
205205module Content {
206- /** An element in an array. */
207- class ArrayElementContent extends Content , TArrayElementContent { }
206+ /** An element in an collection, for example an element in array or in a hash . */
207+ class ElementContent extends Content , TElementContent { }
208208
209- /** An element in an array at a known index. */
210- class KnownArrayElementContent extends ArrayElementContent , TKnownArrayElementContent {
211- private int i ;
209+ /** An element in a collection at a known index. */
210+ class KnownElementContent extends ElementContent , TKnownElementContent {
211+ private ConstantValue cv ;
212212
213- KnownArrayElementContent ( ) { this = TKnownArrayElementContent ( i ) }
213+ KnownElementContent ( ) { this = TKnownElementContent ( cv ) }
214214
215- /** Gets the index in the array . */
216- int getIndex ( ) { result = i }
215+ /** Gets the index in the collection . */
216+ ConstantValue getIndex ( ) { result = cv }
217217
218- override string toString ( ) { result = "array element " + i }
218+ override string toString ( ) { result = "element " + cv }
219219 }
220220
221- /** An element in an array at an unknown index. */
222- class UnknownArrayElementContent extends ArrayElementContent , TUnknownArrayElementContent {
223- override string toString ( ) { result = "array element" }
221+ /** An element in a collection at an unknown index. */
222+ class UnknownElementContent extends ElementContent , TUnknownElementContent {
223+ override string toString ( ) { result = "element" }
224+ }
225+
226+ /** Gets the element content corresponding to constant value `cv`. */
227+ ElementContent getElementContent ( ConstantValue cv ) {
228+ result = TKnownElementContent ( cv )
229+ or
230+ not exists ( TKnownElementContent ( cv ) ) and
231+ result = TUnknownElementContent ( )
224232 }
225233}
226234
@@ -234,8 +242,8 @@ class ContentSet extends TContentSet {
234242 /** Holds if this content set is the singleton `{c}`. */
235243 predicate isSingleton ( Content c ) { this = TSingletonContent ( c ) }
236244
237- /** Holds if this content set represent all `ArrayElementContent `s. */
238- predicate isAnyArrayElement ( ) { this = TAnyArrayElementContent ( ) }
245+ /** Holds if this content set represents all `ElementContent `s. */
246+ predicate isAnyElement ( ) { this = TAnyElementContent ( ) }
239247
240248 /** Gets a textual representation of this content set. */
241249 string toString ( ) {
@@ -244,24 +252,24 @@ class ContentSet extends TContentSet {
244252 result = c .toString ( )
245253 )
246254 or
247- this .isAnyArrayElement ( ) and
255+ this .isAnyElement ( ) and
248256 result = "any array element"
249257 }
250258
251259 /** Gets a content that may be stored into when storing into this set. */
252260 Content getAStoreContent ( ) {
253261 this .isSingleton ( result )
254262 or
255- this .isAnyArrayElement ( ) and
256- result = TUnknownArrayElementContent ( )
263+ this .isAnyElement ( ) and
264+ result = TUnknownElementContent ( )
257265 }
258266
259267 /** Gets a content that may be read from when reading from this set. */
260268 Content getAReadContent ( ) {
261269 this .isSingleton ( result )
262270 or
263- this .isAnyArrayElement ( ) and
264- result instanceof Content:: ArrayElementContent
271+ this .isAnyElement ( ) and
272+ result instanceof Content:: ElementContent
265273 }
266274}
267275
0 commit comments