KT-5397 Simplify text of DeMorgan law conversion intentions
#KT-5397
This commit is contained in:
@@ -292,8 +292,10 @@ add.braces=Add braces
|
|||||||
add.braces.family=Add Braces
|
add.braces.family=Add Braces
|
||||||
convert.negated.boolean.sequence=Replace negated sequence with DeMorgan equivalent
|
convert.negated.boolean.sequence=Replace negated sequence with DeMorgan equivalent
|
||||||
convert.negated.boolean.sequence.family=Replace Negated Sequence with DeMorgan Equivalent
|
convert.negated.boolean.sequence.family=Replace Negated Sequence with DeMorgan Equivalent
|
||||||
convert.negated.expression.with.demorgans.law=Convert negated expression to DeMorgan equivalent
|
convert.negated.expression.with.demorgans.law=DeMorgan Law
|
||||||
convert.negated.expression.with.demorgans.law.family=Convert Negated Expression to DeMorgan Equivalent
|
convert.negated.expression.with.demorgans.law.andToOr=Replace '\\&\\&' with '||'
|
||||||
|
convert.negated.expression.with.demorgans.law.orToAnd=Replace '||' with '\\&\\&'
|
||||||
|
convert.negated.expression.with.demorgans.law.family=DeMorgan Law
|
||||||
split.if=Split into 2 if's
|
split.if=Split into 2 if's
|
||||||
split.if.family=Split If
|
split.if.family=Split If
|
||||||
replace.with.operator.assign.intention=Replace with an operator-assign expression
|
replace.with.operator.assign.intention=Replace with an operator-assign expression
|
||||||
|
|||||||
+5
-3
@@ -30,6 +30,7 @@ import org.jetbrains.jet.lang.psi.JetConstantExpression
|
|||||||
import org.jetbrains.jet.lang.psi.JetSimpleNameExpression
|
import org.jetbrains.jet.lang.psi.JetSimpleNameExpression
|
||||||
import java.util.ArrayList
|
import java.util.ArrayList
|
||||||
import java.util.LinkedList
|
import java.util.LinkedList
|
||||||
|
import org.jetbrains.jet.plugin.JetBundle
|
||||||
|
|
||||||
public class ConvertNegatedExpressionWithDemorgansLawIntention : JetSelfTargetingIntention<JetPrefixExpression>(
|
public class ConvertNegatedExpressionWithDemorgansLawIntention : JetSelfTargetingIntention<JetPrefixExpression>(
|
||||||
"convert.negated.expression.with.demorgans.law", javaClass()
|
"convert.negated.expression.with.demorgans.law", javaClass()
|
||||||
@@ -41,10 +42,11 @@ public class ConvertNegatedExpressionWithDemorgansLawIntention : JetSelfTargetin
|
|||||||
|
|
||||||
val parenthesizedExpression = element.getBaseExpression() as? JetParenthesizedExpression
|
val parenthesizedExpression = element.getBaseExpression() as? JetParenthesizedExpression
|
||||||
val baseExpression = parenthesizedExpression?.getExpression() as? JetBinaryExpression ?: return false
|
val baseExpression = parenthesizedExpression?.getExpression() as? JetBinaryExpression ?: return false
|
||||||
val operatorToken = baseExpression.getOperationToken() ?: return false
|
|
||||||
|
|
||||||
if (!(operatorToken == JetTokens.ANDAND || operatorToken == JetTokens.OROR)) {
|
when (baseExpression.getOperationToken()) {
|
||||||
return false
|
JetTokens.ANDAND -> setText(JetBundle.message("convert.negated.expression.with.demorgans.law.andToOr"))
|
||||||
|
JetTokens.OROR -> setText(JetBundle.message("convert.negated.expression.with.demorgans.law.orToAnd"))
|
||||||
|
else -> return false
|
||||||
}
|
}
|
||||||
|
|
||||||
val elements = splitBooleanSequence(baseExpression) ?: return false
|
val elements = splitBooleanSequence(baseExpression) ?: return false
|
||||||
|
|||||||
+2
@@ -1,3 +1,5 @@
|
|||||||
|
// INTENTION_TEXT: Replace '&&' with '||'
|
||||||
|
|
||||||
fun foo(a: Boolean, b: Boolean) : Boolean {
|
fun foo(a: Boolean, b: Boolean) : Boolean {
|
||||||
return !(<caret>a && b)
|
return !(<caret>a && b)
|
||||||
}
|
}
|
||||||
+2
@@ -1,3 +1,5 @@
|
|||||||
|
// INTENTION_TEXT: Replace '&&' with '||'
|
||||||
|
|
||||||
fun foo(a: Boolean, b: Boolean) : Boolean {
|
fun foo(a: Boolean, b: Boolean) : Boolean {
|
||||||
return !a || !b
|
return !a || !b
|
||||||
}
|
}
|
||||||
+2
@@ -1,3 +1,5 @@
|
|||||||
|
// INTENTION_TEXT: Replace '&&' with '||'
|
||||||
|
|
||||||
fun foo(a: Boolean, b: Boolean, c: Boolean) : Boolean {
|
fun foo(a: Boolean, b: Boolean, c: Boolean) : Boolean {
|
||||||
return !(a && <caret>(b && c))
|
return !(a && <caret>(b && c))
|
||||||
}
|
}
|
||||||
+2
@@ -1,3 +1,5 @@
|
|||||||
|
// INTENTION_TEXT: Replace '&&' with '||'
|
||||||
|
|
||||||
fun foo(a: Boolean, b: Boolean, c: Boolean) : Boolean {
|
fun foo(a: Boolean, b: Boolean, c: Boolean) : Boolean {
|
||||||
return !a || !(b && c)
|
return !a || !(b && c)
|
||||||
}
|
}
|
||||||
+2
@@ -1,3 +1,5 @@
|
|||||||
|
// INTENTION_TEXT: Replace '||' with '&&'
|
||||||
|
|
||||||
fun foo(a: Boolean, b: Boolean) : Boolean {
|
fun foo(a: Boolean, b: Boolean) : Boolean {
|
||||||
return !(<caret>a || b)
|
return !(<caret>a || b)
|
||||||
}
|
}
|
||||||
+2
@@ -1,3 +1,5 @@
|
|||||||
|
// INTENTION_TEXT: Replace '||' with '&&'
|
||||||
|
|
||||||
fun foo(a: Boolean, b: Boolean) : Boolean {
|
fun foo(a: Boolean, b: Boolean) : Boolean {
|
||||||
return !a && !b
|
return !a && !b
|
||||||
}
|
}
|
||||||
+2
@@ -1,3 +1,5 @@
|
|||||||
|
// INTENTION_TEXT: Replace '||' with '&&'
|
||||||
|
|
||||||
fun foo(a: Boolean, b: Boolean, c: Boolean) : Boolean {
|
fun foo(a: Boolean, b: Boolean, c: Boolean) : Boolean {
|
||||||
return !(<caret>a || (b && c))
|
return !(<caret>a || (b && c))
|
||||||
}
|
}
|
||||||
+2
@@ -1,3 +1,5 @@
|
|||||||
|
// INTENTION_TEXT: Replace '||' with '&&'
|
||||||
|
|
||||||
fun foo(a: Boolean, b: Boolean, c: Boolean) : Boolean {
|
fun foo(a: Boolean, b: Boolean, c: Boolean) : Boolean {
|
||||||
return !a && !(b && c)
|
return !a && !(b && c)
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user