@@ -23,6 +23,42 @@ newtype JavaRelatedLocationType =
23
23
MethodDoc ( ) or
24
24
ClassDoc ( )
25
25
26
+ /**
27
+ * A framework mode endpoint.
28
+ */
29
+ abstract class FrameworkModeEndpoint extends Top {
30
+ /**
31
+ * Returns the parameter index of the endpoint.
32
+ */
33
+ abstract int getIndex ( ) ;
34
+
35
+ /**
36
+ * Returns the name of the parameter of the endpoint.
37
+ */
38
+ abstract string getParamName ( ) ;
39
+
40
+ /**
41
+ * Returns the callable that contains the endpoint.
42
+ */
43
+ abstract Callable getEnclosingCallable ( ) ;
44
+ }
45
+
46
+ class ParameterEndpoint extends FrameworkModeEndpoint instanceof Parameter {
47
+ override int getIndex ( ) { result = this .( Parameter ) .getPosition ( ) }
48
+
49
+ override string getParamName ( ) { result = this .( Parameter ) .getName ( ) }
50
+
51
+ override Callable getEnclosingCallable ( ) { result = this .( Parameter ) .getCallable ( ) }
52
+ }
53
+
54
+ class QualifierEndpoint extends FrameworkModeEndpoint instanceof Callable {
55
+ override int getIndex ( ) { result = - 1 }
56
+
57
+ override string getParamName ( ) { result = "this" }
58
+
59
+ override Callable getEnclosingCallable ( ) { result = this }
60
+ }
61
+
26
62
/**
27
63
* A candidates implementation for framework mode.
28
64
*
@@ -33,7 +69,7 @@ newtype JavaRelatedLocationType =
33
69
*/
34
70
module FrameworkCandidatesImpl implements SharedCharacteristics:: CandidateSig {
35
71
// for documentation of the implementations here, see the QLDoc in the CandidateSig signature module.
36
- class Endpoint = DataFlow :: ParameterNode ;
72
+ class Endpoint = FrameworkModeEndpoint ;
37
73
38
74
class EndpointType = AutomodelEndpointTypes:: EndpointType ;
39
75
@@ -46,7 +82,7 @@ module FrameworkCandidatesImpl implements SharedCharacteristics::CandidateSig {
46
82
// Sanitizers are currently not modeled in MaD. TODO: check if this has large negative impact.
47
83
predicate isSanitizer ( Endpoint e , EndpointType t ) { none ( ) }
48
84
49
- RelatedLocation asLocation ( Endpoint e ) { result = e . asParameter ( ) }
85
+ RelatedLocation asLocation ( Endpoint e ) { result = e }
50
86
51
87
predicate isKnownKind = AutomodelJavaUtil:: isKnownKind / 2 ;
52
88
@@ -70,9 +106,7 @@ module FrameworkCandidatesImpl implements SharedCharacteristics::CandidateSig {
70
106
FrameworkModeGetCallable:: getCallable ( e ) .hasQualifiedName ( package , type , name ) and
71
107
signature = ExternalFlow:: paramsString ( FrameworkModeGetCallable:: getCallable ( e ) ) and
72
108
ext = "" and
73
- exists ( int paramIdx | e .isParameterOf ( _, paramIdx ) |
74
- input = AutomodelJavaUtil:: getArgumentForIndex ( paramIdx )
75
- )
109
+ input = AutomodelJavaUtil:: getArgumentForIndex ( e .getIndex ( ) )
76
110
}
77
111
78
112
/**
@@ -124,22 +158,13 @@ class FrameworkModeMetadataExtractor extends string {
124
158
Endpoint e , string package , string type , string subtypes , string name , string signature ,
125
159
string input , string parameterName
126
160
) {
127
- exists ( Callable callable , int paramIdx |
128
- (
129
- e .( DataFlow:: ExplicitParameterNode ) .asParameter ( ) = callable .getParameter ( paramIdx ) and
130
- parameterName = e .asParameter ( ) .getName ( )
131
- or
132
- e .( DataFlow:: InstanceParameterNode ) .getCallable ( ) = callable and
133
- paramIdx = - 1 and
134
- parameterName = "this"
135
- ) and
136
- input = AutomodelJavaUtil:: getArgumentForIndex ( paramIdx ) and
137
- package = callable .getDeclaringType ( ) .getPackage ( ) .getName ( ) and
138
- type = callable .getDeclaringType ( ) .getErasure ( ) .( RefType ) .nestedName ( ) and
139
- subtypes = AutomodelJavaUtil:: considerSubtypes ( callable ) .toString ( ) and
140
- name = callable .getName ( ) and
141
- signature = ExternalFlow:: paramsString ( callable )
142
- )
161
+ parameterName = e .getParamName ( ) and
162
+ name = e .getEnclosingCallable ( ) .getName ( ) and
163
+ input = AutomodelJavaUtil:: getArgumentForIndex ( e .getIndex ( ) ) and
164
+ package = e .getEnclosingCallable ( ) .getDeclaringType ( ) .getPackage ( ) .getName ( ) and
165
+ type = e .getEnclosingCallable ( ) .getDeclaringType ( ) .getErasure ( ) .( RefType ) .nestedName ( ) and
166
+ subtypes = AutomodelJavaUtil:: considerSubtypes ( e .getEnclosingCallable ( ) ) .toString ( ) and
167
+ signature = ExternalFlow:: paramsString ( e .getEnclosingCallable ( ) )
143
168
}
144
169
}
145
170
@@ -207,7 +232,7 @@ private class NotAModelApiParameter extends CharacteristicsImpl::UninterestingTo
207
232
NotAModelApiParameter ( ) { this = "not a model API parameter" }
208
233
209
234
override predicate appliesToEndpoint ( Endpoint e ) {
210
- not exists ( ModelExclusions:: ModelApi api | api .getAParameter ( ) = e . asParameter ( ) )
235
+ not exists ( ModelExclusions:: ModelApi api | api .getAParameter ( ) = e )
211
236
}
212
237
}
213
238
0 commit comments