Java: add hasApiName predicate

This commit is contained in:
Jami Cogswell
2022-12-19 08:38:12 -05:00
parent f933fc75cd
commit 42ddd66360
2 changed files with 8 additions and 14 deletions

View File

@@ -61,24 +61,18 @@ predicate topJdkApiName(string apiName) {
]
}
/**
* Gets information about the given API in the form expected by the
* MaD modeling framework.
*/
string getApiName(Callable api) {
result =
api.getDeclaringType().getPackage() + "." + api.getDeclaringType().getSourceDeclaration() + "#" +
api.getName() + paramsString(api)
/** Holds if `c` has the MaD-formatted name `apiName`. */
predicate hasApiName(Callable c, string apiName) {
apiName =
c.getDeclaringType().getPackage() + "." + c.getDeclaringType().getSourceDeclaration() + "#" +
c.getName() + paramsString(c)
}
/** Holds if the given API has a `Callable`. */
predicate hasCallable(string apiName) { exists(Callable callable | apiName = getApiName(callable)) }
/** A top JDK API. */
class TopJdkApi extends SummarizedCallableBase {
TopJdkApi() {
exists(string apiName |
apiName = getApiName(this.asCallable()) and
hasApiName(this.asCallable(), apiName) and
topJdkApiName(apiName)
)
}

View File

@@ -5,13 +5,13 @@ from string apiName, string message
where
// top jdk api names for which there is no callable
topJdkApiName(apiName) and
not hasCallable(apiName) and
not exists(Callable c | hasApiName(c, apiName)) and
message = "no callable"
or
// top jdk api names for which there isn't a manual model
exists(TopJdkApi topApi |
not topApi.hasManualMadModel() and
apiName = getApiName(topApi.asCallable()) and
hasApiName(topApi.asCallable(), apiName) and
message = "no manual model"
)
select apiName, message order by apiName