Skip to content

Commit 5113041

Browse files
Jami CogswellJami Cogswell
authored andcommitted
Java: add isParameterless predicate to Constructor class
1 parent a8a8b03 commit 5113041

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

java/ql/lib/semmle/code/java/Member.qll

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,9 @@ class Constructor extends Callable, @constructor {
628628
/** Holds if this is a default constructor, not explicitly declared in source code. */
629629
predicate isDefaultConstructor() { isDefConstr(this) }
630630

631+
/** Holds if this is a constructor without parameters. */
632+
predicate isParameterless() { this.getNumberOfParameters() = 0 }
633+
631634
override Constructor getSourceDeclaration() { constrs(this, _, _, _, _, result) }
632635

633636
override string getSignature() { constrs(this, _, result, _, _, _) }

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

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,6 @@ private predicate isJdkInternal(J::CompilationUnit cu) {
5252
cu.getPackage().getName() = ""
5353
}
5454

55-
/** Holds if the given API is a constructor without parameters. */
56-
private predicate isParameterlessConstructor(J::Callable api) {
57-
api instanceof J::Constructor and api.getNumberOfParameters() = 0
58-
}
59-
6055
/**
6156
* Holds if it is relevant to generate models for `api`.
6257
*/
@@ -65,7 +60,7 @@ private predicate isRelevantForModels(J::Callable api) {
6560
not isJdkInternal(api.getCompilationUnit()) and
6661
not api instanceof J::MainMethod and
6762
not api instanceof J::StaticInitializer and
68-
not isParameterlessConstructor(api)
63+
not api.(J::Constructor).isParameterless()
6964
}
7065

7166
/**

0 commit comments

Comments
 (0)