@@ -153,11 +153,12 @@ module SourceSinkInterpretationInput implements
153
153
// Methods having multiple qualified names, a given Method is liable to have
154
154
// more than one SourceOrSinkElement, one for each of the names it claims.
155
155
private newtype TSourceOrSinkElement =
156
- TMethodOrFieldEntityElement ( Entity e , string pkg , string type , boolean subtypes ) {
157
- (
158
- e .( Method ) .hasQualifiedName ( pkg , type , _) or
159
- e .( Field ) .hasQualifiedName ( pkg , type , _)
160
- ) and
156
+ TMethodEntityElement ( Method m , string pkg , string type , boolean subtypes ) {
157
+ m .hasQualifiedName ( pkg , type , _) and
158
+ subtypes = [ true , false ]
159
+ } or
160
+ TFieldEntityElement ( Field f , string pkg , string type , boolean subtypes ) {
161
+ f .hasQualifiedName ( pkg , type , _) and
161
162
subtypes = [ true , false ]
162
163
} or
163
164
TOtherEntityElement ( Entity e ) {
@@ -170,10 +171,15 @@ module SourceSinkInterpretationInput implements
170
171
class SourceOrSinkElement extends TSourceOrSinkElement {
171
172
/** Gets this source or sink element as an entity, if it is one. */
172
173
Entity asEntity ( ) {
173
- this = TMethodOrFieldEntityElement ( result , _, _, _) or
174
- this = TOtherEntityElement ( result )
174
+ result = [ this .asMethodEntity ( ) , this .asFieldEntity ( ) , this .asOtherEntity ( ) ]
175
175
}
176
176
177
+ Method asMethodEntity ( ) { this = TMethodEntityElement ( result , _, _, _) }
178
+
179
+ Field asFieldEntity ( ) { this = TFieldEntityElement ( result , _, _, _) }
180
+
181
+ Entity asOtherEntity ( ) { this = TOtherEntityElement ( result ) }
182
+
177
183
/** Gets this source or sink element as an AST node, if it is one. */
178
184
AstNode asAstNode ( ) { this = TAstElement ( result ) }
179
185
@@ -182,7 +188,8 @@ module SourceSinkInterpretationInput implements
182
188
* with the given values for `pkg`, `type` and `subtypes`.
183
189
*/
184
190
predicate hasTypeInfo ( string pkg , string type , boolean subtypes ) {
185
- this = TMethodOrFieldEntityElement ( _, pkg , type , subtypes )
191
+ this = TMethodEntityElement ( _, pkg , type , subtypes ) or
192
+ this = TFieldEntityElement ( _, pkg , type , subtypes )
186
193
}
187
194
188
195
/** Gets a textual representation of this source or sink element. */
@@ -239,11 +246,10 @@ module SourceSinkInterpretationInput implements
239
246
cn = this .asCall ( ) .getNode ( ) and
240
247
callTarget = cn .getTarget ( )
241
248
|
242
- result .asEntity ( ) = callTarget and
243
249
(
244
- not callTarget instanceof Method
250
+ result . asOtherEntity ( ) = callTarget
245
251
or
246
- callTarget instanceof Method and
252
+ result . asMethodEntity ( ) = callTarget and
247
253
elementAppliesToQualifier ( result , cn .getReceiver ( ) )
248
254
)
249
255
)
@@ -302,7 +308,7 @@ module SourceSinkInterpretationInput implements
302
308
// `syntacticQualBaseType`'s underlying type might be a struct type and `sse`
303
309
// might be a promoted method or field in it.
304
310
targetType =
305
- getIntermediateEmbeddedType ( sse .asEntity ( ) , syntacticQualBaseType .getUnderlyingType ( ) )
311
+ getIntermediateEmbeddedType ( sse .asMethodEntity ( ) , syntacticQualBaseType .getUnderlyingType ( ) )
306
312
)
307
313
)
308
314
}
@@ -382,7 +388,7 @@ module SourceSinkInterpretationInput implements
382
388
or
383
389
exists ( DataFlow:: FieldReadNode frn | frn = n |
384
390
c = "" and
385
- frn .getField ( ) = pragma [ only_bind_into ] ( e ) .asEntity ( ) and
391
+ frn .getField ( ) = pragma [ only_bind_into ] ( e ) .asFieldEntity ( ) and
386
392
elementAppliesToQualifier ( pragma [ only_bind_into ] ( e ) , frn .getBase ( ) )
387
393
)
388
394
)
@@ -400,7 +406,7 @@ module SourceSinkInterpretationInput implements
400
406
or
401
407
exists ( SourceOrSinkElement e , DataFlow:: Write fw , DataFlow:: Node base , Field f |
402
408
e = mid .asElement ( ) and
403
- f = e .asEntity ( )
409
+ f = e .asFieldEntity ( )
404
410
|
405
411
c = "" and
406
412
fw .writesField ( base , f , node .asNode ( ) ) and
0 commit comments