From 8e1178918630fddaaaabb4157b21f8da8b62eee2 Mon Sep 17 00:00:00 2001 From: Owen Mansel-Chan Date: Thu, 12 Dec 2024 12:30:01 +0000 Subject: [PATCH] Restore `asStmt`, `asExpr` and `asCall` to `Node` It doesn't really make sense to define them in terms of dispatch. --- .../lib/semmle/code/java/ControlFlowGraph.qll | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/java/ql/lib/semmle/code/java/ControlFlowGraph.qll b/java/ql/lib/semmle/code/java/ControlFlowGraph.qll index 4702fb45b09..e3c7ed6e5d9 100644 --- a/java/ql/lib/semmle/code/java/ControlFlowGraph.qll +++ b/java/ql/lib/semmle/code/java/ControlFlowGraph.qll @@ -129,13 +129,16 @@ module ControlFlow { Callable getEnclosingCallable() { none() } /** Gets the statement this `Node` corresponds to, if any. */ - Stmt asStmt() { none() } + Stmt asStmt() { this = TStmtNode(result) } /** Gets the expression this `Node` corresponds to, if any. */ - Expr asExpr() { none() } + Expr asExpr() { this = TExprNode(result) } /** Gets the call this `Node` corresponds to, if any. */ - Call asCall() { none() } + Call asCall() { + result = this.asExpr() or + result = this.asStmt() + } /** Gets a textual representation of this element. */ string toString() { none() } @@ -159,10 +162,6 @@ module ControlFlow { override Callable getEnclosingCallable() { result = e.getEnclosingCallable() } - override Expr asExpr() { result = e } - - override Call asCall() { result = e } - override ExprParent getAstNode() { result = e } /** Gets a textual representation of this element. */ @@ -182,10 +181,6 @@ module ControlFlow { override Callable getEnclosingCallable() { result = s.getEnclosingCallable() } - override Stmt asStmt() { result = s } - - override Call asCall() { result = s } - override ExprParent getAstNode() { result = s } override string toString() { result = s.toString() }