Fix hint text for replace with operator assignment #KT-23559 Fixed
This commit is contained in:
committed by
Mikhail Glukhikh
parent
8c3e787584
commit
c49eaf2604
+1
-1
@@ -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
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
// FIX: Replace with '+='
|
||||
fun foo() {
|
||||
var x = 0
|
||||
x += 1
|
||||
}
|
||||
+5
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user