@@ -23,6 +23,64 @@ newtype JavaRelatedLocationType =
2323 MethodDoc ( ) or
2424 ClassDoc ( )
2525
26+ newtype TFrameworkModeEndpoint =
27+ TExplicitParameter ( Parameter p ) or
28+ TQualifier ( Callable c )
29+
30+ /**
31+ * A framework mode endpoint.
32+ */
33+ abstract class FrameworkModeEndpoint extends TFrameworkModeEndpoint {
34+ /**
35+ * Returns the parameter index of the endpoint.
36+ */
37+ abstract int getIndex ( ) ;
38+
39+ /**
40+ * Returns the name of the parameter of the endpoint.
41+ */
42+ abstract string getParamName ( ) ;
43+
44+ /**
45+ * Returns the callable that contains the endpoint.
46+ */
47+ abstract Callable getEnclosingCallable ( ) ;
48+
49+ abstract Top asTop ( ) ;
50+
51+ string toString ( ) { result = this .asTop ( ) .toString ( ) }
52+
53+ Location getLocation ( ) { result = this .asTop ( ) .getLocation ( ) }
54+ }
55+
56+ class ExplicitParameterEndpoint extends FrameworkModeEndpoint , TExplicitParameter {
57+ Parameter param ;
58+
59+ ExplicitParameterEndpoint ( ) { this = TExplicitParameter ( param ) }
60+
61+ override int getIndex ( ) { result = param .getPosition ( ) }
62+
63+ override string getParamName ( ) { result = param .getName ( ) }
64+
65+ override Callable getEnclosingCallable ( ) { result = param .getCallable ( ) }
66+
67+ override Top asTop ( ) { result = param }
68+ }
69+
70+ class QualifierEndpoint extends FrameworkModeEndpoint , TQualifier {
71+ Callable callable ;
72+
73+ QualifierEndpoint ( ) { this = TQualifier ( callable ) }
74+
75+ override int getIndex ( ) { result = - 1 }
76+
77+ override string getParamName ( ) { result = "this" }
78+
79+ override Callable getEnclosingCallable ( ) { result = callable }
80+
81+ override Top asTop ( ) { result = callable }
82+ }
83+
2684/**
2785 * A candidates implementation for framework mode.
2886 *
@@ -33,7 +91,7 @@ newtype JavaRelatedLocationType =
3391 */
3492module FrameworkCandidatesImpl implements SharedCharacteristics:: CandidateSig {
3593 // for documentation of the implementations here, see the QLDoc in the CandidateSig signature module.
36- class Endpoint = DataFlow :: ParameterNode ;
94+ class Endpoint = FrameworkModeEndpoint ;
3795
3896 class EndpointType = AutomodelEndpointTypes:: EndpointType ;
3997
@@ -46,7 +104,7 @@ module FrameworkCandidatesImpl implements SharedCharacteristics::CandidateSig {
46104 // Sanitizers are currently not modeled in MaD. TODO: check if this has large negative impact.
47105 predicate isSanitizer ( Endpoint e , EndpointType t ) { none ( ) }
48106
49- RelatedLocation asLocation ( Endpoint e ) { result = e .asParameter ( ) }
107+ RelatedLocation asLocation ( Endpoint e ) { result = e .asTop ( ) }
50108
51109 predicate isKnownKind = AutomodelJavaUtil:: isKnownKind / 2 ;
52110
@@ -70,9 +128,7 @@ module FrameworkCandidatesImpl implements SharedCharacteristics::CandidateSig {
70128 FrameworkModeGetCallable:: getCallable ( e ) .hasQualifiedName ( package , type , name ) and
71129 signature = ExternalFlow:: paramsString ( FrameworkModeGetCallable:: getCallable ( e ) ) and
72130 ext = "" and
73- exists ( int paramIdx | e .isParameterOf ( _, paramIdx ) |
74- input = AutomodelJavaUtil:: getArgumentForIndex ( paramIdx )
75- )
131+ input = AutomodelJavaUtil:: getArgumentForIndex ( e .getIndex ( ) )
76132 }
77133
78134 /**
@@ -124,16 +180,13 @@ class FrameworkModeMetadataExtractor extends string {
124180 Endpoint e , string package , string type , string subtypes , string name , string signature ,
125181 string input , string parameterName
126182 ) {
127- exists ( Callable callable , int paramIdx |
128- e .asParameter ( ) = callable .getParameter ( paramIdx ) and
129- input = AutomodelJavaUtil:: getArgumentForIndex ( paramIdx ) and
130- package = callable .getDeclaringType ( ) .getPackage ( ) .getName ( ) and
131- type = callable .getDeclaringType ( ) .getErasure ( ) .( RefType ) .nestedName ( ) and
132- subtypes = AutomodelJavaUtil:: considerSubtypes ( callable ) .toString ( ) and
133- name = callable .getName ( ) and
134- parameterName = e .asParameter ( ) .getName ( ) and
135- signature = ExternalFlow:: paramsString ( callable )
136- )
183+ parameterName = e .getParamName ( ) and
184+ name = e .getEnclosingCallable ( ) .getName ( ) and
185+ input = AutomodelJavaUtil:: getArgumentForIndex ( e .getIndex ( ) ) and
186+ package = e .getEnclosingCallable ( ) .getDeclaringType ( ) .getPackage ( ) .getName ( ) and
187+ type = e .getEnclosingCallable ( ) .getDeclaringType ( ) .getErasure ( ) .( RefType ) .nestedName ( ) and
188+ subtypes = AutomodelJavaUtil:: considerSubtypes ( e .getEnclosingCallable ( ) ) .toString ( ) and
189+ signature = ExternalFlow:: paramsString ( e .getEnclosingCallable ( ) )
137190 }
138191}
139192
@@ -201,7 +254,7 @@ private class NotAModelApiParameter extends CharacteristicsImpl::UninterestingTo
201254 NotAModelApiParameter ( ) { this = "not a model API parameter" }
202255
203256 override predicate appliesToEndpoint ( Endpoint e ) {
204- not exists ( ModelExclusions :: ModelApi api | api . getAParameter ( ) = e . asParameter ( ) )
257+ not e . getEnclosingCallable ( ) instanceof ModelExclusions :: ModelApi
205258 }
206259}
207260
0 commit comments