ReplaceWithTraditionalAssignmentIntention - smaller range
This commit is contained in:
+6
-5
@@ -22,11 +22,12 @@ import org.jetbrains.kotlin.psi.JetBinaryExpression
|
||||
import org.jetbrains.kotlin.psi.JetPsiFactory
|
||||
import org.jetbrains.kotlin.psi.JetSimpleNameExpression
|
||||
|
||||
public class ReplaceWithTraditionalAssignmentIntention : JetSelfTargetingOffsetIndependentIntention<JetBinaryExpression>(javaClass(), "Replace with traditional assignment") {
|
||||
override fun isApplicableTo(element: JetBinaryExpression): Boolean {
|
||||
return element.getOperationToken() in JetTokens.AUGMENTED_ASSIGNMENTS
|
||||
&& element.getLeft() is JetSimpleNameExpression
|
||||
&& element.getRight() != null
|
||||
public class ReplaceWithTraditionalAssignmentIntention : JetSelfTargetingIntention<JetBinaryExpression>(javaClass(), "Replace with traditional assignment") {
|
||||
override fun isApplicableTo(element: JetBinaryExpression, caretOffset: Int): Boolean {
|
||||
if (element.getOperationToken() !in JetTokens.AUGMENTED_ASSIGNMENTS) return false
|
||||
if (element.getLeft() !is JetSimpleNameExpression) return false
|
||||
if (element.getRight() == null) return false
|
||||
return element.getOperationReference().getTextRange().containsOffset(caretOffset)
|
||||
}
|
||||
|
||||
override fun applyTo(element: JetBinaryExpression, editor: Editor) {
|
||||
|
||||
@@ -2,5 +2,5 @@ fun foo() {
|
||||
var x = 0
|
||||
val a = 1
|
||||
val b = 1
|
||||
<caret>x += a / b
|
||||
x <caret>+= a / b
|
||||
}
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
// IS_APPLICABLE: false
|
||||
fun foo() {
|
||||
var x = 0
|
||||
<caret>x + 1
|
||||
x <caret>+ 1
|
||||
}
|
||||
@@ -3,5 +3,5 @@ fun foo() {
|
||||
var x = 0
|
||||
val a = 1
|
||||
val b = 1
|
||||
<caret>x = a / b
|
||||
x <caret>= a / b
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
fun foo() {
|
||||
var x = 0
|
||||
<caret>x += 1
|
||||
x <caret>+= 1
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
fun foo() {
|
||||
var x = 0
|
||||
<caret>x = x + 1
|
||||
x <caret>= x + 1
|
||||
}
|
||||
Reference in New Issue
Block a user