Fix hint text for replace with operator assignment #KT-23559 Fixed

This commit is contained in:
Mon_chi
2018-05-13 14:28:01 +03:00
committed by Mikhail Glukhikh
parent 8c3e787584
commit c49eaf2604
4 changed files with 16 additions and 1 deletions
@@ -55,7 +55,7 @@ class ReplaceWithOperatorAssignmentInspection : AbstractApplicabilityBasedInspec
override val defaultFixText = "Replace with operator-assignment"
override fun fixText(element: KtBinaryExpression) =
"Replace with '${element.operationReference.operationSignTokenType?.value}='"
"Replace with '${(element.right as? KtBinaryExpression)?.operationReference?.operationSignTokenType?.value}='"
private fun checkExpressionRepeat(variableExpression: KtNameReferenceExpression, expression: KtBinaryExpression, bindingContext: BindingContext): Boolean {
val descriptor = bindingContext[BindingContext.REFERENCE_TARGET, expression.operationReference]?.containingDeclaration
@@ -0,0 +1,5 @@
// FIX: Replace with '+='
fun foo() {
var x = 0
<caret>x = x + 1
}
@@ -0,0 +1,5 @@
// FIX: Replace with '+='
fun foo() {
var x = 0
x += 1
}
@@ -3977,6 +3977,11 @@ public class LocalInspectionTestGenerated extends AbstractLocalInspectionTest {
runTest("idea/testData/inspectionsLocal/replaceWithOperatorAssignment/simpleAssign.kt");
}
@TestMetadata("validAddition.kt")
public void testValidAddition() throws Exception {
runTest("idea/testData/inspectionsLocal/replaceWithOperatorAssignment/validAddition.kt");
}
@TestMetadata("validSubtraction.kt")
public void testValidSubtraction() throws Exception {
runTest("idea/testData/inspectionsLocal/replaceWithOperatorAssignment/validSubtraction.kt");