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