Skip to content

Commit

Permalink
Improve simple expressions detection for local variable deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
waleedyaseen committed Apr 15, 2024
1 parent a4253df commit aa989c0
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,19 @@ class RsDeleteLocalVariableFix : LocalQuickFix {
}

private fun RsExpression.isSimpleToRemove(): Boolean {
if (this is RsStringLiteralExpression) {
return stringLiteralContent.stringInterpolationExpressionList.all { it.isSimpleToRemove() }
}
return when (this) {
is RsNullLiteralExpression,
is RsIntegerLiteralExpression,
is RsCoordLiteralExpression,
is RsBooleanLiteralExpression,
is RsLongLiteralExpression -> true

is RsLongLiteralExpression,
is RsLocalVariableExpression,
is RsConstantExpression,
is RsArrayAccessExpression -> true
is RsStringInterpolationExpression -> expression.isSimpleToRemove()
is RsParExpression -> expression.isSimpleToRemove()
is RsCalcExpression -> expression.isSimpleToRemove()
is RsBinaryExpression -> left.isSimpleToRemove() && right.isSimpleToRemove()
Expand Down

0 comments on commit aa989c0

Please sign in to comment.