This commit is contained in:
Tamas Vajk
2024-11-22 11:37:09 +01:00
parent 052a243db6
commit 6c8cb103fc
2 changed files with 13 additions and 1 deletions

View File

@@ -6277,7 +6277,7 @@ open class KotlinFileExtractor(
val condId = tw.getFreshIdLabel<DbWhenbranchcondition>()
tw.writeStmts_whenbranchcondition(condId, bId, 0, callable)
tw.writeHasLocation(id, bLocId)
tw.writeHasLocation(condId, bLocId)
tw.writeWhen_branch_condition_with_expr(condId)
extractExpressionExpr(b.condition, callable, condId, 0, condId)
extractExpressionStmt(b.result, callable, bId, 1)

View File

@@ -2624,6 +2624,10 @@ class WhenBranchConditionWithExpression extends WhenBranchCondition {
/** Gets the expression of this branch condition. */
Expr getExpression() { result.isNthChildOf(this, 0) }
override string toString() { result = "... ->" }
override string getAPrimaryQlClass() { result = "WhenBranchConditionWithExpression" }
}
/** A Kotlin `when` branch condition with a range. */
@@ -2638,6 +2642,10 @@ class WhenBranchConditionWithRange extends WhenBranchCondition {
* Ranges are represented by calls to `operator fun <T : Comparable<T>> T.rangeTo(that: T): ClosedRange<T>`.
*/
MethodCall getRange() { result.isNthChildOf(this, 0) }
override string toString() { result = "in ... ->" }
override string getAPrimaryQlClass() { result = "WhenBranchConditionWithRange" }
}
/** A Kotlin `when` branch condition with a pattern. */
@@ -2649,6 +2657,10 @@ class WhenBranchConditionWithPattern extends WhenBranchCondition {
/** Gets the type pattern of this branch condition. */
Type getType() { when_branch_condition_with_pattern(this, _, result, _) }
override string toString() { result = "is ... ->" }
override string getAPrimaryQlClass() { result = "WhenBranchConditionWithPattern" }
}
// TODO: This might need more cases. It might be better as a predicate