Java: Add entity discard predicates

This commit is contained in:
Kasper Svendsen
2025-01-09 09:35:56 +01:00
parent b6e56f26c7
commit 6e92d7e247
7 changed files with 134 additions and 0 deletions

View File

@@ -6,6 +6,7 @@ module;
import Expr
import metrics.MetricStmt
private import semmle.code.java.Overlay
/** A common super-class of all statements. */
class Stmt extends StmtParent, ExprParent, @stmt {
@@ -987,3 +988,15 @@ class SuperConstructorInvocationStmt extends Stmt, ConstructorCall, @superconstr
override string getAPrimaryQlClass() { result = "SuperConstructorInvocationStmt" }
}
overlay[local]
private predicate discardableStmt(string file, @stmt s) {
not isOverlay() and
file = getRawFile(s)
}
/** Discard base statements in files fully extracted in the overlay. */
overlay[discard_entity]
private predicate discardStmt(@stmt s) {
exists(string file | discardableStmt(file, s) and extractedInOverlay(file))
}