Minor: intention message changed for if/when -> assignment/return
This commit is contained in:
+4
-1
@@ -26,7 +26,10 @@ import org.jetbrains.kotlin.psi.KtPsiFactory
|
|||||||
import org.jetbrains.kotlin.psi.createExpressionByPattern
|
import org.jetbrains.kotlin.psi.createExpressionByPattern
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType
|
import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType
|
||||||
|
|
||||||
class FoldIfToAssignmentIntention : SelfTargetingRangeIntention<KtIfExpression>(KtIfExpression::class.java, "Replace 'if' expression with assignment") {
|
class FoldIfToAssignmentIntention : SelfTargetingRangeIntention<KtIfExpression>(
|
||||||
|
KtIfExpression::class.java,
|
||||||
|
"Lift assignment out of 'if' expression"
|
||||||
|
) {
|
||||||
override fun applicabilityRange(element: KtIfExpression): TextRange? {
|
override fun applicabilityRange(element: KtIfExpression): TextRange? {
|
||||||
val branches = element.branches
|
val branches = element.branches
|
||||||
|
|
||||||
|
|||||||
+4
-1
@@ -26,7 +26,10 @@ import org.jetbrains.kotlin.psi.KtPsiFactory
|
|||||||
import org.jetbrains.kotlin.psi.createExpressionByPattern
|
import org.jetbrains.kotlin.psi.createExpressionByPattern
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType
|
import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType
|
||||||
|
|
||||||
class FoldIfToReturnIntention : SelfTargetingRangeIntention<KtIfExpression>(KtIfExpression::class.java, "Replace 'if' expression with return") {
|
class FoldIfToReturnIntention : SelfTargetingRangeIntention<KtIfExpression>(
|
||||||
|
KtIfExpression::class.java,
|
||||||
|
"Lift return out of 'if' expression"
|
||||||
|
) {
|
||||||
|
|
||||||
override fun applicabilityRange(element: KtIfExpression): TextRange? {
|
override fun applicabilityRange(element: KtIfExpression): TextRange? {
|
||||||
val branches = element.branches
|
val branches = element.branches
|
||||||
|
|||||||
+4
-1
@@ -23,7 +23,10 @@ import org.jetbrains.kotlin.idea.intentions.branchedTransformations.BranchedFold
|
|||||||
import org.jetbrains.kotlin.psi.*
|
import org.jetbrains.kotlin.psi.*
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
class FoldWhenToAssignmentIntention : SelfTargetingRangeIntention<KtWhenExpression>(KtWhenExpression::class.java, "Replace 'when' expression with assignment") {
|
class FoldWhenToAssignmentIntention : SelfTargetingRangeIntention<KtWhenExpression>(
|
||||||
|
KtWhenExpression::class.java,
|
||||||
|
"Lift assignment out of 'when' expression"
|
||||||
|
) {
|
||||||
override fun applicabilityRange(element: KtWhenExpression): TextRange? {
|
override fun applicabilityRange(element: KtWhenExpression): TextRange? {
|
||||||
if (!KtPsiUtil.checkWhenExpressionHasSingleElse(element)) return null
|
if (!KtPsiUtil.checkWhenExpressionHasSingleElse(element)) return null
|
||||||
|
|
||||||
|
|||||||
+4
-1
@@ -22,7 +22,10 @@ import org.jetbrains.kotlin.idea.intentions.SelfTargetingRangeIntention
|
|||||||
import org.jetbrains.kotlin.idea.intentions.branchedTransformations.BranchedFoldingUtils
|
import org.jetbrains.kotlin.idea.intentions.branchedTransformations.BranchedFoldingUtils
|
||||||
import org.jetbrains.kotlin.psi.*
|
import org.jetbrains.kotlin.psi.*
|
||||||
|
|
||||||
class FoldWhenToReturnIntention : SelfTargetingRangeIntention<KtWhenExpression>(KtWhenExpression::class.java, "Replace 'when' expression with return") {
|
class FoldWhenToReturnIntention : SelfTargetingRangeIntention<KtWhenExpression>(
|
||||||
|
KtWhenExpression::class.java,
|
||||||
|
"Lift return out of 'when' expression"
|
||||||
|
) {
|
||||||
override fun applicabilityRange(element: KtWhenExpression): TextRange? {
|
override fun applicabilityRange(element: KtWhenExpression): TextRange? {
|
||||||
if (!KtPsiUtil.checkWhenExpressionHasSingleElse(element)) return null
|
if (!KtPsiUtil.checkWhenExpressionHasSingleElse(element)) return null
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user