mirror of
https://github.com/github/codeql.git
synced 2026-04-29 18:55:14 +02:00
Java: add isParameterless predicate to Constructor class
This commit is contained in:
@@ -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, _, _, _) }
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user