Skip to content

Commit 8e11789

Browse files
committed
Restore asStmt, asExpr and asCall to Node
It doesn't really make sense to define them in terms of dispatch.
1 parent aaa4361 commit 8e11789

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

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

+6-11
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,16 @@ module ControlFlow {
129129
Callable getEnclosingCallable() { none() }
130130

131131
/** Gets the statement this `Node` corresponds to, if any. */
132-
Stmt asStmt() { none() }
132+
Stmt asStmt() { this = TStmtNode(result) }
133133

134134
/** Gets the expression this `Node` corresponds to, if any. */
135-
Expr asExpr() { none() }
135+
Expr asExpr() { this = TExprNode(result) }
136136

137137
/** Gets the call this `Node` corresponds to, if any. */
138-
Call asCall() { none() }
138+
Call asCall() {
139+
result = this.asExpr() or
140+
result = this.asStmt()
141+
}
139142

140143
/** Gets a textual representation of this element. */
141144
string toString() { none() }
@@ -159,10 +162,6 @@ module ControlFlow {
159162

160163
override Callable getEnclosingCallable() { result = e.getEnclosingCallable() }
161164

162-
override Expr asExpr() { result = e }
163-
164-
override Call asCall() { result = e }
165-
166165
override ExprParent getAstNode() { result = e }
167166

168167
/** Gets a textual representation of this element. */
@@ -182,10 +181,6 @@ module ControlFlow {
182181

183182
override Callable getEnclosingCallable() { result = s.getEnclosingCallable() }
184183

185-
override Stmt asStmt() { result = s }
186-
187-
override Call asCall() { result = s }
188-
189184
override ExprParent getAstNode() { result = s }
190185

191186
override string toString() { result = s.toString() }

0 commit comments

Comments
 (0)