@@ -22,6 +22,8 @@ class Type = J::Type;
22
22
23
23
class Unit = J:: Unit ;
24
24
25
+ class Callable = J:: Callable ;
26
+
25
27
private J:: Method superImpl ( J:: Method m ) {
26
28
result = m .getAnOverride ( ) and
27
29
not exists ( result .getAnOverride ( ) ) and
@@ -36,7 +38,7 @@ private predicate isInfrequentlyUsed(J::CompilationUnit cu) {
36
38
/**
37
39
* Holds if it is relevant to generate models for `api`.
38
40
*/
39
- private predicate isRelevantForModels ( J :: Callable api ) {
41
+ private predicate isRelevantForModels ( Callable api ) {
40
42
not isUninterestingForModels ( api ) and
41
43
not isInfrequentlyUsed ( api .getCompilationUnit ( ) ) and
42
44
// Disregard all APIs that have a manual model.
@@ -48,7 +50,7 @@ private predicate isRelevantForModels(J::Callable api) {
48
50
/**
49
51
* Holds if it is relevant to generate models for `api` based on data flow analysis.
50
52
*/
51
- predicate isRelevantForDataFlowModels ( J :: Callable api ) {
53
+ predicate isRelevantForDataFlowModels ( Callable api ) {
52
54
isRelevantForModels ( api ) and
53
55
( not api .getDeclaringType ( ) instanceof J:: Interface or exists ( api .getBody ( ) ) )
54
56
}
@@ -61,7 +63,7 @@ predicate isRelevantForTypeBasedFlowModels = isRelevantForModels/1;
61
63
* In the Standard library and 3rd party libraries it the Callables that can be called
62
64
* from outside the library itself.
63
65
*/
64
- class TargetApiSpecific extends J :: Callable {
66
+ class TargetApiSpecific extends Callable {
65
67
TargetApiSpecific ( ) {
66
68
this .isPublic ( ) and
67
69
this .fromSource ( ) and
@@ -71,6 +73,15 @@ class TargetApiSpecific extends J::Callable {
71
73
) and
72
74
isRelevantForModels ( this )
73
75
}
76
+
77
+ /**
78
+ * Gets the callable that a model will be lifted to, if any.
79
+ */
80
+ Callable lift ( ) {
81
+ exists ( Method m | m = superImpl ( this ) and m .fromSource ( ) | result = m )
82
+ or
83
+ not exists ( superImpl ( this ) ) and result = this
84
+ }
74
85
}
75
86
76
87
private string isExtensible ( J:: RefType ref ) {
@@ -84,9 +95,7 @@ private string typeAsModel(J::RefType type) {
84
95
}
85
96
86
97
private J:: RefType bestTypeForModel ( TargetApiSpecific api ) {
87
- if exists ( superImpl ( api ) )
88
- then superImpl ( api ) .fromSource ( ) and result = superImpl ( api ) .getDeclaringType ( )
89
- else result = api .getDeclaringType ( )
98
+ result = api .lift ( ) .getDeclaringType ( )
90
99
}
91
100
92
101
/**
@@ -200,7 +209,7 @@ string returnNodeAsOutput(DataFlowImplCommon::ReturnNodeExt node) {
200
209
/**
201
210
* Gets the enclosing callable of `ret`.
202
211
*/
203
- J :: Callable returnNodeEnclosingCallable ( DataFlowImplCommon:: ReturnNodeExt ret ) {
212
+ Callable returnNodeEnclosingCallable ( DataFlowImplCommon:: ReturnNodeExt ret ) {
204
213
result = DataFlowImplCommon:: getNodeEnclosingCallable ( ret ) .asCallable ( )
205
214
}
206
215
0 commit comments