Skip to content

Commit 64145cf

Browse files
committed
Java: Make it evident that we print signature of the lifted callable.
1 parent f00ad7c commit 64145cf

File tree

1 file changed

+22
-24
lines changed

1 file changed

+22
-24
lines changed

java/ql/src/utils/modelgenerator/internal/CaptureModelsSpecific.qll

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -98,43 +98,41 @@ class TargetApiSpecific extends Callable {
9898
Callable lift() { result = lift }
9999
}
100100

101-
private string isExtensible(J::RefType ref) {
102-
if ref.isFinal() then result = "false" else result = "true"
103-
}
104-
105-
private string typeAsModel(J::RefType type) {
106-
result =
107-
type.getCompilationUnit().getPackage().getName() + ";" +
108-
type.getErasure().(J::RefType).nestedName()
109-
}
110-
111-
private J::RefType bestTypeForModel(TargetApiSpecific api) {
112-
result = api.lift().getDeclaringType()
101+
private string isExtensible(Callable c) {
102+
if c.getDeclaringType().isFinal() then result = "false" else result = "true"
113103
}
114104

115105
/**
116-
* Returns the appropriate type name for the model. Either the type
117-
* declaring the method or the supertype introducing the method.
106+
* Returns the appropriate type name for the model.
118107
*/
119-
private string typeAsSummaryModel(TargetApiSpecific api) {
120-
result = typeAsModel(bestTypeForModel(api))
108+
private string typeAsModel(Callable c) {
109+
exists(RefType type | type = c.getDeclaringType() |
110+
result =
111+
type.getCompilationUnit().getPackage().getName() + ";" +
112+
type.getErasure().(J::RefType).nestedName()
113+
)
121114
}
122115

123-
private predicate partialModel(TargetApiSpecific api, string type, string name, string parameters) {
124-
type = typeAsSummaryModel(api) and
125-
name = api.getName() and
126-
parameters = ExternalFlow::paramsString(api)
116+
private predicate partialLiftedModel(
117+
TargetApiSpecific api, string type, string extensible, string name, string parameters
118+
) {
119+
exists(Callable c | c = api.lift() |
120+
type = typeAsModel(c) and
121+
extensible = isExtensible(c) and
122+
name = c.getName() and
123+
parameters = ExternalFlow::paramsString(c)
124+
)
127125
}
128126

129127
/**
130128
* Computes the first 6 columns for MaD rows.
131129
*/
132130
string asPartialModel(TargetApiSpecific api) {
133-
exists(string type, string name, string parameters |
134-
partialModel(api, type, name, parameters) and
131+
exists(string type, string extensible, string name, string parameters |
132+
partialLiftedModel(api, type, extensible, name, parameters) and
135133
result =
136134
type + ";" //
137-
+ isExtensible(bestTypeForModel(api)) + ";" //
135+
+ extensible + ";" //
138136
+ name + ";" //
139137
+ parameters + ";" //
140138
+ /* ext + */ ";" //
@@ -146,7 +144,7 @@ string asPartialModel(TargetApiSpecific api) {
146144
*/
147145
string asPartialNeutralModel(TargetApiSpecific api) {
148146
exists(string type, string name, string parameters |
149-
partialModel(api, type, name, parameters) and
147+
partialLiftedModel(api, type, _, name, parameters) and
150148
result =
151149
type + ";" //
152150
+ name + ";" //

0 commit comments

Comments
 (0)