From ea688372bddc167510d98944207b01b211f92f46 Mon Sep 17 00:00:00 2001 From: Tamas Vajk Date: Fri, 11 Oct 2024 10:17:16 +0200 Subject: [PATCH] Apply review findings --- .../src/main/kotlin/entities/Expression.kt | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/java/kotlin-extractor2/src/main/kotlin/entities/Expression.kt b/java/kotlin-extractor2/src/main/kotlin/entities/Expression.kt index f052abc2cc5..97a18aafb58 100644 --- a/java/kotlin-extractor2/src/main/kotlin/entities/Expression.kt +++ b/java/kotlin-extractor2/src/main/kotlin/entities/Expression.kt @@ -236,6 +236,22 @@ private fun isNumericFunction(target: KaFunctionSymbol, fName: String): Boolean isFunction(target, "kotlin", "Double", fName) } +/** + * Extracts a binary expression as either a binary expression or a function call. + * + * Overloaded operators are extracted as function calls. + * + * ``` + * data class Counter(val dayIndex: Int) { + * operator fun plus(increment: Int): Counter { + * return Counter(dayIndex + increment) + * } + * } + * ``` + * + * `Counter(1) + 3` is extracted as `Counter(1).plus(3)`. + * + */ context(KaSession) private fun KotlinFileExtractor.extractBinaryExpression( expression: KtBinaryExpression, @@ -261,11 +277,9 @@ private fun KotlinFileExtractor.extractBinaryExpression( extractExprContext(id, tw.getLocation(expression), callable, exprParent.enclosingStmt) extractExpressionExpr(expression.left!!, callable, id, 0, exprParent.enclosingStmt) extractExpressionExpr(expression.right!!, callable, id, 1, exprParent.enclosingStmt) - - return + } else { + TODO() } - - TODO() } else -> TODO()