Java: add isParameterless predicate to Constructor class

This commit is contained in:
Jami Cogswell
2022-12-09 15:07:25 -05:00
parent a8a8b03d2f
commit 5113041623
2 changed files with 4 additions and 6 deletions

View File

@@ -628,6 +628,9 @@ class Constructor extends Callable, @constructor {
/** Holds if this is a default constructor, not explicitly declared in source code. */
predicate isDefaultConstructor() { isDefConstr(this) }
/** Holds if this is a constructor without parameters. */
predicate isParameterless() { this.getNumberOfParameters() = 0 }
override Constructor getSourceDeclaration() { constrs(this, _, _, _, _, result) }
override string getSignature() { constrs(this, _, result, _, _, _) }

View File

@@ -52,11 +52,6 @@ private predicate isJdkInternal(J::CompilationUnit cu) {
cu.getPackage().getName() = ""
}
/** Holds if the given API is a constructor without parameters. */
private predicate isParameterlessConstructor(J::Callable api) {
api instanceof J::Constructor and api.getNumberOfParameters() = 0
}
/**
* Holds if it is relevant to generate models for `api`.
*/
@@ -65,7 +60,7 @@ private predicate isRelevantForModels(J::Callable api) {
not isJdkInternal(api.getCompilationUnit()) and
not api instanceof J::MainMethod and
not api instanceof J::StaticInitializer and
not isParameterlessConstructor(api)
not api.(J::Constructor).isParameterless()
}
/**