Skip to content

Commit

Permalink
Extract comparison operators
Browse files Browse the repository at this point in the history
  • Loading branch information
tamasvajk committed Oct 16, 2024
1 parent a19b5e6 commit 118183e
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion java/kotlin-extractor2/src/main/kotlin/entities/Expression.kt
Original file line number Diff line number Diff line change
Expand Up @@ -318,8 +318,21 @@ private fun KotlinFileExtractor.extractBinaryExpression(
extractBinaryExpression(expression, callable, parent, tw::writeExprs_eqexpr)
} else if (op == KtTokens.EXCLEQEQEQ && target == null) {
extractBinaryExpression(expression, callable, parent, tw::writeExprs_neexpr)
} else if (op in listOf(KtTokens.LT, KtTokens.GT, KtTokens.LTEQ, KtTokens.GTEQ)) {
if (target.isNumericWithName("compareTo")) {
when (op) {
KtTokens.LT -> extractBinaryExpression(expression, callable, parent, tw::writeExprs_ltexpr)
KtTokens.GT -> extractBinaryExpression(expression, callable, parent, tw::writeExprs_gtexpr)
KtTokens.LTEQ -> extractBinaryExpression(expression, callable, parent, tw::writeExprs_leexpr)
KtTokens.GTEQ -> extractBinaryExpression(expression, callable, parent, tw::writeExprs_gtexpr)
else -> TODO("error")
}
} else {
TODO("Extract lowered equivalent call, such as `a.compareTo(b) < 0`")
}

} else {
// todo: other operators, such as .., ..<, in, !in, +=, -=, *=, /=, %=, <, >, <=, >=, ==, !=,
// todo: other operators, such as .., ..<, in, !in, =, +=, -=, *=, /=, %=, ==, !=,
TODO("Extract as method call")
}
}
Expand Down

0 comments on commit 118183e

Please sign in to comment.