mirror of
https://github.com/github/codeql.git
synced 2026-02-28 12:53:49 +01:00
Java: Rename getTrueExpr/getFalseExpr on ConditionalExpr to getThen/getElse.
This commit is contained in:
@@ -166,8 +166,8 @@ class CompileTimeConstantExpr extends Expr {
|
||||
// The ternary conditional operator ` ? : `.
|
||||
exists(ConditionalExpr e | this = e |
|
||||
e.getCondition().isCompileTimeConstant() and
|
||||
e.getTrueExpr().isCompileTimeConstant() and
|
||||
e.getFalseExpr().isCompileTimeConstant()
|
||||
e.getThen().isCompileTimeConstant() and
|
||||
e.getElse().isCompileTimeConstant()
|
||||
)
|
||||
or
|
||||
// Access to a final variable initialized by a compile-time constant.
|
||||
@@ -1464,26 +1464,42 @@ class ConditionalExpr extends Expr, @conditionalexpr {
|
||||
Expr getCondition() { result.isNthChildOf(this, 0) }
|
||||
|
||||
/**
|
||||
* DEPRECATED: Use getThen() instead.
|
||||
*
|
||||
* Gets the expression that is evaluated if the condition of this
|
||||
* conditional expression evaluates to `true`.
|
||||
*/
|
||||
Expr getTrueExpr() { result.isNthChildOf(this, 1) }
|
||||
deprecated Expr getTrueExpr() { result.isNthChildOf(this, 1) }
|
||||
|
||||
/**
|
||||
* DEPRECATED: Use getElse() instead.
|
||||
*
|
||||
* Gets the expression that is evaluated if the condition of this
|
||||
* conditional expression evaluates to `false`.
|
||||
*/
|
||||
deprecated Expr getFalseExpr() { result.isNthChildOf(this, 2) }
|
||||
|
||||
/**
|
||||
* Gets the expression that is evaluated if the condition of this
|
||||
* conditional expression evaluates to `true`.
|
||||
*/
|
||||
Expr getThen() { result.isNthChildOf(this, 1) }
|
||||
|
||||
/**
|
||||
* Gets the expression that is evaluated if the condition of this
|
||||
* conditional expression evaluates to `false`.
|
||||
*/
|
||||
Expr getFalseExpr() { result.isNthChildOf(this, 2) }
|
||||
Expr getElse() { result.isNthChildOf(this, 2) }
|
||||
|
||||
/**
|
||||
* Gets the expression that is evaluated by the specific branch of this
|
||||
* conditional expression. If `true` that is `getTrueExpr()`, if `false`
|
||||
* it is `getFalseExpr()`.
|
||||
* conditional expression. If `true` that is `getThen()`, if `false`
|
||||
* it is `getElse()`.
|
||||
*/
|
||||
Expr getBranchExpr(boolean branch) {
|
||||
branch = true and result = this.getTrueExpr()
|
||||
branch = true and result = this.getThen()
|
||||
or
|
||||
branch = false and result = this.getFalseExpr()
|
||||
branch = false and result = this.getElse()
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -351,9 +351,9 @@ private class PpConditionalExpr extends PpAst, ConditionalExpr {
|
||||
override PpAst getChild(int i) {
|
||||
i = 0 and result = this.getCondition()
|
||||
or
|
||||
i = 2 and result = this.getTrueExpr()
|
||||
i = 2 and result = this.getThen()
|
||||
or
|
||||
i = 4 and result = this.getFalseExpr()
|
||||
i = 4 and result = this.getElse()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -315,13 +315,7 @@ private module GuardsInput implements SharedGuards::InputSig<Location, ControlFl
|
||||
)
|
||||
}
|
||||
|
||||
class ConditionalExpr extends Expr instanceof J::ConditionalExpr {
|
||||
Expr getCondition() { result = super.getCondition() }
|
||||
|
||||
Expr getThen() { result = super.getTrueExpr() }
|
||||
|
||||
Expr getElse() { result = super.getFalseExpr() }
|
||||
}
|
||||
class ConditionalExpr = J::ConditionalExpr;
|
||||
|
||||
class Parameter = J::Parameter;
|
||||
|
||||
|
||||
@@ -86,8 +86,8 @@ Expr clearlyNotNullExpr(Expr reason) {
|
||||
or
|
||||
exists(ConditionalExpr c, Expr r1, Expr r2 |
|
||||
c = result and
|
||||
c.getTrueExpr() = clearlyNotNullExpr(r1) and
|
||||
c.getFalseExpr() = clearlyNotNullExpr(r2) and
|
||||
c.getThen() = clearlyNotNullExpr(r1) and
|
||||
c.getElse() = clearlyNotNullExpr(r2) and
|
||||
(reason = r1 or reason = r2)
|
||||
)
|
||||
or
|
||||
|
||||
Reference in New Issue
Block a user