Skip to content

Commit

Permalink
Restore asStmt, asExpr and asCall to Node
Browse files Browse the repository at this point in the history
It doesn't really make sense to define them in terms of dispatch.
  • Loading branch information
owen-mc committed Dec 12, 2024
1 parent aaa4361 commit 8e11789
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions java/ql/lib/semmle/code/java/ControlFlowGraph.qll
Original file line number Diff line number Diff line change
Expand Up @@ -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() }
Expand All @@ -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. */
Expand All @@ -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() }
Expand Down

0 comments on commit 8e11789

Please sign in to comment.