Extract not-null expression

This commit is contained in:
Tamas Vajk
2021-11-23 11:47:35 +01:00
committed by Ian Lynagh
parent 6603767d94
commit 716b87d200
7 changed files with 126 additions and 45 deletions

View File

@@ -695,6 +695,7 @@ case @expr.kind of
| 79 = @stmtexpr
| 80 = @stringtemplateexpr
| 81 = @varargexpr
| 82 = @notnullexpr
;
/** Holds if this `when` expression was written as an `if` expression. */
@@ -771,7 +772,8 @@ when_branch_else(unique int id: @whenbranch ref);
| @minusexpr
| @plusexpr
| @bitnotexpr
| @lognotexpr;
| @lognotexpr
| @notnullexpr;
@caller = @classinstancexpr
| @methodaccess

View File

@@ -1463,9 +1463,7 @@ class InstanceOfExpr extends Expr, @instanceofexpr {
/** An `instanceof` expression. */
class NotInstanceOfExpr extends Expr, @notinstanceofexpr {
/** Gets the expression on the left-hand side of the `!is` operator. */
Expr getExpr() {
result.isNthChildOf(this, 0)
}
Expr getExpr() { result.isNthChildOf(this, 0) }
/** Gets the access to the type on the right-hand side of the `!is` operator. */
Expr getTypeName() { result.isNthChildOf(this, 1) }
@@ -2195,19 +2193,13 @@ class WhenBranch extends Top, @whenbranch {
Expr getCondition() { result.isNthChildOf(this, 0) }
/** Gets the result of this branch. */
Stmt getRhs() {
result.isNthChildOf(this, 1)
}
Stmt getRhs() { result.isNthChildOf(this, 1) }
/** Gets a result expression of this `when` branch. */
Expr getAResult() {
result = getAResult(this.getRhs())
}
Expr getAResult() { result = getAResult(this.getRhs()) }
/** Holds if this is an `else` branch. */
predicate isElseBranch() {
when_branch_else(this)
}
predicate isElseBranch() { when_branch_else(this) }
override string toString() { result = "... -> ..." }
@@ -2290,3 +2282,10 @@ class VarArgExpr extends Expr, @varargexpr {
override string getAPrimaryQlClass() { result = "VarArgExpr" }
}
/** A Kotlin not-null expression. For example, `expr!!`. */
class NotNullExpr extends UnaryExpr, @notnullexpr {
override string toString() { result = "...!!" }
override string getAPrimaryQlClass() { result = "NotNullExpr" }
}