Skip to content

Commit ea68837

Browse files
committed
Apply review findings
1 parent 7e8b20d commit ea68837

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

java/kotlin-extractor2/src/main/kotlin/entities/Expression.kt

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,22 @@ private fun isNumericFunction(target: KaFunctionSymbol, fName: String): Boolean
236236
isFunction(target, "kotlin", "Double", fName)
237237
}
238238

239+
/**
240+
* Extracts a binary expression as either a binary expression or a function call.
241+
*
242+
* Overloaded operators are extracted as function calls.
243+
*
244+
* ```
245+
* data class Counter(val dayIndex: Int) {
246+
* operator fun plus(increment: Int): Counter {
247+
* return Counter(dayIndex + increment)
248+
* }
249+
* }
250+
* ```
251+
*
252+
* `Counter(1) + 3` is extracted as `Counter(1).plus(3)`.
253+
*
254+
*/
239255
context(KaSession)
240256
private fun KotlinFileExtractor.extractBinaryExpression(
241257
expression: KtBinaryExpression,
@@ -261,11 +277,9 @@ private fun KotlinFileExtractor.extractBinaryExpression(
261277
extractExprContext(id, tw.getLocation(expression), callable, exprParent.enclosingStmt)
262278
extractExpressionExpr(expression.left!!, callable, id, 0, exprParent.enclosingStmt)
263279
extractExpressionExpr(expression.right!!, callable, id, 1, exprParent.enclosingStmt)
264-
265-
return
280+
} else {
281+
TODO()
266282
}
267-
268-
TODO()
269283
}
270284

271285
else -> TODO()

0 commit comments

Comments
 (0)